mui / mui/base-ui

[radio group] Allow to be used standalone without RadioGroup

Open
#1,328 7 comments 0 reactions 0 assignees View on GitHub
breaking change component: radio group waiting for 👍
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

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

- [`Material-UI Radio`](https://mui.com/material-ui/react-radio-button/#standalone-radio-buttons)
- [`Ant Design Radio`](https://ant.design/components/radio/#components-radio-demo-basic)

## Motivation

The current implementation tightly couples the `Radio` component with `RadioGroup`, making it less versatile in scenarios where developers:
1. Need a static representation of radio buttons for read-only or decorative purposes.
2. Want to use the `Radio` component for custom designs without needing full `RadioGroup` functionality.
3. 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.

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.