[Radio] Allow to be used standalone without RadioGroup #1328
Description
Feature request
Summary
Enhance the Radio
component to support standalone usage without requiring it to be part of a RadioGroup
. Specifically, add support for checked
and onChange
props. This will allow developers to manage the state of individual Radio
components, enabling more flexibility for custom visual designs or use cases where RadioGroup
is not needed.
Examples in other libraries
Motivation
The current implementation tightly couples the Radio
component with RadioGroup
, making it less versatile in scenarios where developers:
- Need a static representation of radio buttons for read-only or decorative purposes.
- Want to use the
Radio
component for custom designs without needing fullRadioGroup
functionality. - Handle state or interactions independently for each
Radio
, such as in the case of custom forms, polls, or conditional UI.
By allowing Radio
to accept checked
and onChange
, developers can use it more flexibly in a variety of contexts. Currently, developers building their own components on Base UI need to create two versions of Radio
components: one based on the Base UI Radio
for use with RadioGroup
, and another that is a clone of the first to be used independently without RadioGroup
. Supporting checked
and onChange
directly in the Base UI Radio
would eliminate the need for such duplication, simplifying development and improving consistency across implementations.
Metadata
Assignees
Labels
Projects
Status
Backlog