You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Radio hover css behaves differently in Beta 5/6 #3263
If you do a css selector like .radio:hover, beta 4 and below would apply the styles when you hover the label associated with the radio element. In beta 6, this is not the case.
Expected behavior
It would be nice if the beta 4 behavior could be brought back.
<Select.Trigger> acted this way in beta.4 as well, so it wasn't necessarily consistent across form controls before
If you use enclosing <label>s like on the docs, the selector is more straightforward:
label:hover.radio{}
Enclosing <label>s also prevent issues with layout where pressing a gap between the label text and button control still activates the item. With siblings you need to ensure there's no gap in layout between them (e.g. padding)
@literalpie sorry, it's not clear from the GitHub bot message, but basically we allow native/old behavior if you intentionally render a <button>.
We still prioritize supporting enclosing <label>s without creating invalid HTML by default (they render <span>s), but if you render a button (<Radio.Root nativeButton render={<button />} />), then you'll get the old :hover behavior back since the id is linked to the visible form control, at the cost of not being able to use enclosing labels
For others who may find this, I was confused why the suggested code works, but not a label wrapping the whole Radio.Root. This JSFiddle shows that if there's both a button and an input inside a label, the :hover pseudo class on the button won't include hover of the label. If only a button is inside the label, the pseudo class will include hovering of the label. Atomiks' suggested code would cause the hidden input to be a sibling of the label, not inside it.
@atomiks You've been helpful so far, so sorry to ask another question. When you say
without creating invalid HTML by default
Do you mean your suggested solution would cause invalid HTML? If not, what's the invalid html you refer to?
We optimized for the simpest case to work by default:
<label><Radio.Root/></label>
Which is valid since it renders a <span> inside the <label> along with <input>. And retaining the :hover behavior is easy enough:
label:hover.Radio{}
Your JS fiddle doesn't seem to contain code that describes your issue. I think it picks the first "form control", so <button> works if <input> is rendered after in the DOM
Activity
mj12albert commentedon Nov 18, 2025
😅 yeah you're right: #3205 (comment)
The beta.4 behavior is because the label was linked to the button, but now it's linked to the hidden input for valid HTML
atomiks commentedon Nov 18, 2025
<Select.Trigger>acted this way in beta.4 as well, so it wasn't necessarily consistent across form controls beforeIf you use enclosing
<label>s like on the docs, the selector is more straightforward:Enclosing
<label>s also prevent issues with layout where pressing a gap between the label text and button control still activates the item. With siblings you need to ensure there's no gap in layout between them (e.g. padding)github-actions commentedon Jan 5, 2026
This fix will be available in the next npm release of Base UI.
In the meantime, you can try it out on our Canary release channel:
literalpie commentedon Jan 22, 2026
This doesn't seem to be fixed (stackblitz). The workaround I've been using continues to work.
(I won't reopen this because the previous messages indicate this is expected)
atomiks commentedon Jan 22, 2026
@literalpie sorry, it's not clear from the GitHub bot message, but basically we allow native/old behavior if you intentionally render a
<button>.We still prioritize supporting enclosing
<label>s without creating invalid HTML by default (they render<span>s), but if you render a button (<Radio.Root nativeButton render={<button />} />), then you'll get the old:hoverbehavior back since the id is linked to the visible form control, at the cost of not being able to use enclosing labelsatomiks commentedon Jan 22, 2026
Actually, enclosing labels are supported as well without creating invalid HTML, though it requires some extra work:
The hidden input now sits outside the
<label>: https://stackblitz.com/edit/vitejs-vite-ctslar1y?file=src%2FApp.tsx,package.jsonliteralpie commentedon Jan 23, 2026
For others who may find this, I was confused why the suggested code works, but not a label wrapping the whole Radio.Root. This JSFiddle shows that if there's both a button and an input inside a label, the :hover pseudo class on the button won't include hover of the label. If only a button is inside the label, the pseudo class will include hovering of the label. Atomiks' suggested code would cause the hidden input to be a sibling of the label, not inside it.
@atomiks You've been helpful so far, so sorry to ask another question. When you say
Do you mean your suggested solution would cause invalid HTML? If not, what's the invalid html you refer to?
atomiks commentedon Jan 23, 2026
This is invalid HTML, because
<label>can't contain both<button>and<input>This is valid on the other hand, because
<label>only contains the<button>:We optimized for the simpest case to work by default:
Which is valid since it renders a
<span>inside the<label>along with<input>. And retaining the:hoverbehavior is easy enough:Your JS fiddle doesn't seem to contain code that describes your issue. I think it picks the first "form control", so
<button>works if<input>is rendered after in the DOMliteralpie commentedon Jan 23, 2026
Thanks so much for the explanation! It makes sense now