Skip to main content

Create a Theme

Define the tokens you want to change, generate a theme object, and pass it to VortexProvider. Complete Quick Start first to install the packages. To change only part of a screen, use Scoped Theming.

Define your theme

Add acme to vortex-native.config.ts at your project root. This example changes primary text colors, button corners, and native accessibility settings:

vortex-native.config.ts
import type { VortexNativeThemeConfig } from "@vortexlabs/vortex-themes";

const config: VortexNativeThemeConfig = {
  themes: {
    acme: {
      semanticTokens: {
        color: {
          foregroundPrimaryDefault: {
            light: "brandPrimary700",
            dark: "brandPrimary300",
          },
        },
      },
      componentTokens: {
        borderRadius: {
          button: { borderRadius: "lg" },
        },
      },
      native: {
        touchTarget: 44,
        maxFontSizeMultiplier: 1.5,
      },
    },
  },
};

export default config;

Omitted tokens use Vortex's defaults. Each token you define replaces that entire token object, so include all its required fields. For example, a semantic color needs both modes, and a typography token needs all five typography fields.

native sets the minimum press area (touchTarget) and the cap on system text scaling (maxFontSizeMultiplier). The defaults are 44 and 2.

Generate the theme

Add a script to your existing package.json:

package.json
"scripts": {
  "build:theme": "vortex-themes theming --platform native --output ./src/themes"
}
bun run build:theme

The CLI reads vortex-native.config.ts and creates src/themes/acme/theme.native.ts. Use --config for another path. Without a config, it generates the bundled themes.

Run it again after changing your config or upgrading Vortex packages. Edit the config, not the generated files.

Apply your theme

Pass the generated object to your provider:

App.tsx
import { VortexProvider } from "@vortexlabs/vortex-native";
import acmeTheme from "./src/themes/acme/theme.native";

<VortexProvider theme={acmeTheme} defaultColorMode="system">
  {children}
</VortexProvider>

To skip generation, import a bundled theme instead: vortex, awen, or sleek, such as @vortexlabs/vortex-themes/themes/vortex/native.

Font files are supplied separately; follow the Fonts guide.

Change colors

Semantic colors reference global colors through light and dark, as in the example above. Changing a global color affects every role that references it. To change one component state, edit its semantic role, such as backgroundButtonPrimaryDefault.

Web uses *Hover colors; native uses *Pressed colors. When sharing a config with web, set both: native generation fails if you override a hover color without its pressed color.

A semantic color can also reference a global color with opacity:

backgroundPrimarySubtlest: {
  light: { color: "brandPrimary600", opacity: 0.1 },
  dark: { color: "brandPrimary400", opacity: 0.2 },
},

Opacity is a number from 0 to 1. Use an opaque global color; do not combine both sources of transparency. The same rule applies to shadow opacity.

Use the color reference for token names, and Color Modes to switch between light and dark.

Generated values

The theme object holds values that React Native styles accept directly:

TokensNative output
ColorsHex or rgba(); semantic colors are grouped under color.light and color.dark.
Space, size, border width, radiusNumbers in points.
TypographyText styles from the mobile recipes, such as typography.bodyMdRegular.
ShadowsboxShadow strings.
DurationMilliseconds, such as duration[200].
EasingControl points for Easing.bezier(...theme.easing.easeOut).

Native output has no CSS breakpoints or desktop typography.