正在加载视频...

视频加载失败

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

169,711 次观看 • 3 年前 •via X (Twitter)

78 条评论

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Colm Tuite 的头像
Colm Tuite3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Andrey Okonetchnikov 的头像
Andrey Okonetchnikov3 年前

@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 ✪ 的头像
Surjith S M ✪3 年前

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

Shruti Balasa 的头像
Shruti Balasa3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Found a better way 😉

Mo Youssouf | Web Designer 的头像
Mo Youssouf | Web Designer3 年前

@shrutibalasa @tailwindcss Is it :focus?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Shruti Balasa 的头像
Shruti Balasa3 年前

@MedMYA @tailwindcss Really nice!

Bhanu Teja P 的头像
Bhanu Teja P3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Amy Sans MS ✨— in my cat lady era 的头像
Amy Sans MS ✨— in my cat lady era3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Keyboard accessible 🙈

Mike 的头像
Mike3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Sure

Essomouah 的头像
Essomouah3 年前

@tailwindcss Purposely not sharing the code ?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Nope, Check out the code here 👇

Timothée Guignard 的头像
Timothée Guignard3 年前

@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 ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Cleanshot.

Dananz 的头像
Dananz3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Dananz 的头像
Dananz3 年前

@tailwindcss Looks amazing btw, great job!

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss thank you

𝗫𝗲𝘄𝗹 / Ken V. ☄️ 的头像
𝗫𝗲𝘄𝗹 / Ken V. ☄️3 年前

@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 ✪ 的头像
Surjith S M ✪3 年前

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

𝗫𝗲𝘄𝗹 / Ken V. ☄️ 的头像
𝗫𝗲𝘄𝗹 / Ken V. ☄️3 年前

@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 👩🏽‍💻 的头像
Trecia Kat 👩🏽‍💻3 年前

@tailwindcss Code 🙏 🤲

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Sure.

Trecia Kat 👩🏽‍💻 的头像
Trecia Kat 👩🏽‍💻3 年前

@tailwindcss Link to source 🙏

btter 的头像
btter3 年前

@tailwindcss how did you implement that ?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@philipbr12 @tailwindcss Check out the code here 👇

btter 的头像
btter3 年前

@tailwindcss Thank you very much

Angel A. Núñez 的头像
Angel A. Núñez3 年前

@tailwindcss It looks amazing! 👏

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss thank you

kurky_tweets 的头像
kurky_tweets3 年前

@tailwindcss Code pls

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Danilo Gacevic 的头像
Danilo Gacevic3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Jose Antonio Dominguez 的头像
Jose Antonio Dominguez3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Almost there 👇

Anand Chowdhary 的头像
Anand Chowdhary3 年前

@tailwindcss Target?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

asraf_ai 的头像
asraf_ai3 年前

@tailwindcss wow!!!

Abdullahi Jimoh  的头像
Abdullahi Jimoh 3 年前

@tailwindcss Checkbox

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Gleb Varganov 的头像
Gleb Varganov3 年前

@tailwindcss Looks nice! Good job!

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss 😇

Senith 的头像
Senith3 年前

@tailwindcss It's smooth like butter.

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Thank you

Oliver Franke 的头像
Oliver Franke3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Alvaro Aquije 的头像
Alvaro Aquije3 年前

@tailwindcss That looks awesome, mind sharing the code?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@alvaro_dotdev @tailwindcss Check out the code here 👇

Pingero 的头像
Pingero3 年前

@tailwindcss Smooth!

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Martin Lexelius 的头像
Martin Lexelius3 年前

@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 🥨☢️☯️ 的头像
Markus Lutz 🥨☢️☯️3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Markus Lutz 🥨☢️☯️ 的头像
Markus Lutz 🥨☢️☯️3 年前

@tailwindcss many thanks. This is great 🥰

hyeseong.kim 的头像
hyeseong.kim3 年前

@tailwindcss :focus-within?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Martin Lexelius 的头像
Martin Lexelius3 年前

@tailwindcss I hope it’s not the checkbox hack

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Nope :)

Basharath 的头像
Basharath3 年前

@tailwindcss Nice work, Surjith 👏

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Thank you

Lukas 的头像
Lukas3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@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 的头像
Youenn3 年前

@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 ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss I guess you need js for that

creativenull 的头像
creativenull3 年前

@tailwindcss Looks like some simple css transitions :D

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@creativenullll @tailwindcss Check out the code here 👇

Marian Benčat 的头像
Marian Benčat3 年前

@tailwindcss Focus within.

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

WinnersDaily 的头像
WinnersDaily3 年前

@tailwindcss Can we have the code?

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Check out the code here 👇

Mr. Ridlafalah 的头像
Mr. Ridlafalah3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Sure :)

相关视频