Use recipes and state variants
Use styleVariants for simple state maps
Section titled “Use styleVariants for simple state maps”export const button = styleVariants({ default: { opacity: 1 }, pressed: { opacity: 0.8 },})This is a good fit when the state model is small and you only need named branches.
Use recipe for reusable component surfaces
Section titled “Use recipe for reusable component surfaces”Use recipe when you need:
- defaults
- multiple variant groups
- compound variants
- one reusable component-facing surface
Resolve recipes in component code
Section titled “Resolve recipes in component code”const styles = useThemedStyles(s)const resolveButtonStyle = useMemo( () => createRecipeResolver(styles.button, { cacheSize: 32 }), [styles.button],)Then select state explicitly:
<Pressable style={({ pressed }) => resolveButtonStyle({ pressed, tone: "primary" })} />The resolver precomputes variant order, defaults and compound matchers. Its
selection cache is bounded to the resolver lifetime; cacheSize: 0 disables
retention. Use resolveButtonStyle.getCacheStats() for hit/miss/eviction
receipts and call resolveButtonStyle.dispose() when an owned resolver is no
longer needed.
Why explicit state is the rule
Section titled “Why explicit state is the rule”React Native has no CSS selector engine. There is no native equivalent of &:hover, &:focus, or &:active in .css.ts. State must come from component props or runtime callbacks.