Login
You're viewing the code4lib.social public feed.

Replies

  • 💬 0🔄 0⭐ 0
  • Aug 12, 2026, 10:35 PM

    @patrickbrosset so they are adding a bit of CSS that most sites have been adding for a bit over a decade.

    Is there a way in HTML/CSS to detect that this new 'switch' option is there natively and thus that one can disable the CSS people have, or enable the compat part?

    💬 1🔄 0⭐ 0
  • Patrick Brossetpatrickbrosset@mas.to
    Aug 13, 2026, 4:37 AM

    @jeroen I’m not expert on this new thing yet, but I would say:

    - In JavaScript: create an input, set its type to checkbox and set the switch attribute, then test if `"switch" in inputˋ is true. The fact that the IDL property is set probably indicates support.

    - in CSS: maybe a directory like ˋ input[type="checkbox"][switch][role="switch"]` would detect support, since the browser adds the switch role. But I’m not 100% sure.

    The switch attribute was made to silently progressively enhance any checkbox. But you’re right that detecting support would avoid loading unnecessary code for those who already have custom switches.

    @tomayac might be able to help further.

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 1
  • 💬 0🔄 0⭐ 0