The Pattern
Instead of importing multiple components:Creating Slots
UsewithSlots() to attach child components to a parent.
Card.Header, Card.Body, and Card.Footer are available.
Slots + Context
Slots become powerful when combined with context. Children automatically inherit parent variants.intent="success" styling.
When slot components share the same variants and context, use
styledConfig() to avoid duplicating the config.Nested Slots
You can add slots to components that already have slots.displayName
Slots preserve the original component’s display name for React DevTools.When to Use Slots
✅ Use slots when:- Components are meant to be used together
- You want dot notation for better DX
- Parent-child relationships should be obvious
- Components are independent
- There’s no clear parent-child relationship
- You’re just grouping unrelated components
Slots vs Children
Slots don’t restrict what children you can use. They’re just a convenient way to access related components.Next: React Native Guide
Using better-styled with React Native