mui / mui/base-ui

Export Root context hooks for better composability

Open
#4,329 13 comments 15 reactions 0 assignees View on GitHub
waiting for 👍
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.