ThemeProvider
Theme persistence for the whole app, and the reason a reload never flashes the wrong one.
useTheme
This docs site itself runs on this provider — the toggle in the sidebar is `toggleTheme`.
theme: light
resolvedTheme: light
Usage
import { ThemeProvider, ThemeScript, useTheme } from '@oceanic-hub/brand-system'Render <ThemeScript /> in <head> and wrap the app in <ThemeProvider>. The
script applies the stored or OS theme before first paint, which is the only way to avoid a
flash of the wrong theme; the provider persists changes to localStorage.
shadcn ships no provider of its own: its docs point at next-themes, a Next.js-only package,
and document it as a recipe rather than a component. This one is framework-agnostic instead —
no dependency on Next's app router, or any router at all — which is what lets the same
<ThemeProvider> sit under this showcase, a plain Vite app, or anything else the brand
ships to.
'system' is a choice a caller can ask for, not just a fallback sampled once: while it is
selected, the provider holds a matchMedia listener, so an OS flip lands live with no reload.
theme is what a settings screen ticks; resolvedTheme is what a surface should actually
read to pick an asset or a chart palette — two fields because collapsing them would leave a
settings screen unable to show "system, currently dark" as a state distinct from "dark".
This documentation site runs on it — the toggle in the sidebar is useTheme().toggleTheme,
and every preview on every page inherits that one decision.
Following the OS
'system' is a choice, not a fallback: theme stays 'system' and resolvedTheme tracks the OS live.
theme: light → resolvedTheme: light
The active button reads theme — the choice. A settings screen ticks that. Anything asking what it is looking at reads resolvedTheme.
API Reference
See the ThemeProvider API page for every prop of every part, with types, defaults and the contract that pins them. It also documents useTheme — exported alongside the parts, and signatures rather than props.