Skip to Content
Tokens

Native

Every theme as plain JS values for React Native and anything without CSS variables.

Usage

import { useColorScheme, View, Text } from "react-native"
import { nativeTheme } from "@dapplelight/signet-tokens/native"

export function InvoiceCard({ total }: { total: string }) {
  const t = nativeTheme("editorial", useColorScheme())
  return (
    <View style={{ backgroundColor: t.colors.card, borderRadius: t.radius.lg, padding: t.spacing * 4 }}>
      <Text style={{ color: t.colors.cardForeground, fontSize: t.fontSize.base }}>{total}</Text>
    </View>
  )
}

Colour names are the contract's in camelCase: --color-card-foreground is cardForeground. Colours are #rrggbb or rgba(r, g, b, a) strings; radius, spacing and font size are numbers.

API

ExportWhat it does
nativeTheme(name, scheme?)One theme in one mode: { colors, radius, spacing, fontSize }.
NATIVE_THEMESEvery theme with both modes: Record<ThemeName, NativeTokens>.
THEME_NAMESThe theme names, for a picker.
ThemeNameType: the theme names.
ModeType: "light" | "dark".
NativeColorsType: colour tokens by camelCase name.
NativeTokensType: { light, dark, radius, spacing, fontSize }.

nativeTheme(name, scheme?)

OptionTypeDefault
nameThemeNamerequiredThrows on an unknown name.
scheme"light" | "dark" | "unspecified" | nulllightPass useColorScheme() as is. Anything but "dark" is light.

Examples

Theme picker

import { THEME_NAMES, nativeTheme } from "@dapplelight/signet-tokens/native"

const swatches = THEME_NAMES.map((name) => ({
  name,
  primary: nativeTheme(name, "light").colors.primary,
}))

There is no useNativeTheme hook: it would pull react-native into this package. Wrap nativeTheme in your own.