Skip to content

Export Root context hooks for better composabilityย #4329

@adityaa72

Description

@adityaa72

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for ๐Ÿ‘Waiting for upvotes. Open for community feedback and needs more interest to be worked on.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions