v1.0.10 · Release snapshot

Documentation comes from this release commit, without inheriting newer content. Commit: 63ea8c2b3d.

Styling & theming

The app uses react-native-unistyles v3 for styles. Tokens (colors, spacing, fonts, breakpoints) live under src/core/theme/. The root unistyles.ts is the orchestration file that pulls those tokens in and calls StyleSheet.configure.

File layout

unistyles.ts                  # root entry: imports tokens, calls StyleSheet.configure
src/core/theme/
  index.ts                    # barrel + UnistylesThemes/UnistylesBreakpoints module augmentation
  colors.ts                   # light + dark color palettes
  gradients.ts                # named linear gradients (light + dark) consumed by <TextOutline>
  spacing.ts                  # spacing token map + radius scale
  fonts.ts                    # font assets, sizes, weights, line heights
  breakpoints.ts              # xs / sm / md / lg
  themes.ts                   # composes colors + gradients + spacing + radii into light/dark themes

The split is intentional: tokens are values (live in src/core/theme/), and registration is a side effect (lives at root).

Setup chain

index.ts imports ./unistyles before expo-router/entry, so themes are registered before any screen mounts.

Theme shape

// src/core/theme/themes.ts
import { darkColors, lightColors } from '@core/theme/colors';
import { radius, spacing } from '@core/theme/spacing';

export const darkTheme = {
  colors: darkColors,
  spacing,
  radius,
};
TokenPurposeLives in
colorsAll chrome + semantic tokens. Never use hardcoded hex inline.src/core/theme/colors.ts
gradientsNamed linear gradients (type, colors, stops, direction) consumed by <TextOutline>.src/core/theme/gradients.ts
spacingToken map: none / xs(4) / sm(8) / md(12) / lg(16) / xl(24) / xxl(32) / xxxl(48) / huge(64).src/core/theme/spacing.ts
radiusBorder radius scale (sm, md, lg, full).src/core/theme/spacing.ts
fontsFont assets, weights, sizes, line heights — consumed by <Text> and expo-font.src/core/theme/fonts.ts
breakpointsResponsive bucket sizes.src/core/theme/breakpoints.ts

Using styles in a component

import { StyleSheet } from 'react-native-unistyles';

export const Card = () => <View style={styles.card} />;

const styles = StyleSheet.create((theme) => ({
  card: {
    backgroundColor: theme.colors.surface,
    padding: theme.spacing.lg,
    borderRadius: theme.radius.md,
    borderWidth: 1,
    borderColor: theme.colors.border,
  },
}));

Variants

Use variants for prop-driven styling — variants compose into runtime styles without rerenders.

// src/components/PrimaryButton.tsx
export const PrimaryButton = ({ variant = 'primary', disabled }) => {
  styles.useVariants({ variant, disabled });
  return <Pressable style={styles.button}>...</Pressable>;
};

const styles = StyleSheet.create((theme) => ({
  button: {
    height: 48,
    borderRadius: theme.radius.md,
    variants: {
      variant: {
        primary: { backgroundColor: theme.colors.primary },
        secondary: { backgroundColor: theme.colors.accent },
        ghost: {
          backgroundColor: theme.colors.transparent,
          borderWidth: 1,
          borderColor: theme.colors.border,
        },
      },
      disabled: {
        true: { opacity: 0.5 },
        false: { opacity: 1 },
      },
    },
  },
}));

Gradients

Linear gradients are first-class theme tokens — defined once in src/core/theme/gradients.ts and accessed as theme.gradients.<name> from any StyleSheet.create((theme) => ...) block, or applied to text via the <TextOutline gradient="..."> component.

Each gradient is a LinearGradientToken:

{
  type: "linear",
  colors: ["#FFE07A", "#FFC93D"],     // 2+ raw hex / rgba stops
  stops?: [0, 1],                      // optional 0..1 positions, omit for even spacing
  direction?: "vertical",              // "horizontal" | "vertical" | "diagonal-tl-br" | "diagonal-tr-bl" | { angle: 0 }
}

Adding a new gradient:

  1. Add the entry under the same key in both lightGradients and darkGradients in gradients.ts. The satisfies Record<keyof typeof lightGradients, LinearGradientToken> annotation on darkGradients enforces key parity at compile time.

  2. Pick light/dark color stops independently — gradients flip with the active theme just like theme.colors.*.

  3. Reference it from a component:

    // Theme token
    <TextOutline variant="display" gradient="heroTitle">
      LEVEL UP
    </TextOutline>
    
    // Inline token — custom colors, stops, and direction without adding a theme key
    <TextOutline
      variant="title"
      weight="bold"
      gradient={{
        type: "linear",
        colors: ["#C084FC", "#53C9FF", "#A4EFFF"],
        stops: [0.265, 0.5, 0.735],
        direction: { angle: 73 },
      }}
    >
      Accent word
    </TextOutline>
    
    // Two-color shorthand — `startColor` / `endColor` with optional stops + direction
    <TextOutline
      variant="title"
      weight="bold"
      gradient={{ startColor: "#C084FC", endColor: "#53C9FF", direction: "horizontal" }}
    >
      Accent word
    </TextOutline>

    Button fills accept the same token shape via gradientFill on <PrimaryButton> and <PremiumButton>. When set, gradientFill overrides the variant's preset sweep (variant chrome — border, shadow, radius — is unchanged):

    <PrimaryButton
      label="Get"
      variant="gradientBrand"
      gradientFill={{
        type: "linear",
        colors: [theme.colors.buttonBrandGlow, theme.colors.buttonBrandBase],
        stops: [0.2, 0.8],
        direction: "diagonal-tl-br",
      }}
      onPress={onPress}
    />

    Or read the raw token from a stylesheet for a custom Skia surface:

    const styles = StyleSheet.create((theme) => ({
      hero: { ...theme.gradients.heroTitle }, // pseudo — pass to a Skia <LinearGradient>
    }));

TextOutline renders gradient text with expo-linear-gradient + @react-native-masked-view/masked-view (no Skia canvas). Outline and drop-shadow are layered RN <Text> duplicates behind the fill.

GradientPill also accepts an optional locations prop (0..1 stop positions) when used directly for low-level expo-linear-gradient fills.

The angle convention for { angle: number } is screen-space: 0° runs top → bottom, 90° runs left → right, 180° runs bottom → top, 270° runs right → left. Negative or out-of-range angles are normalized into [0, 360).

Theme switching at runtime

import { UnistylesRuntime } from 'react-native-unistyles';

UnistylesRuntime.setTheme('light'); // or 'dark'

If you want OS-driven theming, replace initialTheme: 'dark' in StyleSheet.configure with adaptiveThemes: true and let Unistyles follow the system appearance.

Breakpoints

Defined for both phones and small tablets:

const breakpoints = { xs: 0, sm: 360, md: 768, lg: 1024 };

Use them with the { xs: ..., md: ... } style syntax inside a stylesheet to scale layouts:

const styles = StyleSheet.create((theme, _rt) => ({
  container: {
    paddingHorizontal: { xs: theme.spacing.lg, md: theme.spacing.xxxl },
  },
}));

A stylesheet with breakpoint- or orientation-keyed values takes the runtime — (theme, _rt), even when it never reads it. Every stylesheet is created when the app starts, and on a width change Unistyles 3 re-parses a (theme)-only sheet only for the views on screen at that moment. An iPad that starts upright parses the sheets at md; when the app then turns landscape, a screen first opened later (the song result) keeps its xs/md values for the whole session. A (theme, rt) sheet is refreshed on every runtime change, mounted or not. src/core/theme/__tests__/breakpoint-stylesheets.test.ts fails on a (theme)-only sheet that holds such a value.

Where to put style code

ScopeLocation
Shared, app-widesrc/components/* (e.g. Screen, PrimaryButton)
Feature-localsrc/features/<x>/components/*
One-off inside a screenCo-located StyleSheet.create at the bottom of the screen
Color tokenssrc/core/theme/colors.ts
Spacing / radiussrc/core/theme/spacing.ts
Fontssrc/core/theme/fonts.ts
Breakpointssrc/core/theme/breakpoints.ts
Theme compositionsrc/core/theme/themes.ts
Registration onlyunistyles.ts (root)

Common pitfalls

  • Never hardcode a hex value. Add it to the theme first.
  • Never hardcode fontFamily strings ('Nunito_400Regular', 'System', …). Use theme.fonts.primary.* / theme.fonts.secondary.* from src/core/theme/fonts.ts (see .cursor/rules/typography-fonts.mdc).
  • Don't import StyleSheet from react-native — always from react-native-unistyles so themes apply.
  • useVariants requires the component to actually render. If you build a variant table but never call useVariants, the variant branch is dead code.
  • Babel root. If a new top-level folder is added (e.g. packages/ui), update babel.config.js autoProcessPaths so its styles get themed.