Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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

169,711 Aufrufe • vor 3 Jahren •via X (Twitter)

78 Kommentare

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Colm Tuite
Colm Tuitevor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Andrey Okonetchnikov
Andrey Okonetchnikovvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Shruti Balasa
Shruti Balasavor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Found a better way 😉

Profilbild von Mo Youssouf | Web Designer
Mo Youssouf | Web Designervor 3 Jahren

@shrutibalasa @tailwindcss Is it :focus?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Shruti Balasa
Shruti Balasavor 3 Jahren

@MedMYA @tailwindcss Really nice!

Profilbild von Bhanu Teja P
Bhanu Teja Pvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Amy Sans MS ✨— in my cat lady era
Amy Sans MS ✨— in my cat lady eravor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Keyboard accessible 🙈

Profilbild von Mike
Mikevor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Sure

Profilbild von Essomouah
Essomouahvor 3 Jahren

@tailwindcss Purposely not sharing the code ?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Nope, Check out the code here 👇

Profilbild von Timothée Guignard
Timothée Guignardvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Cleanshot.

Profilbild von Dananz
Dananzvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Dananz
Dananzvor 3 Jahren

@tailwindcss Looks amazing btw, great job!

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss thank you

Profilbild von 𝗫𝗲𝘄𝗹 / Ken V. ☄️
𝗫𝗲𝘄𝗹 / Ken V. ☄️vor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von 𝗫𝗲𝘄𝗹 / Ken V. ☄️
𝗫𝗲𝘄𝗹 / Ken V. ☄️vor 3 Jahren

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

Profilbild von Trecia Kat 👩🏽‍💻
Trecia Kat 👩🏽‍💻vor 3 Jahren

@tailwindcss Code 🙏 🤲

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Sure.

Profilbild von Trecia Kat 👩🏽‍💻
Trecia Kat 👩🏽‍💻vor 3 Jahren

@tailwindcss Link to source 🙏

Profilbild von btter
bttervor 3 Jahren

@tailwindcss how did you implement that ?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@philipbr12 @tailwindcss Check out the code here 👇

Profilbild von btter
bttervor 3 Jahren

@tailwindcss Thank you very much

Profilbild von Angel A. Núñez
Angel A. Núñezvor 3 Jahren

@tailwindcss It looks amazing! 👏

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss thank you

Profilbild von kurky_tweets
kurky_tweetsvor 3 Jahren

@tailwindcss Code pls

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Danilo Gacevic
Danilo Gacevicvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Jose Antonio Dominguez
Jose Antonio Dominguezvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Almost there 👇

Profilbild von Anand Chowdhary
Anand Chowdharyvor 3 Jahren

@tailwindcss Target?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von asraf_ai
asraf_aivor 3 Jahren

@tailwindcss wow!!!

Profilbild von Abdullahi Jimoh
Abdullahi Jimoh vor 3 Jahren

@tailwindcss Checkbox

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Gleb Varganov
Gleb Varganovvor 3 Jahren

@tailwindcss Looks nice! Good job!

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss 😇

Profilbild von Senith
Senithvor 3 Jahren

@tailwindcss It's smooth like butter.

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Thank you

Profilbild von Oliver Franke
Oliver Frankevor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Alvaro Aquije
Alvaro Aquijevor 3 Jahren

@tailwindcss That looks awesome, mind sharing the code?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@alvaro_dotdev @tailwindcss Check out the code here 👇

Profilbild von Pingero
Pingerovor 3 Jahren

@tailwindcss Smooth!

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Martin Lexelius
Martin Lexeliusvor 3 Jahren

@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 🤷‍♂️

Profilbild von Markus Lutz 🥨☢️☯️
Markus Lutz 🥨☢️☯️vor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Markus Lutz 🥨☢️☯️
Markus Lutz 🥨☢️☯️vor 3 Jahren

@tailwindcss many thanks. This is great 🥰

Profilbild von hyeseong.kim
hyeseong.kimvor 3 Jahren

@tailwindcss :focus-within?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Martin Lexelius
Martin Lexeliusvor 3 Jahren

@tailwindcss I hope it’s not the checkbox hack

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Nope :)

Profilbild von Basharath
Basharathvor 3 Jahren

@tailwindcss Nice work, Surjith 👏

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Thank you

Profilbild von Lukas
Lukasvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von Youenn
Youennvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss I guess you need js for that

Profilbild von creativenull
creativenullvor 3 Jahren

@tailwindcss Looks like some simple css transitions :D

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@creativenullll @tailwindcss Check out the code here 👇

Profilbild von Marian Benčat
Marian Benčatvor 3 Jahren

@tailwindcss Focus within.

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

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

Profilbild von WinnersDaily
WinnersDailyvor 3 Jahren

@tailwindcss Can we have the code?

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Check out the code here 👇

Profilbild von Mr. Ridlafalah
Mr. Ridlafalahvor 3 Jahren

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

Profilbild von Surjith S M ✪
Surjith S M ✪vor 3 Jahren

@tailwindcss Sure :)

Ähnliche Videos