block
A pre-built block for switching between light, dark, and system theme modes. Renders a button that opens a Menu whose radio group holds the three options — System, Dark, and Light — and persists the selection to localStorage. The button icon updates automatically to reflect the active mode.
Because it’s a menu radio group, the options come with roving focus, typeahead, a keyboard-only focus ring, and a check mark on the active mode for free — and picking one doesn’t dismiss the panel, so modes can be previewed in place.
---
import ThemeModeSelect from "../theme-mode-select.astro";
import { flex } from "@pindoba/styled-system/patterns";
---
<div
class={flex({
justify: "center",
})}
>
<ThemeModeSelect id="demo-theme-mode-select" />
</div>Props forwarded to the trigger `<Button>`.
Root element id. Also seeds the menu, trigger, and option ids. Defaults to a generated value.
Props forwarded to the internal `<Menu>` (e.g. `size`). `passThrough` is owned by the block — use this component's own `passThrough.trigger` / `passThrough.menuPanel` instead of nesting one here.
Per-slot escape hatch. `root` accepts `style` (merged into the slot class) and `props`; `trigger` and `menuPanel` forward onto the Menu's own `passThrough.trigger` / `passThrough.popoverPanel`.
"bottom-end"Placement of the menu panel relative to its trigger.
Props forwarded to the trigger `<Button>` (e.g. `size`, `emphasis`).