Skip to content
UI

Theming

Most apps only need to edit the shared tokens. Use xstyle for one-off changes. Add the theme runtime only when users need to switch between light, dark, and system modes.

How theming works

Yopem components read semantic values such as primary, background, foreground, font, and radius from src/styles/tokens.stylex.ts. Change that file once to update every component.

Change the whole app

Complete Installation first. Then open the copied token file and replace the values you want. Keep all other existing values.

Change background and foreground pairs together so text remains readable. Font tokens select a font family but do not download its files. Run a production build after editing tokens.

Component overrides

Use xstyle when one component should look different. Yopem applies it after default styles and variants.

Use stylex.props for native HTML elements. Use xstyle for Yopem components. Preserve focus, hover, and disabled styles when overriding those states.

Add dark mode

Skip this section if your app has one fixed theme. A static light or dark theme needs no provider and no client script.

For user-selectable light, dark, and system modes, copy these two files:

src/theme/theme.tsx
src/theme/theme-provider.tsx

Add the script before hydration and wrap your app with the provider. This example keeps TanStack Start head and script components in place. Adapt only those framework-specific imports for another SSR framework.

Add any control that calls useTheme. Use your existing Select or Segmented Control component in a real interface.

ThemeScript and ThemeProvider must use matching defaults. If your Content Security Policy blocks inline scripts, pass the same per-request nonce allowed by your CSP to ThemeScript.