<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-pref-consumption/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-pref-consumption

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-pref-consumption>` web component is a preference control of the Magma Design System that lets the user pick an energy-consumption mode (`low`, `medium`, `high`); it is usually a child of [`<mds-pref>`](../mds-pref/AGENTS.md) and renders as a tab group with one option per mode, so it has no native HTML primitive equivalent.

#### Semantic Behavior

- **Usually inside `<mds-pref>`**: Placed as a direct slot child of `<mds-pref>`, alongside the other `mds-pref-*` controls; it also works on its own, since it applies and stores the preference by itself.
- **Mode resolution on load**: The active mode is resolved once, on load, in priority order - the `mode` prop, then the persisted value, then the `high` default - so the control restores the last user choice across reloads.
- **Applies the preference globally**: Selecting a mode applies it across the whole document and persists the choice.
- **Change event**: Each change emits `mdsPrefChange` with `{ preference: 'consumption' }`, once the new mode is applied and stored; a pick of the level already active and the first application on load do not emit it. `consumption` requires a reload to fully apply, so the parent `<mds-pref>` shows its "reload required" notice for it in a visible panel.
- **Instances stay in sync**: Instances mounted together (a hidden `<mds-pref controller>` and a visible settings panel) share the applied consumption: a pick in one is mirrored by the others, which neither apply it again nor emit `mdsPrefChange`. A `pref-consumption-*` class written on `<html>` by other code is mirrored the same way.

#### Properties & Visual Configurations

- **`mode`**: The selected consumption preference (`low` / `medium` / `high`). Leave it unset to let the component restore the persisted value or fall back to `high`; set it explicitly only to force an initial mode.
- **`size`**: Sizes the nested tab items (`sm` / `md`). Inside `<mds-pref>`, set it on the parent instead: the parent's `size` reaches every `mds-pref-*` child on load and when it changes, and overwrites the child's own.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/ui-preferences-consumption--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` | `mode` | `"high" \| "low" \| "medium" \| undefined` | - | Specifies the preference mode |
| `size` | `size` | `"md" \| "sm" \| undefined` | - | Sets the size of the component items nested inside it |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsPrefChange` | `MdsPrefChangeEventDetail` | Emits when the component is triggered |

## Dependencies

Uses: `mds-text`, `mds-tab`, `mds-tab-item`.
