Switch Styling
Style Variants
The following style variants can be applied:
| Variant | Description | Supported by |
|---|---|---|
| Shows a checkmark inside the marker when on, and a cross when off, for a stronger at-a-glance affordance | Aura, Lumo |
| Renders a more compact switch | Aura |
| Places the label before the switch, reversing their order | Aura |
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 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 {…}
|
Switch Properties
| Property | Supported by |
|---|---|
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Lumo |
| Lumo |
| Lumo |
| Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
Label
| Property | Supported by |
|---|---|
| Lumo |
| Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
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 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.
|
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] - Track
-
vaadin-switch::part(switch) - Marker
-
vaadin-switch::part(marker) - Label
-
vaadin-switch::part(label)
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)
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"]