Content
- The row's label is “Appearance”. The options are Light, Dark and System.
The Appearance setting: Light, Dark or System, for every Bridge app.
import { … } from "@brdgapp/ui/components/theme-switch"ThemeSwitch is the Appearance setting: Light, Dark or System. It saves the choice for every Bridge app and applies it at once, with no fade. It's built on SegmentedControl and the package's theme (useTheme and themeScript). The usual mistake is putting a theme button in an app's top bar: it belongs in Settings.
The look comes from props
A component's appearance comes only from its own options (variant, size, color). className on a package component is for layout (mt-4, shrink-0, w-full), never for font size, color, padding, radius or hover. If the look needs a className, the component or the chosen option is wrong: fix that instead.
Options. Light (sun), Dark (moon), System (screen), each with its word.
Selected. The current choice, raised on a white chip.
The Appearance row. Try it: this whole site changes, and so would every Bridge app.
Appearance
Applies in every Bridge app.
| State | What happens |
|---|---|
| Before the page loads | Shows System until the saved choice is read, a moment later. |
| System | Follows the device, and changes when the device does. |
themeScript in the app's root layout.Do
Put it in Settings → Appearance with a label.Don't
Add a sun-and-moon button to the top bar.| Keys | Action |
|---|---|
| Tab | Moves to the selected option. |
| ←→ | Moves between options. |
| EnterSpace | Picks the option. |
ThemeSwitch
The Appearance setting.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Layout only. |
useTheme
From @brdgapp/ui/hooks/use-theme: the choice, what's drawn, and a setter.
| Prop | Type | Default | Description |
|---|---|---|---|
theme | "light" | "dark" | "system" | — | The choice. |
resolvedTheme | "light" | "dark" | — | What's drawn now. |
setTheme | (theme) => void | — | Saves the choice for every Bridge app and applies it. |
What it's built from and where it's used, read from the code. When you change it, check these too.