Skip to content

Radio hover css behaves differently in Beta 5/6 #3263

Closed

Description

@literalpie

Bug report

Current behavior

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.

Reproducible example

Shows the two versions side-by-side. A workaround is added to App.css and commented out
https://stackblitz.com/edit/vitejs-vite-bwvxcdt3?file=src%2FApp.tsx,src%2FApp.css

Base UI version

1.0.0-beta.6

Which browser are you using?

Chrome and Safari

Which OS are you using?

macOS

Additional context

This also applies to Checkbox, and other css states like :active.

I suspect this might just be an expected outcome of #3205.

My workaround is using a css selector like .radio:hover, .radio:has(~ label:hover)

Activity

  1. added
    status: waiting for maintainer
    on Nov 18, 2025
  2. mj12albert commented on Nov 18, 2025

    @mj12albert
    Member

    I suspect this might just be an expected outcome of #3205

    😅 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

  3. added
    component: radio group
    and removed
    status: waiting for maintainer
    on Nov 18, 2025
  4. atomiks commented on Nov 18, 2025

    @atomiks
    Contributor

    <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)

  5. added
    type: expected behavior
    on Nov 19, 2025
  6. github-actions commented on Jan 5, 2026

    @github-actions

    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:

    npm i https://pkg.pr.new/@base-ui/react@3640
  7. literalpie commented on Jan 22, 2026

    @literalpie
    Author

    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)

  8. atomiks commented on Jan 22, 2026

    @atomiks
    Contributor

    @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

  9. atomiks commented on Jan 22, 2026

    @atomiks
    Contributor

    Actually, enclosing labels are supported as well without creating invalid HTML, though it requires some extra work:

    <Radio.Root 
      nativeButton 
      render={(props) => (
        <label>
          <button {...props} />
        </label>
      )}
    />

    The hidden input now sits outside the <label>: https://stackblitz.com/edit/vitejs-vite-ctslar1y?file=src%2FApp.tsx,package.json

  10. literalpie commented on Jan 23, 2026

    @literalpie
    Author

    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?

  11. atomiks commented on Jan 23, 2026

    @atomiks
    Contributor

    This is invalid HTML, because <label> can't contain both <button> and <input>

    <label>
      <Radio.Root nativeButton render={<button />} />
    </label>

    This is valid on the other hand, because <label> only contains the <button>:

    <Radio.Root 
      nativeButton 
      render={(props) => (
        <label>
          <button {...props} />
        </label>
      )}
    />

    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

  12. literalpie commented on Jan 23, 2026

    @literalpie
    Author

    Thanks so much for the explanation! It makes sense now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: radio grouptype: expected behavior

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions