> Markdown version of [Styling](https://vaadin.com/docs/next/components/switch/styling). Section index: [llms.txt](https://vaadin.com/docs/next/components/llms.txt)

# Switch Styling

## <a id="style-variants"></a>Style Variants

The following style variants can be applied:

| Variant   | Description                                                                                              | Supported by |
| --------- | -------------------------------------------------------------------------------------------------------- | ------------ |
| `icon`    | Shows a checkmark inside the marker when on, and a cross when off, for a stronger at-a-glance affordance | Aura, Lumo   |
| `small`   | Renders a more compact switch                                                                            | Aura         |
| `reverse` | Places the label before the switch, reversing their order                                                | Aura         |

## <a id="style-properties"></a>Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the `html {…​}` selector. See [Component Style Properties](https://vaadin.com/docs/next/styling/styling-components.md#component-style-properties) for more information on style properties.

> **Note: Input Field Components Shared Styles**
>
> Style properties whose names start with `--vaadin-input-field` are shared among all input field components. To apply them only to a specific type of component, use an element selector like `vaadin-text-field {…​}`

### <a id="switch-properties"></a>Switch Properties

| Property                               | Supported by |
| -------------------------------------- | ------------ |
| `--vaadin-switch-background`           | Aura, Lumo   |
| `--vaadin-switch-border-color`         | Aura, Lumo   |
| `--vaadin-switch-border-radius`        | Aura, Lumo   |
| `--vaadin-switch-border-width`         | Aura, Lumo   |
| `--vaadin-switch-gap`                  | Aura, Lumo   |
| `--vaadin-switch-height`               | Aura, Lumo   |
| `--vaadin-switch-width`                | Aura, Lumo   |
| `--vaadin-switch-icon-color`           | Aura, Lumo   |
| `--vaadin-switch-icon-size`            | Aura, Lumo   |
| `--vaadin-switch-label-color`          | Lumo         |
| `--vaadin-switch-label-font-size`      | Lumo         |
| `--vaadin-switch-label-font-weight`    | Lumo         |
| `--vaadin-switch-label-line-height`    | Lumo         |
| `--vaadin-switch-marker-border-color`  | Aura, Lumo   |
| `--vaadin-switch-marker-border-radius` | Aura, Lumo   |
| `--vaadin-switch-marker-border-width`  | Aura, Lumo   |
| `--vaadin-switch-marker-color`         | Aura, Lumo   |
| `--vaadin-switch-marker-height`        | Aura, Lumo   |
| `--vaadin-switch-marker-scale`         | Aura, Lumo   |
| `--vaadin-switch-marker-width`         | Aura, Lumo   |

### <a id="label"></a>Label

| Property                                        | Supported by |
| ----------------------------------------------- | ------------ |
| `--vaadin-input-field-focused-label-color`      | Lumo         |
| `--vaadin-input-field-hovered-label-color`      | Lumo         |
| `--vaadin-input-field-label-color`              | Aura, Lumo   |
| `--vaadin-input-field-label-font-size`          | Aura, Lumo   |
| `--vaadin-input-field-label-font-weight`        | Aura, Lumo   |
| `--vaadin-input-field-label-line-height`        | Aura, Lumo   |
| `--vaadin-input-field-required-indicator-color` | Aura, Lumo   |
| `--vaadin-input-field-required-indicator`       | Aura, Lumo   |

### <a id="helper"></a>Helper

| Property                                  | Supported by |
| ----------------------------------------- | ------------ |
| `--vaadin-input-field-helper-color`       | Aura, Lumo   |
| `--vaadin-input-field-helper-font-size`   | Aura, Lumo   |
| `--vaadin-input-field-helper-font-weight` | Aura, Lumo   |
| `--vaadin-input-field-helper-line-height` | Aura, Lumo   |
| `--vaadin-input-field-helper-spacing`     | Lumo         |

### <a id="error-message"></a>Error Message

| Property                                 | Supported by |
| ---------------------------------------- | ------------ |
| `--vaadin-input-field-error-color`       | Aura, Lumo   |
| `--vaadin-input-field-error-font-size`   | Aura, Lumo   |
| `--vaadin-input-field-error-font-weight` | Aura, Lumo   |
| `--vaadin-input-field-error-line-height` | Aura, Lumo   |

## <a id="css-selectors"></a>CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the [Styling documentation](https://vaadin.com/docs/next/styling.md) for more details on how to style components.

> **Important: Not for Shadow DOM**
>
> These selectors should be used in `styles.css` or another stylesheet loaded with the `@StyleSheet` annotation or the `@import` CSS rule. **They do not work in the shadow DOM of Vaadin components**, such as in stylesheets in the `components` sub-folder or loaded with the `@CssImport` annotation’s `themeFor` property.

---

### <a id="switch"></a>Switch

- Root element

  `vaadin-switch`

- Focused

  `vaadin-switch[focused]`

- Keyboard focused

  `vaadin-switch[focus-ring]`

- Disabled

  `vaadin-switch[disabled]`

- Read-only

  `vaadin-switch[readonly]`

- Pressed

  `vaadin-switch[active]`

- Checked (on)

  `vaadin-switch[checked]`

- With tooltip

  `vaadin-switch[has-tooltip]`

- Track

  `vaadin-switch::part(switch)`

- Marker

  `vaadin-switch::part(marker)`

- Label

  `vaadin-switch::part(label)`

#### <a id="label-2"></a>Label

- Switch with label

  `vaadin-switch[has-label]`

- Label

  `vaadin-switch::part(label)`

- Label text

  `vaadin-switch > label`

- Required switch

  `vaadin-switch[required]`

- Required indicator

  `vaadin-switch::part(required-indicator)`

#### <a id="helper-and-validation-error"></a>Helper and Validation Error

- Field with helper

  `vaadin-switch[has-helper]`

- Helper

  `vaadin-switch::part(helper-text)`

- Helper text

  `vaadin-switch > [slot="helper"]`

- Invalid field

  `vaadin-switch[invalid]`

- Field with error message

  `vaadin-switch[has-error-message]`

- Error message

  `vaadin-switch::part(error-message)`

- Error message text

  `vaadin-switch > [slot="error-message"]`
