On this page
Theming
For most apps, changes to shared tokens are enough. Use xstyle to change styles for individual components. Add the theme runtime only if users need to switch between light, dark, and system modes.
How theming works
Yopem components read semantic values from src/styles/tokens.stylex.ts. These
values include primary, background, foreground, font, and radius. Change that
file to update every component.
Change the whole app
Complete Installation first. Open the copied token file. Replace the required values. Keep all other existing values.
Keep primary actions neutral. Use --accent for neutral hover surfaces. Use the
--accent-solid pair for selected indicators. Use --ring for focus. Keep
existing token names when you change their values.
Use --control-background for fields and --overlay-backdrop for backdrops.
Use --overlay-shell for dialog frames and the card pair for inset content and
footers. Use the popover pair for floating menus and tooltips.
Change background and foreground pairs together to keep text readable. This includes primary, secondary, muted, accent, card, and popover pairs. Use the success, warning, destructive, and info tokens for status.
Use --radius for standard surfaces and --radius-sm for compact details.
Other radius tokens are explicit overrides. Keep functional circles intact. Font
tokens select a font family. They do not download font files. Load Geist Sans
and Geist Mono or configure other font tokens. Run a production build after you
edit tokens.
Component overrides
Use xstyle to change the appearance of one component. Yopem applies it after
default styles and variants.
Use stylex.props for native HTML elements. Use xstyle for Yopem components.
Keep focus, hover, and disabled styles when you override those states.
Add dark mode
If your app has one fixed theme, do not add theme switching. A static light or dark theme does not need a provider or client script.
To let users select light, dark, and system modes, copy these two files:
src/theme/theme.tsxsrc/theme/theme-provider.tsxThese examples use manual-copy paths. Fresh CLI init uses a themes directory.
For CLI installations, use the theme path from ui.json in these imports.
Add the script before hydration. Wrap your app with the provider. This example keeps the TanStack Start head and script components. For another SSR framework, change only those framework-specific imports.
Add the Theme Switcher registry item. Put
ThemeSwitcher inside ThemeProvider to let users select Light, Dark, or
System. Use ThemeToggle for an icon button that changes between light and
dark.
Use useTheme from your theme provider to build a custom control.
ThemeScript must run before the first paint. It uses data-cfasync="false" to
prevent Cloudflare Rocket Loader from deferring theme selection.
ThemeScript and ThemeProvider must use the same defaults. If your Content Security Policy blocks inline scripts, pass its permitted per-request nonce to ThemeScript.