Compound Components with Context
Build multi-part components that share state through context.
Compound Components
A compound component is one logical UI split into several sub-components that coordinate (Tabs + Tab + TabPanel).
Shared State via Context
The parent sets shared state in context; children read it via getContext.
<!-- Tabs.svelte -->
setContext("tabs", { active, setActive });All lessons in this course
- Render Props with Snippets
- Higher-Order Components
- The Builder Pattern for Headless UI
- Compound Components with Context