Jump to content

Welcome to CodeNameJessica

Welcome to CodeNameJessica!

💻 Where tech meets community.

Hello, Guest! 👋
You're just a few clicks away from joining an exclusive space for tech enthusiasts, problem-solvers, and lifelong learners like you.

🔐 Why Join?
By becoming a member of CodeNameJessica, you’ll get access to:
In-depth discussions on Linux, Security, Server Administration, Programming, and more
Exclusive resources, tools, and scripts for IT professionals
A supportive community of like-minded individuals to share ideas, solve problems, and learn together
Project showcases, guides, and tutorials from our members
Personalized profiles and direct messaging to collaborate with other techies

🌐 Sign Up Now and Unlock Full Access!
As a guest, you're seeing just a glimpse of what we offer. Don't miss out on the complete experience! Create a free account today and start exploring everything CodeNameJessica has to offer.

Chris’ Corner: Simple, Accessible Multi-Select UI

(0 reviews)
by: Chris Coyier
Mon, 08 Sep 2025 17:01:16 +0000


There’s a nice article by Enzo Manuel Mangano called Checkbox Interactions – The beauty of Layout Animations. In the end, you get some nicely animated checkboxes, essentially:

I like it.

It’s a modern-looking multiple-choice with very clear UX.

Enzo’s tutorial is all React Native-ified. I think Enzo is a React Native guy and that’s his thing. And that’s fine and makes sense. A lot of time UI like this is part of highly dynamic web apps that deserve that kind of treatment and embracing that style of code to help it live there is fine.

But I wouldn’t want anyone to think that it’s necessary you reach for a tool like React Native to create something like this. This is actually pretty darn simple HTML & CSS that can be quite performant, semantic, and accessible.

Each of those “buttons”, is really this:

<label>
  Italian
  <input type="checkbox" class="screenreader-only">
  <svg>
    <path d="..." />
  <svg>
</label>

Each button is really a label, because then you are appropriately connecting the text of the label to the checkbox in an accessible way. I will call out Enzo for this one: his final demo outputs <div>s and <span>s, which you can’t even tab to, so it’s a pretty inaccessible final result.

When it’s a label, the whole thing becomes “clickable” then, toggling the checkbox within.

We can hide the actual checkboxes (notice the UI doesn’t actually show them) by applying an accessible screenreader-only class. But each of them remains an interactive element and thus are able to be tabbed to. But because we can’t see them, we should do…

label {
  cursor: pointer;

  &:focus-within {
    outline: 3px solid orange;
  }
}

This will ensure there is a visual indicator when any of them are focused. And with that focus, the spacebar will work to activate them like any normal checkbox.

The fun part though is the neat interaction where activating one of the options animated the checkbox in and changes some colors. It’s easy! I promise! We just check if the label has a checked input and make those changes. All right in CSS.

label {
  --highlightColor: oklch(0.764 0.1924 65.38);

  cursor: pointer;
  border: 1px solid white;

  &:focus-within {
    outline: 3px solid var(--highlightColor);
  }

  svg {
    width: 0;
    transition: width 0.66s;
    fill: var(--highlightColor);
  }
  
  &:has(:checked) {
    border-color: var(--highlightColor);
    background: color-mix(in srgb, var(--highlightColor), transparent 80%);

    svg {
      width: 0.88lh;
    }
  }
}

The finished demo, I’d say, is near 100% the same experience as Enzo’s. Cheers!

0 Comments

Recommended Comments

There are no comments to display.

Guest
Add a comment...

Important Information

Terms of Use Privacy Policy Guidelines We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.