Skip to content

[docs] Radio docs are incorrect/lacking #1694

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

Closed
benface opened this issue Apr 9, 2025 · 4 comments · Fixed by #1756
Closed

[docs] Radio docs are incorrect/lacking #1694

benface opened this issue Apr 9, 2025 · 4 comments · Fixed by #1756
Labels
bug 🐛 Something isn't working docs Improvements or additions to the documentation

Comments

@benface
Copy link

benface commented Apr 9, 2025

Docs feedback

How can we improve Base UI documentation?

The docs for the Radio.Root component mention:

Represents the radio button itself. Renders a element and a hidden beside.

But that's incorrect; the hidden <input> seems to be rendered as a sibling of the <button> element rather than inside it.

Which begs the question... why can't <Radio.Root> actually render a <label> that contains both the <button> and the <input>? Seems strange to have to wrap it in a <label> ourselves, as per the example... it's not really documented so maybe that's optional, but if we don't wrap it in a <label>, how is the radio going to be labelled?

@benface benface added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 9, 2025
@benface
Copy link
Author

benface commented Apr 9, 2025

Another issue: Radio.Root's value prop apparently has a default value of undefined, which makes it look like that prop is optional (not to mention that native <input type="radio" /> work just fine without a value), but it's actually required. Maybe required props should have no default value specified, or maybe it could be even more explicit and show "(required)" or something?

Image

@atomiks
Copy link
Contributor

atomiks commented Apr 9, 2025

But that's incorrect; the hidden seems to be rendered as a sibling of the element rather than inside it.

It says "beside" not "inside"

Which begs the question... why can't <Radio.Root> actually render a that contains both the and the ?

For form controls specifically, we recommend using the Field (Field.Label), which provides labelling for them (along with validation). If it's not a form control that's focusable, then it gets its own Label part (e.g. Progress)

Another issue: Radio.Root's value prop apparently has a default value of undefined, which makes it look like that prop is optional (not to mention that native work just fine without a value), but it's actually required. Maybe required props should have no default value specified, or maybe it could be even more explicit and show "(required)" or something?

Makes sense, the docs in this case can be better

@atomiks atomiks added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 10, 2025
@benface
Copy link
Author

benface commented Apr 10, 2025

It says "beside" not "inside"

Oops, my bad. I should read what I copy/paste more carefully. 😄

For form controls specifically, we recommend using the Field (Field.Label), which provides labelling for them (along with validation). If it's not a form control that's focusable, then it gets its own Label part (e.g. Progress)

Awesome, thanks for the tip!

@benface
Copy link
Author

benface commented Apr 16, 2025

Another issue: Radio.Root's value prop apparently has a default value of undefined, which makes it look like that prop is optional (not to mention that native work just fine without a value), but it's actually required. Maybe required props should have no default value specified, or maybe it could be even more explicit and show "(required)" or something?

Makes sense, the docs in this case can be better

Note: I noticed the exact same issue with the Menu.RadioItem component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants