Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

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

169,711 görüntüleme • 3 yıl önce •via X (Twitter)

78 Yorum

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

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

Colm Tuite profil fotoğrafı
Colm Tuite3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

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

Andrey Okonetchnikov profil fotoğrafı
Andrey Okonetchnikov3 yıl önce

@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.

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

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

Shruti Balasa profil fotoğrafı
Shruti Balasa3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Found a better way 😉

Mo Youssouf | Web Designer profil fotoğrafı
Mo Youssouf | Web Designer3 yıl önce

@shrutibalasa @tailwindcss Is it :focus?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

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

Shruti Balasa profil fotoğrafı
Shruti Balasa3 yıl önce

@MedMYA @tailwindcss Really nice!

Bhanu Teja P profil fotoğrafı
Bhanu Teja P3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

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

Amy Sans MS ✨— in my cat lady era profil fotoğrafı
Amy Sans MS ✨— in my cat lady era3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Keyboard accessible 🙈

Mike profil fotoğrafı
Mike3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Sure

Essomouah profil fotoğrafı
Essomouah3 yıl önce

@tailwindcss Purposely not sharing the code ?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Nope, Check out the code here 👇

Timothée Guignard profil fotoğrafı
Timothée Guignard3 yıl önce

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

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Cleanshot.

Dananz profil fotoğrafı
Dananz3 yıl önce

@tailwindcss It's cool and all until you try to use it inside an overflow: hidden container

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss yeah, will be a problem then. This is a simple POC :)

Dananz profil fotoğrafı
Dananz3 yıl önce

@tailwindcss Looks amazing btw, great job!

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss thank you

𝗫𝗲𝘄𝗹 / Ken V. ☄️ profil fotoğrafı
𝗫𝗲𝘄𝗹 / Ken V. ☄️3 yıl önce

@tailwindcss • focus-visible + peer • focus-within on container + group I need aria-expanded support, which I do with Alpine; so sadly not sufficient.

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss This is keyboard accessible. Sadly no way to change aria-* attributes.

𝗫𝗲𝘄𝗹 / Ken V. ☄️ profil fotoğrafı
𝗫𝗲𝘄𝗹 / Ken V. ☄️3 yıl önce

@tailwindcss With styles alone, I guess not. For a11y I use eg. AlpineJS & then style according/along to the aria-expanded's value instead.

Trecia Kat 👩🏽‍💻 profil fotoğrafı
Trecia Kat 👩🏽‍💻3 yıl önce

@tailwindcss Code 🙏 🤲

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Sure.

Trecia Kat 👩🏽‍💻 profil fotoğrafı
Trecia Kat 👩🏽‍💻3 yıl önce

@tailwindcss Link to source 🙏

btter profil fotoğrafı
btter3 yıl önce

@tailwindcss how did you implement that ?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@philipbr12 @tailwindcss Check out the code here 👇

btter profil fotoğrafı
btter3 yıl önce

@tailwindcss Thank you very much

Angel A. Núñez profil fotoğrafı
Angel A. Núñez3 yıl önce

@tailwindcss It looks amazing! 👏

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss thank you

kurky_tweets profil fotoğrafı
kurky_tweets3 yıl önce

@tailwindcss Code pls

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Danilo Gacevic profil fotoğrafı
Danilo Gacevic3 yıl önce

@tailwindcss Cool! Does it look the same on mobile browsers?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Yes, tested on ios safari & chrome. animations not showing up on chrome though.

Jose Antonio Dominguez profil fotoğrafı
Jose Antonio Dominguez3 yıl önce

@tailwindcss Focus! :) I love css without js powers

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Almost there 👇

Anand Chowdhary profil fotoğrafı
Anand Chowdhary3 yıl önce

@tailwindcss Target?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

asraf_ai profil fotoğrafı
asraf_ai3 yıl önce

@tailwindcss wow!!!

Abdullahi Jimoh  profil fotoğrafı
Abdullahi Jimoh 3 yıl önce

@tailwindcss Checkbox

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Gleb Varganov profil fotoğrafı
Gleb Varganov3 yıl önce

@tailwindcss Looks nice! Good job!

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss 😇

Senith profil fotoğrafı
Senith3 yıl önce

@tailwindcss It's smooth like butter.

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Thank you

Oliver Franke profil fotoğrafı
Oliver Franke3 yıl önce

@tailwindcss Wow that’s awesome! Would you mind sharing the code?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Alvaro Aquije profil fotoğrafı
Alvaro Aquije3 yıl önce

@tailwindcss That looks awesome, mind sharing the code?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@alvaro_dotdev @tailwindcss Check out the code here 👇

Pingero profil fotoğrafı
Pingero3 yıl önce

@tailwindcss Smooth!

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Martin Lexelius profil fotoğrafı
Martin Lexelius3 yıl önce

@tailwindcss It's a nice little css hack using a button and a div (which should not have role menu/menuitem). Keyboard nav does not follow established patterns and the state of the button is not communicated. Why not just build a real disclosure? Don't call it accessible 🤷‍♂️

Markus Lutz 🥨☢️☯️ profil fotoğrafı
Markus Lutz 🥨☢️☯️3 yıl önce

@tailwindcss Is it possible to get the code? Have tried there for hours with js.

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Markus Lutz 🥨☢️☯️ profil fotoğrafı
Markus Lutz 🥨☢️☯️3 yıl önce

@tailwindcss many thanks. This is great 🥰

hyeseong.kim profil fotoğrafı
hyeseong.kim3 yıl önce

@tailwindcss :focus-within?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss You are right 👏 Check out the code here 👇

Martin Lexelius profil fotoğrafı
Martin Lexelius3 yıl önce

@tailwindcss I hope it’s not the checkbox hack

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Nope :)

Basharath profil fotoğrafı
Basharath3 yıl önce

@tailwindcss Nice work, Surjith 👏

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Thank you

Lukas profil fotoğrafı
Lukas3 yıl önce

@tailwindcss Why not using custom CSS? Now there is a hard dependency on @tailwindcss

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Pretty much easy to do this in pure CSS as well. You can always copy paste the css to avoid tailwind as dependency.

Youenn profil fotoğrafı
Youenn3 yıl önce

@tailwindcss There is a way to close the dropdown after click on one off the button ? I need this but not for navigation :)

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss I guess you need js for that

creativenull profil fotoğrafı
creativenull3 yıl önce

@tailwindcss Looks like some simple css transitions :D

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@creativenullll @tailwindcss Check out the code here 👇

Marian Benčat profil fotoğrafı
Marian Benčat3 yıl önce

@tailwindcss Focus within.

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss You are right 👏 Check out the code here 👇

WinnersDaily profil fotoğrafı
WinnersDaily3 yıl önce

@tailwindcss Can we have the code?

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Check out the code here 👇

Mr. Ridlafalah profil fotoğrafı
Mr. Ridlafalah3 yıl önce

@tailwindcss amazing, really appreciate if you can show us the magic behind it 😁

Surjith S M ✪ profil fotoğrafı
Surjith S M ✪3 yıl önce

@tailwindcss Sure :)

Benzer Videolar