Export Root context hooks for better composability
- Dominant language
- TypeScript
- Stars
- 10.9k
- Forks
- 543
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 101
Description
# Feature request
## Summary
Expose **Root context hooks** for Base UI components to allow developers to access internal component state and behaviors when building custom subcomponents.
Currently, many Base UI components manage their state internally through a Root provider (e.g. `open`, `value`, `active item`, `disabled`, etc.), but the corresponding context hooks are not publicly exported. Providing access to these hooks would enable advanced composition while still leveraging Base UI’s built-in logic and accessibility features.
For example, hooks such as:
- `useCheckboxRootContext()`
- `useSwitchRootContext()`
would allow developers to build custom triggers, indicators, animations, or wrappers that interact with the component state.
---
## Motivation
When building real-world applications or internal design systems, developers often need to:
- Create **custom triggers or controls**
- Add **custom animations or transitions**
- Build **design system wrappers**
- Access state such as:
- `open`
- `selected value`
- `active item`
- `disabled`
Without access to the Root context, developers may need to:
- Re-implement component logic
Exposing official context hooks would improve:
- **Composability**
- **Extensibility**
- **Developer experience**
- **Design system integration**
while still keeping the internal implementation consistent and accessible.
Contributor guide
Assessment
This issue has not been assessed yet.