Documentation comes from this release commit, without inheriting newer content. Commit: cc3dd17e61.
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
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
Using styles in a component
Variants
Use variants for prop-driven styling — variants compose into runtime styles without rerenders.
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:
Adding a new gradient:
-
Add the entry under the same key in both
lightGradientsanddarkGradientsingradients.ts. Thesatisfies Record<keyof typeof lightGradients, LinearGradientToken>annotation ondarkGradientsenforces key parity at compile time. -
Pick light/dark color stops independently — gradients flip with the active theme just like
theme.colors.*. -
Reference it from a component:
Button fills accept the same token shape via
gradientFillon<PrimaryButton>and<PremiumButton>. When set,gradientFilloverrides the variant's preset sweep (variant chrome — border, shadow, radius — is unchanged):Or read the raw token from a stylesheet for a custom Skia surface:
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
If you want OS-driven theming, replace initialTheme: 'dark' in StyleSheet.configure with adaptiveThemes: true and let Unistyles follow the system appearance.
Breakpoints
Registered with Unistyles:
Phone vs iPad is never a width breakpoint. Size for the device class with IS_TABLET
(@core/device/is-tablet) and scaleTypeForTablet (@core/device/tablet-type-scale):
A width breakpoint cannot tell the two apart: a landscape phone is 568–956 pt wide (md), a
portrait iPad mini 744 pt. The app is requireFullScreen, so an iPad window never shrinks and the
device check always matches the screen. It also reads in module constants and gameplay math, where
a reactive breakpoint cannot.
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
Common pitfalls
- Never hardcode a hex value. Add it to the theme first.
- Never hardcode
fontFamilystrings ('Nunito_400Regular','System', …). Usetheme.fonts.primary.*/theme.fonts.secondary.*fromsrc/core/theme/fonts.ts(see.cursor/rules/typography-fonts.mdc). - Don't import
StyleSheetfromreact-native— always fromreact-native-unistylesso themes apply. useVariantsrequires the component to actually render. If you build a variant table but never calluseVariants, the variant branch is dead code.- Babel root. If a new top-level folder is added (e.g.
packages/ui), update babel.config.jsautoProcessPathsso its styles get themed.