Usage
Theme Select lets users choose the application color theme: light, dark, or following the operating system preference. Use it in settings screens, profile pages, or anywhere a theme preference belongs. It is a controlled component: it only reports the chosen theme through v-model and does not apply or persist the theme itself, which keeps the host application in charge of how the choice takes effect.
import { MtThemeSelect } from "@shopware-ag/meteor-component-library";
Examples
Pairing with useTheme
The useTheme composable resolves the system option against prefers-color-scheme, applies the resolved value as data-theme, and persists the choice. Binding its theme ref to the select is all a typical app needs.
API reference
Props
| Prop | Type | Default |
|---|---|---|
labelThe label for the select field itself. | string | |
disabledDisables the select field. | boolean | |
model-value | any | "system" |
Events
| Event | Payload |
|---|---|
update:modelValue | [value: Theme] |
Best practices
Do
- Default to
systemso the application respects the operating system preference. - Pair the select with useTheme so the choice is applied and persisted consistently.
- Give the field a label that describes the setting, such as
Color themeorAppearance.
Don't
- Do not use Theme Select for unrelated multi-option settings; it is purpose-built for color themes.
- Do not apply the theme from multiple places at once. Keep one owner for the
data-themeattribute.
Behavior
- Theme Select accepts and emits one of three values through
modelValue:"light","dark", or"system", and defaults to"system". - The component is purely presentational. Resolving
system, writingdata-theme, and persisting the choice is the host's responsibility, which useTheme handles out of the box. - Option labels are localized (English and German) through the library's i18n setup.
- Additional Select props such as
smallorerrorfall through to the underlying select.
Accessibility
- Keyboard and screen reader behavior follow the underlying Select component.
- Each option is labelled with text; the sun, moon, and desktop icons are decorative (
aria-hidden), so the choice never relies on iconography alone. - Provide a visible
labelso the setting is announced with its purpose.