-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Radio] Allow to be used standalone without RadioGroup #1328
Comments
Hi @colmtuite, If possible, I would love to pick this up, Can you please assign it to me ? |
I've added this to backlog for now. Radio items are not valid outside of a radio group, so in order to add support for it, I will need some more information on why you'd ever want to do that.
Are you talking about a radio item card or something? Where there is a purely decorative radio button type visual artefact inside the card? If so, this can be done by styling
I can't think of any design where a radio is needed outside of a group? |
I may be wrong but I haven't found this explicitly listed in any HTML specification. Standard HTML radio input supports Based on my own research, MDN Web Docs for example say: "<input> elements of type radio are generally used in radio groups" Which doesn't mean it's invalid when used standalone. I have also created basic HTML structure with standalone Radio button and in a Radio Group, both pass HTML validation on https://validator.w3.org/#validate_by_input Standalone:
In Radio Group:
I have already changed my code to use RadioGroup so I personally don't require this feature but it may benefit someone else, like those migrating from Material UI. My specific use case was for polls and quizes that were built using Material UI 5 which supported standalone Radio buttons. |
@colmtuite check my duplicate issue to see one more usage example. Basically more complex forms and inputs are where this is needed. Also just following the vanilla HTML/JS functionality would be good. |
In order for this to properly work @elieven, where adding the It looks like Radix doesn't allow this behavior, though. In your case, what is the downside of wrapping |
@atomiks I meant from a UX perspective moreso than a spec perspective. Perhaps "valid" was the wrong word choice. What I'm wondering is, is there a reasonable requirement for supporting this, that justifies the documentation issues that will likely arise from it? I can't think of any reasonable use case for an isolated radio button. |
Feature request
Summary
Enhance the
Radio
component to support standalone usage without requiring it to be part of aRadioGroup
. Specifically, add support forchecked
andonChange
props. This will allow developers to manage the state of individualRadio
components, enabling more flexibility for custom visual designs or use cases whereRadioGroup
is not needed.Examples in other libraries
Material-UI Radio
Ant Design Radio
Motivation
The current implementation tightly couples the
Radio
component withRadioGroup
, making it less versatile in scenarios where developers:Radio
component for custom designs without needing fullRadioGroup
functionality.Radio
, such as in the case of custom forms, polls, or conditional UI.By allowing
Radio
to acceptchecked
andonChange
, 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 ofRadio
components: one based on the Base UIRadio
for use withRadioGroup
, and another that is a clone of the first to be used independently withoutRadioGroup
. Supportingchecked
andonChange
directly in the Base UIRadio
would eliminate the need for such duplication, simplifying development and improving consistency across implementations.The text was updated successfully, but these errors were encountered: