Skip navigation
use CSS :has() & :user-valid/invalid to power form micro-interactions
0:00 / 0:24

use CSS :has() & :user-valid/invalid to power form micro-interactions

jhey ʕ•ᴥ•ʔ

@jh3yy148K followers

Visit on X
1,236 likesDownloadOriginal post

53,605 views

use CSS :has() & :user-valid/invalid to power form micro-interactions .group:has(:valid) { --color: var(--valid); } input:user-invalid + .error { display: block; } :user-valid/invalid detects if an input is valid and if it has been interacted with 🔥 no js dirty checkin' 🤙

10 Comments

Comments from the original post on X (Twitter)

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    here's the @CodePen link! 🚀 got a request for this in "the other place™" so threw together a new demo now that :user-valid/invalid has good support 🙌

    61 likes

  • Kyle TechSquidTV's profile picture

    @TechSquidTV

    Beautiful 👏

    2 likes

  • Steven's profile picture

    @AppLab_io

    Bro you’re cooking on thanksgiving? Love it

    1 like

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    not now - i'm waitin' for the cookin' 💀 got the game on, Steam Deck in hand 😇

    2 likes

  • Marlon Stevenson's profile picture

    @mRockSwe

    Really sweet animation. Bookmarked.

  • Marcos Esqueda's profile picture

    @bymarcant

    How did you do the grid pattern?

  • Riaad Arif's profile picture

    @riaad_arif

    Hats off to you! 🎩

  • Abolfazl's profile picture

    @mrjs6781

    That's so beautiful bro🤝

  • Patil Ketan's profile picture

    @patilketan671

    I love your design I try to make it useing ai but I can’t can you give me any idea ?

  • Matthias Martin's profile picture

    @RoyDigerhund

    Would be cool to have a CSS only solution for different error messages depending on the input.