Загрузка видео...

Не удалось загрузить видео

На главную

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 :)

Похожие видео