Skip navigation
Created this fully "accessible" dropdown using pure Tailwind CSS 🤩
0:00 / 0:21

Created this fully "accessible" dropdown using pure Tailwind CSS 🤩

Surjith S M ✪

@surjithctly10K followers

Visit on X
593 likesDownloadOriginal post

169,734 views

Created this fully "accessible" dropdown using pure Tailwind CSS 🤩 × No javascript × No custom styles Can you guess which CSS property is this?

78 Comments

Comments from the original post on X (Twitter)

  • Surjith S M ✪'s profile picture

    @surjithctly

    The correct answer is :focus-within ✨ People who guessed it right → @Xewl @cometkim @czechhater @szympajka 👏 Check out the code here 👇

    20 likes

  • Colm Tuite's profile picture

    @colmtuite

    @tailwindcss It's not possible to build an accessible dropdown without JS. I recommend using Radix or React Aria.

    11 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Yes, true. This is Keyboard accessible I meant.

  • Andrey Okonetchnikov's profile picture

    @okonetchnikov

    @colmtuite @tailwindcss Tab isn’t the right key of making a select accessible with a keyboard. Please don’t ship this to production since it will confuse lots of people.

    5 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @colmtuite @tailwindcss Yes, there are some limitations because this is a CSS only proof of concept.

  • Shruti Balasa's profile picture

    @shrutibalasa

    @tailwindcss Checkbox hack? Using peer-* utility classes I guess

    6 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Found a better way 😉

    3 likes

  • Mo Youssouf | Web Designer's profile picture

    @MedMYA

    @shrutibalasa @tailwindcss Is it :focus?

    2 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @shrutibalasa @tailwindcss You are close :) Check out the code here 👇

    2 likes

  • Shruti Balasa's profile picture

    @shrutibalasa

    @MedMYA @tailwindcss Really nice!

    1 like

  • Bhanu Teja P's profile picture

    @pbteja1998

    @tailwindcss Probably <details> and <summary> Atleast that’s what I use for these type of things.

    5 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Its possible, but closing by clicking outside will be nightmare :)

    2 likes

  • Amy Sans MS ✨— in my cat lady era's profile picture

    @amy_ndy

    @tailwindcss How do you update the aria-expended without js ?

    4 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Keyboard accessible 🙈

  • Mike's profile picture

    @Levous_io

    @tailwindcss Mind sharing the code? I'm interested what approach you used

    3 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Sure

  • Essomouah's profile picture

    @mo_souley

    @tailwindcss Purposely not sharing the code ?

    3 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Nope, Check out the code here 👇

    1 like

  • Timothée Guignard's profile picture

    @TimGuignard

    @tailwindcss Not really related to your question but which software do you use to show keyboard keys while taking the video screenshot?

    3 likes

  • Surjith S M ✪'s profile picture

    @surjithctly

    @tailwindcss Cleanshot.

    2 likes