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

# mds-input-switch

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

The `<mds-input-switch>` web component is the binary/selectable input control of the Magma Design System. A single tag covers three native primitives - it renders as a toggle switch by default and re-renders as a native `checkbox` or `radio` depending on `type`, wrapping `<input type="checkbox|radio">` with form association, accessibility, and iconography handled natively.

#### Semantic Behavior

- **Type-driven rendering**: `type` selects the visual primitive. `'switch'` (default) renders the sliding toggle, whose knob slides only when `checked` changes (by the user or by code) and is already in place on load or when shown again after being hidden; `'checkbox'` and `'radio'` render the corresponding native control.
- **Form association**: The host participates in a `<form>` natively - the form value is `value` while `checked` and enabled, nothing otherwise, and it follows every change of `checked`, `value` or `disabled`, by the user or by code. A form reset brings back the `checked` state of load, like a native input.
- **Radio grouping**: When `type="radio"`, checking one instance, by the user or by code, unchecks the other radios with the same `name` in the same form (or, outside a form, in the same document or shadow root), as native radios do, so the group submits one value. A radio without a `name` is a group of its own.
- **Checked / indeterminate**: `checked` reflects selection; toggling it always clears `indeterminate`. The indeterminate glyph is only meaningful for `checkbox`.
- **Disabled state**: Blocks interaction and clears the submitted form value while disabled. A disabled `<fieldset>` around the component does the same, as it does a native input.
- **Keyboard operable**: The control responds to keyboard activation in addition to pointer clicks.
- **Accessibility**: The control exposes a localized accessible label ("select"/"unselect") derived from slotted text (it/en/es/el).
- **Change event**: `mdsInputSwitchChange` fires with `{ name, checked, value }` whenever the user changes the selection; setting `checked` from code does not emit it.
- **Default slot**: The default slot is the visible text label rendered beside the control; when empty, the label region collapses.

#### Properties & Visual Configurations

- **`type`** is the primary configuration: pick `'switch'` for on/off settings, `'checkbox'` for multi-select selections, `'radio'` for mutually exclusive choices within a `name` group.
- **`explicit`** applies only to `type="switch"`: it surfaces a check/remove glyph inside the toggle knob so the on/off state is readable without relying on color alone.
- **`size`** (`'sm'` / `'md'` / `'lg'`) scales the toggle and is honored only when `type="switch"`.
- **`icon`** overrides the default checked glyph (checkbox/radio variants); leave empty to use the type's built-in icon set.

#### Other behavioral props

- **`typography`** and **`variant`** style the slotted text label; they map to the shared typography ladders rather than the system tone/variant ladder defined in [`agents/variants.md`](../../../../agents/variants.md).

## 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/form-switch--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 |
| --- | --- | --- | --- | --- |
| `autofocus` | `autofocus` | `boolean` | - | Sets or returns whether a checkbox should automatically get focus when the page loads |
| `checked` | `checked` | `boolean \| undefined` | - | Specifies that an `<input>` element should be pre-selected when the page loads (for `type="checkbox"` or `type="radio"`) |
| `disabled` | `disabled` | `boolean \| undefined` | - | Sets or returns whether a checkbox is disabled, or not |
| `explicit` | `explicit` | `boolean \| undefined` | - | Sets if the type switch mode shows explicit icons |
| `icon` | `icon` | `string` | `''` | The checked icon displayed |
| `indeterminate` | `indeterminate` | `boolean \| undefined` | - | Sets or returns the indeterminate state of the checkbox |
| `name` | `name` | `string` | `''` | Specifies the name of an `<input>` element |
| `size` | `size` | `"lg" \| "md" \| "sm"` | `'md'` | Specifies the size for the switch toggle, it works only if attribute 'type' is set to 'switch' |
| `type` | `type` | `"checkbox" \| "radio" \| "switch"` | `'switch'` | Specifies switch type: switch (default), checkbox and radio |
| `typography` | `typography` | `"caption" \| "detail" \| "label" \| "option" \| "paragraph" \| "tip" \| undefined` | `'detail'` | Specifies the font typography of the element |
| `value` | `value` | `string \| undefined` | `''` | Specifies the value of the input element |
| `variant` | `variant` | `"code" \| "info" \| "read" \| "title" \| undefined` | - | Specifies the variant for `typography` |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsInputSwitchChange` | `MdsInputSwitchEventDetail` | Emits when the value changes |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Put text string or elements here |

## CSS custom properties

None is public: its 27 custom properties are internal and may change in any release. Style it with its props, its parts and the semantic roles.

## Dependencies

Uses: `mds-icon`, `mds-text`.
Used by: `mds-table-header`, `mds-table-row`.
