Skip to main content

Component Organization

Single-File Pattern

For compound components, define everything in one file:

Naming Conventions

Variant Names

Use descriptive, semantic names:

Boolean Variants

Prefix with is or has to avoid shadowing native props:

Slot Names

Use PascalCase, matching the visual role:

Performance

Avoid Inline Definitions

Define styled components outside render:

Context Scope

Only use context when you need variant propagation. For standalone components, skip it:

Minimize Compound Variants

Compound variants are powerful but add complexity. Use sparingly:

Common Pitfalls

Don’t Nest Contexts Unnecessarily

Each context adds a provider. Keep the tree shallow:

Variant vs Intent

Don’t create separate boolean variants when you can use a single variant or intent:

Design System Tips

Consistent Variant Values

Use the same variant names across components:

Default Variants

Always provide sensible defaults:
Common patterns for design systems:

React Native Specific

Use isDisabled Pattern

Pressable States

Leverage function composition for press states:

Platform-Specific Styles

Use NativeWind’s platform prefixes:

TypeScript Guide

Deep dive into type inference