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

# mds-button-dropdown

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

The `<mds-button-dropdown>` web component is a split-button control of the Magma Design System: it pairs a primary `<mds-button>` action with a secondary chevron button that opens an attached `<mds-dropdown>`, giving users a default action plus a menu of related choices in a single, visually unified control.

#### Semantic Behavior

- **Default slot is the menu**: Whatever you place in the default slot becomes the dropdown panel content; it is not treated as the button label (the visible label comes from the `label` prop).
- **Chevron trigger**: The second button is icon-only (chevron) and toggles the dropdown; it carries `aria-haspopup` and `aria-expanded` for the menu it opens. It is named in the page language (the `lang` of `<html>`) after the label ("More actions for Export", or "More actions" without a label), so two split buttons of one page name their chevrons apart; `dropdown-label` gives it a name of the page's instead.
- **Shared configuration**: `active`, `disabled`, `size`, `tone` and `variant` are forwarded identically to both internal buttons, so the two halves always stay visually and behaviorally in sync. `await` belongs to the primary action, the one in progress. `href`, `target` and `autoFocus` belong to the primary action alone: the chevron only opens the menu.
- **Current state**: `current` marks the primary action as the one that leads to the view you are in, as on `<mds-button>`. Both halves take the look of the current button; only the primary action is announced with `aria-current` and, with `current` (or `current="page"`), neither navigates, nor submits, nor fires `mdsButtonDropdownClick`. With `current="section"`, a view inside it, the primary action stays a link back. The chevron keeps opening the menu either way. A menu item that leads to the view you are in takes `current` itself.
- **Form association**: The host is form-associated. With `type="submit"` the primary action submits the enclosing `<form>` (or the one its `form` attribute names) and sends `name=value`, like a native submit button; with `type="reset"` it resets it. The chevron never submits. Unlike `<mds-button>`, `type` defaults to `'button'`: a dropdown in a form submits it only when asked. The menu items are slotted `<mds-button>`, so they follow their own `type` (default `'submit'`), `name` and `value`, and the receiver tells all the actions apart by `name`.
- **Disabled / await states**: `disabled` passes through to both buttons, so it disables the action and the trigger together; a disabled `<fieldset>` around the component disables both halves the same way, without setting `disabled`. `await` shows one spinner, on the primary action, which alone is announced as busy; the chevron keeps its arrow and is disabled until the component stops awaiting, so the menu does not open meanwhile.
- **Primary action event**: `mdsButtonDropdownClick` fires when the primary action is clicked or activated from the keyboard, and not while the component is `disabled` or awaiting. The chevron and the menu items do not fire it. A native `click` listener on the component also runs for the menu items, whose clicks bubble to it, so listen for `mdsButtonDropdownClick` to run the primary action in JavaScript.
- **Dropdown part**: The internal dropdown is exposed as the `dropdown` shadow part for external styling of the menu surface.
- **Corners**: The two halves take their outer corners from the host, the radius of `--mds-button-dropdown-radius`, and meet with flat inner corners. A row that joins the component flattens its corners on the host: in an `<mds-button-group>` the side that touches the next member is flat, on the primary action or on the chevron.
- **Width**: The component keeps its own width, its primary action as wide as an `<mds-button>` with the same label. A row that stretches it, as `actions/stacked` does under `--magma-container-actions` (380px) in `<mds-card-footer>`, `<mds-banner>`, `<mds-status-bar>` or a row of your own (`align-self: stretch`, a `width`, a `flex-basis`), gives the free width to the primary action, its label in the middle, and keeps the chevron at its own size at the end: the two halves still read as one button, with no fill past them.

#### Properties & Visual Configurations

The shared `variant` / `tone` / `size` ladders are defined in [`agents/variants.md`](../../../../agents/variants.md); they apply here as in `<mds-button>`, narrowed to `tone` `strong` / `weak` and without the `google` / `apple` variants, and are forwarded to both internal buttons. `variant` defaults to `'primary'`, `tone` defaults to `'strong'`, and `size` defaults to `'md'`.

- **`label`** sets the text of the primary action button only; the chevron trigger is icon-only.
- **`type`** (default `'button'`), **`name`** and **`value`** apply to the primary action only, as described under Form association. The menu items follow their own `type`: inside a `<form>`, give `type="button"` to the ones that must not submit it.
- **`href`** makes the primary action a link that navigates instead of submitting, with `target` choosing `'self'` vs `'blank'`; the chevron still opens the menu.

#### Other behavioral props

- **`autoFocus`** focuses the primary action once the component is loaded.
- **`icon`** is an SVG filename slug from the Magma icon library, applied to the primary action button (the chevron icon on the trigger is fixed and not configurable).
- **`iconCurrent`** and **`iconHover`** take the place of `icon` on the primary action, when it is current and under the pointer, as on `<mds-button>`: `iconHover` falls back on `iconCurrent`, and both need `icon`. The chevron keeps its arrow.
- **`truncate`** sets how the label of the primary action truncates, as on `mds-button` (default `'word'`).

## 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-button-dropdown--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 |
| --- | --- | --- | --- | --- |
| `active` | `active` | `boolean` | - | Specifies if the button is active or not |
| `autoFocus` | `auto-focus` | `boolean` | - | Focuses the primary action once the component is loaded |
| `await` | `await` | `boolean \| undefined` | - | Specifies if the button is awaiting for a response |
| `current` | `current` | `"page" \| "section" \| boolean \| undefined` | - | Marks the primary action as the one that leads to the view you are in, as `current` does on `mds-button`: `current` (or `current="page"`) is that view, and the primary action neither navigates nor submits nor emits `mdsButtonDropdownClick`; `current="section"` is a view inside it, and the primary action stays a link back. Both halves take the look; only the primary action is announced with `aria-current`, the chevron keeps opening the menu |
| `disabled` | `disabled` | `boolean \| undefined` | - | Specifies if the component is disabled or not |
| `dropdownLabel` | `dropdown-label` | `string \| undefined` | - | The accessible name of the chevron, the button that opens the menu, in place of the one the component builds in the language of the page: "More actions for" and `label`, or "More actions" without a label. Two split buttons of one page then name their chevrons apart |
| `href` | `href` | `string \| undefined` | - | The URL the primary action navigates to, instead of submitting; the chevron only opens the menu |
| `icon` | `icon` | `string \| undefined` | - | The icon displayed in the button; `iconCurrent` and `iconHover` take its place in their states |
| `iconCurrent` | `icon-current` | `string \| undefined` | - | The icon of the primary action when it is current, in place of `icon`, as `iconCurrent` does on `mds-button`: under the pointer too, unless `iconHover` says otherwise. Without `icon` it shows nothing |
| `iconHover` | `icon-hover` | `string \| undefined` | - | The icon of the primary action under the pointer, in place of `icon`, and `iconCurrent` when it is not set, as `iconHover` does on `mds-button`. Without `icon` it shows nothing |
| `label` | `label` | `string` | - | Specifies le text label of the component |
| `name` | `name` | `string \| undefined` | - | The name sent with `value` to the form the primary action submits, as a native submit button does |
| `size` | `size` | `"lg" \| "md" \| "sm" \| "xl"` | `'md'` | Specifies the size for the button |
| `target` | `target` | `"blank" \| "self"` | `'self'` | Where the primary action opens `href`, `'self'` or `'blank'` |
| `tone` | `tone` | `"strong" \| "weak" \| undefined` | `'strong'` | Specifies the tone variant for the button |
| `truncate` | `truncate` | `"all" \| "none" \| "word" \| undefined` | `'word'` | Specifies if the text shoud be truncated or should behave as a normal text |
| `type` | `type` | `"a" \| "button" \| "reset" \| "submit" \| undefined` | `'button'` | The type of the primary action: with `'submit'` or `'reset'` it submits or resets the form the component is in, the chevron never does. Unlike `mds-button` it defaults to `'button'` |
| `value` | `value` | `string \| undefined` | - | The value sent under `name` to the form the primary action submits |
| `variant` | `variant` | `"ai" \| "dark" \| "error" \| "info" \| "light" \| "primary" \| "secondary" \| "success" \| "warning" \| undefined` | `'primary'` | Specifies the color variant for the button |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsButtonDropdownClick` | `void` | Emits when the primary action is clicked or activated from the keyboard, unless the component is disabled or awaiting. The chevron and the menu items do not emit it, while a native `click` on the component also comes from the menu items |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |

## Parts

| Part | Description |
| --- | --- |
| `dropdown` | The `mds-dropdown` that the arrow opens, with the default slot inside |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-button-dropdown-radius` | Sets the border-radius of the component |

## Dependencies

Uses: `mds-button`, `mds-dropdown`.
