And 2 days before this went live, dialog and ::backdrop gained support in Safari, and it's now supported in all major browser engines 🥳
@ggsingla2 жыл бұрын
🤩🤩
@bushigi59132 жыл бұрын
Damn, so easy to complement this behavior!!! Thank you Kevin!
@tonyrogers71012 жыл бұрын
Oh. Beautiful! I think I have a new favorite pseudo-element :) @Kevin Powell: Is it possible to add some very light animation to the modal’s appearance?
@borisvolkov11132 жыл бұрын
Any way to close modal on backdrop click?)
@diemantrabeats75512 жыл бұрын
What site do I need to follow to find out when new features are added to css? You seems to have an inside scoop and because I’m new to all this I have no idea where everyone’s find these new feature updates
@danielvillegas70132 жыл бұрын
I was literally trying to build my own modal with css last week. Amazing.
@davidgwyer51692 жыл бұрын
Same. 🙂
@souviksaha54162 жыл бұрын
@@davidgwyer5169 how can i close the modal by clicking on the backdrop using vanills js?
@lookupverazhou8599 Жыл бұрын
It's still good to build your own to see how it works.
@the-real-tridder2 жыл бұрын
I watched this, thought it was cool, went about existing, 3 months later, needed it, remembered your vid, searched it, found it and jobs done. Love your work, thank you!
@ChristianMay212 жыл бұрын
Learned this the hard way: if you change the "display" style property on the dialog, you'll also have to add a "display: none" for when the dialog is closed. The way the browser closes a dialog is just by setting `display: none` on it when the "open" attribute is false. Since that style comes from the User Agent stylesheet, it's very easy to overwrite - so if you have a rule like: .myDialog { display: grid }, make sure you also add an accompanying rule like .myDialog:not([open]) { display: none }.
@curiusrex2 жыл бұрын
Had the same problem here any display property for the element in CSS keeps it open...
@bernpaul9868 Жыл бұрын
How can I pass data inside or something like ajax ?
@outerpreneurconsulting6304 Жыл бұрын
Your comment save me some good time! thank you!
@eric.slyfield Жыл бұрын
Very important note here! Thanks for providing clarity.
@ThePessimisticPothead Жыл бұрын
Thank you so much for this comment. I've spent hours trying to figure out why my modal wasn't closing
@TheKrajcovicFamily Жыл бұрын
Very easy and useful. Thanks Kevin. A small tip. If you have a global reset of padding: 0; margin: 0; the model window will be stuck to the left side of the page when it opens
@Stan-l-e-y Жыл бұрын
thank you legend
@StockyJabberwockyGaming Жыл бұрын
Thank you!
@harryprowess9871 Жыл бұрын
Thanks man👍
@katiecollins68672 ай бұрын
Thank you for your comment, this helped me with my project :)
@Ferdam2 жыл бұрын
It's great. Next I want native css/html option to style/modify Drop Down menus, would be a dream! Also, you can easily use backdrop-filter: blur(4px); to get a blurry background, if you like fancy stuff
@478182 жыл бұрын
Well, this is good timing. I'm collaborating with a bunch of colleagues on a hackathon project starting tomorrow, and will need a modal. Was going to create it from scratch, so this will be a huge time saver since we only have a day and a half to have our idea come to life. Thank you!
@abishekbaiju17053 ай бұрын
I was struggling to extend the dialog to full width and full height. just adding min-width to full helped me solve the issue. thanks a ton for the video.
@bisedaniel14872 жыл бұрын
Hello Kevin, since you asked, it could be easier: showModal() / hideModal() or openModal() / closeModal() would be, if not more obvious, more coherent. Great video nonetheless. Thank you
@ScottLee642 жыл бұрын
Agree. If I saw show() or showModal() in someone's code, I'd immediately assume that hide() or hideModal() would be what I'd need to get rid of it.
@jcollins5192 жыл бұрын
, showModal(), and close()... Easy!
@wlockuz4467 Жыл бұрын
Doesn't make sense to have to close and closeModal if they're doing the same thing
@carradee Жыл бұрын
I made a polyfill for "dialog" several years ago, and I'm honestly glad it's *finally* outdated. It's about time.
@J3llyman2 жыл бұрын
This is actually the perfect functionality for a personal project I'm working on. Put it in and it just works! Love it when that happens.
@rozneg2 жыл бұрын
Amazing that it comes with that much functionality out of the box, saves a lot of time. Good job, thanks for sharing it!
@mamaburroughs301616 күн бұрын
Thank you so much for just posting this video. I was trying to find a way to do this and came across your video which worked perfectly! Love watching all of your content
@NathanHedglin2 жыл бұрын
Was just looking at this. Great video and perfect timing!
@tundeakinniyi61902 жыл бұрын
Thanks Kevin for this. You are that special person God has given this generation. Thanks for the updates. I like your explanation always
@pyplacca2 жыл бұрын
I think you can basically wrap the close button in the form inside the dialog so u don't have to use an event listener on the close button. Sure, there might be scenarios where you'd need the event listener but not for most use cases. Great stuff.
@spirobel2.0Ай бұрын
have a thumbs up sir
@mxjxn-art2 жыл бұрын
I think I watched at least a dozen videos of yours before I realized you were saying "hello my front end friends" and not "hello my friend and friends"
@tflitsch2 жыл бұрын
🤯
@KevinPowell2 жыл бұрын
You aren't the only one, lol. I've tried slowing down to make it more clear
@oliver1392 жыл бұрын
Miracle! I just need this in my interview test and youtube recommend this to me!
@hovhadovah2 жыл бұрын
This is awesome! Pleasantly surprised to see that also traps focus by default for accessibility.
@CyberTechBits2 жыл бұрын
Thanks Kevin! Love your content. I am immediately implementing this into two of my active projects! So, much cleaner/easier and less code than the old way! Thanks for keeping me up to date my friend!
@bradpirochta92932 жыл бұрын
Very nice. I'm an angular developer, and it is nice to use native elements for stuff like this.
@shibazhussain28896 ай бұрын
Thanks so much for this tutorial, I've been trying to figure this out for a while and a lot of tutorials online are very complicated as they are not aware of the built in functions that you demo'd. BTW for anyone struggling to get their modal to appear at the centre of the screen use the following CSS properties on your modal as I was getting frustrated that my modal was appearing in the corner of the screen. .modal1 { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 20px; border: 1px solid black; z-index: 1000; }
@dragonprince082 жыл бұрын
The idea of native HTML modals is so cool!!!!!
@victoriakolberg90962 жыл бұрын
I had to pause the video halfway through and subscribe to his channel. So great, thanks!
@pi11sburydoeboy2 жыл бұрын
I'm currently using bootstrap for modals at the moment since it was quick and dirty. But I'll be looking to implement this for sure! Love your content!!!
@tonyrogers71012 жыл бұрын
There’s never been a better time to give Bootstrap the boot. 👢 ;-)
@sirQuilly2 жыл бұрын
This is mind boggling - just yesterday I was searching the net for this exact solution... Thanks Kevin!
@abdulsalphan2 жыл бұрын
It's like he reads our mind and delivers us what we need.
@dougc842 жыл бұрын
This is something we've needed for a long time. Dealing with JS libraries for this kind of thing is inconsistent at best, and frustrating at worst. Even though it *does* technically require JS to work as modals (it would be nice if there was an kind of thing), its so minimal that even implementation in frameworks will take no time at all.
@IdleAtre2 жыл бұрын
I am surprised there is no "for" indeed.
@GloriousCoconut2 жыл бұрын
After doing on/off hobbiest web dev for like 15 years I've spent so many hours making stupid modals this changes everything forever.
@losrobbosful2 жыл бұрын
Exactly the thing I was waiting for. Kevin saved my life again once again
@andertker44602 жыл бұрын
I think this will be useful for anyone like me that has started doing a library as part of THE ODIN PROJECT curriculum. You're doing a great job; keep it up. Greetings from Bilbao, Spain.
@StuckDuck2 жыл бұрын
My life has been changed since this video dropped
@walkingin63752 жыл бұрын
Absolutely what I need right now for my project. Thanks Kevin
@heisthazey73112 жыл бұрын
I've had to hand craft 3 modals just this week..this video could not have any better timing. I'm excited to use this & hopefully browsers will catch up and start supporting it across the board so dialogs can actually be used in production sites.
@trplnr2 жыл бұрын
I've been trying to find out how to make these and i didnt know it was this easy, Thanks!
@fabhi2 жыл бұрын
Front End Friends! Yes! Great improvement
@mikhailvasilev57982 жыл бұрын
woooooooow awesome, my life will never be the same Thanks!!!
@karek95932 жыл бұрын
this makes things 10x easier love it
@christian-schubert7 ай бұрын
Okay, just had a good laugh 😆 "Have you ever needed a modal or popup to ...POP UP?" ...and then the KZfaq Cookie Banner popped up on me. Now, THAT'S what perfect timing is all about. Comedy GOLD
@shahfaisal39232 жыл бұрын
This is one of the amazing video I've ever seen. Thanks a lot Kevin for this amazing video.
@HaNaxHeart2 жыл бұрын
I havent watch the video, but I already know its gonna be awesome, love your videos.
@littlebit725 Жыл бұрын
This is freaking dreamy. Thanks for sharing!
@Ana_Alien2 жыл бұрын
You help me improve myself in CSS every day. I hope you create js videos for beginners. that will make a difference for me because your way of explaining is so beautiful
@dannyt5032 жыл бұрын
For JS stuff, try looking up the channel called "Fireship". He explains stuff in short easy to understand videos.
@tonyrogers71012 жыл бұрын
Also check out the channels: * Web Dev Simplified * Layout Land Both are top-notch. Web Dev Simplified also has lots of JS stuff (as well as CSS stuff) that is very well explained.
@gabyramosita6 ай бұрын
You explain things so well!! I'm learning and this helped a lot, thank you!
@cintron3d2 жыл бұрын
After going through the pain of implementing an accessible dialog from scratch - this is amazing news! Can't wait to swap my custom implementation out for this! (Reduce bundle size and maintenance load)
@veritatas6782 жыл бұрын
I loved this new element so much that I already put it in production code :=
@DjLeonSKennedy2 жыл бұрын
Native dialog is amazing! Thank you
@lucienchu96492 жыл бұрын
Finally, it could be possible to drop MUI modal, which is pretty nice.
@pazzoeo2 жыл бұрын
This puts such a big smile on my face
@archiem63232 жыл бұрын
I will make this one. Thanks. Always a fan.🤗
@haekalalexander30312 жыл бұрын
Bro why is this KZfaq channel has low views, my css skills went up drastically after i discovered him, i wish this KZfaq channel will become more popular in the future, i found out that you can explain css better than web dev simplified and make learning css fun
@hiddenninja77922 жыл бұрын
amazing tutorial on how to create a popup modal. thanks a lot for the vid.
@kylevandeusen2 жыл бұрын
Totally nailed frontend friends on this one bud!
@keremunce19722 жыл бұрын
DUDE THAST SUPER EASY THANK YOU KEVIN
@bobdinitto2 жыл бұрын
Awesome! And the background options are a nice touch. Sadly too late for my current project but I shall consider using this going forward. Thanks for showing!
@abhinayganu2 жыл бұрын
Thanking you, I have been trying to learn practice anyway.
@soggygooseman2 жыл бұрын
Is there a clean way to close on outside click, by chance? I'm assuming you can throw a listener on the ::backdrop pseudo element? Otherwise great content as always, thank you so much!
@strot21032 жыл бұрын
i join the question
@josvelema23622 жыл бұрын
with an eventlistener on click yes you can; something like this: modal.addEventlistener("click"" , (event) => { if( event.target.className == "backdrop" ) { modal.style.display = "none"; } })
@soggygooseman2 жыл бұрын
@@josvelema2362 I don't have a fiddle up to play with all of this, was just kinda theoretical, but I think your example might fail bc backdrop isn't a class, but a pseudo-element right? (i.e. - it's not .backdrop but ::backdrop) not sure you can target a pseudo element off target event, but again im just thinking off my head so could easily be wrong here
@josvelema23622 жыл бұрын
@@soggygooseman maybe not , but wrapping it an container with a class would. or maybe you could negate it in the if statement. I have no problems with my own modal system where the modal can be closed by pressing on the X button or (so an or statement also) outside the modal box (the blurred backdrop/ground). If it is not possible , it should be made possible ;) Have it go when you find the time and let me know , I don't have time at the moment for fiddling , but I would if I had.
@KevinPowell2 жыл бұрын
I haven't tried playing with that, but I bet it's not too hard. Only thing is I don't think you could listen for a click on the pseudo element
@josesavioli39822 жыл бұрын
Very useful tag! Didn't know about it
@stellanwae505010 ай бұрын
You made it soooooo easy. Thanks Kevin
@DaVince212 жыл бұрын
This is really useful functionality!
@gregtasi2 жыл бұрын
This is absolutely amazing! Had so much trouble making my own custom modals...
@thedacian1232 жыл бұрын
Awsome.There are sofisticated widgets library that have this(eg Anguular Materials) and now it is available out of the box
@Stoney_Eagle2 жыл бұрын
I love this native modal feature already! I'm gonna pass this on to my designer for the website I'm working on, but I assume she also got your notification hehe. You can make the onclick callback shorter by removing all the syntax and just pass the anonymous function as a callback variable if you don't need any extra functionality 😉
@jonmayer2 жыл бұрын
This is really interesting and saves so much set up. Very cool.
@omkarp99432 жыл бұрын
Thanks Mr. Powell !
@user-hg8bo3em5y2 жыл бұрын
Wow that's really cool I didn't even this existed
@fallonmassey4714 Жыл бұрын
I think I'm in love 😅😅😅 *This has been a long time coming,* I hate the confirm dialog!🤨
@erikjansson17902 жыл бұрын
Thanks for another great video! I don’t know if it’s safari (iPhone) that doesn’t support it yet, but VoiceOver doesn’t announce that the modal has popped up. Usually you need to set a live region for screen readers to announce real-time changes like this. I’m curious if that is now out-of-the-box. I’ll check with another screen reader and report back … UPDATE: Tested with -compatible browser and the NVDA screen reader. It works! Not clear that it works with modals triggered by something else than a user interaction. For example "You're about to be signed out automatically". That may or may not still need a role="alertdialog". Another thing: an accessible solution, like a11y modal, should place the focus back on the button/link once the modal is closed.
@JoeBonez2 жыл бұрын
I think this will definitely replace the MudBlazor dialogs I’m currently using.
@ziadamer76212 жыл бұрын
I am eagerly waiting for the videos to be uploaded by Professor ❤❤
@AabhusanAryalOfficial2 жыл бұрын
The last time I watched your video, you said "Hello there my friend and friends" in your intro
@valentinkhoroshkov97092 жыл бұрын
Excellent! Thank you, Kevin!
@1bcx Жыл бұрын
In ::backdrop You can use the following method background-filter : blur(“add how many px with blur ”) i use 5px
@robertzeurunkl84012 жыл бұрын
Dammit! I spent a lot of time coming up with a JavaScript modal dialog box scheme, only to have YOU undo it with a single native HTML element! lol
@ashtonblignaut45652 жыл бұрын
Omw this is amazing! Thanks for sharing!
@the_end_boss2 жыл бұрын
Nice tutorial with some handy tips of variations.
@aleksandr952 жыл бұрын
Thank you so much, Kevin!
@welling12 жыл бұрын
Wow. Simple! (And I even understood the Javascript! )
@valeriousmonk6542 жыл бұрын
This is revolutionary!
@chezchezchezchez2 жыл бұрын
Life will never be the same.
@MrSteini1242 жыл бұрын
So cool and simple. Thanks a ton!
@Jeer9632 жыл бұрын
OMG Thank you so much, you are my hero
@riman84932 жыл бұрын
This is awesome! :D Thanks for sharing!!
@kiddhkane2 жыл бұрын
Very useful, thank you man!
@wvaviator34082 жыл бұрын
I'd be interested to learn more about how this might help with developing modal functionality that's accessible. I know that modals are a hot topic for accessibility since they're so easy to screw up, and my guess is that this new component is probably handles a lot of stuff like keyboard focus and navigation out of the box which will be very helpful.
@dannyt5032 жыл бұрын
Yeah it has all the accessibility stuff baked in by default. It's great 😊
@SuperGylden2 жыл бұрын
@@dannyt503 Unfortunately it hasn't. Yet
@dannyt5032 жыл бұрын
@@SuperGylden That is what Safari was holding out on. They wanted the accessibility issues resolved before launching it. Since they launched I'm assuming the issues were resolved. It's possible that Chrome/Firefox might still have the issues in them though.
@SuperGylden2 жыл бұрын
@@dannyt503 As I understand it, there's still issues on how the modal should get focus. I can't link to it but the discussion is going on at whatwgs github. I also tried myself to use the tab key and was able to move out of the dialog/modal. That is perhaps as it is supposed to work but different from the "normal accessibility" recommendations for modals. I hope the issues will be sorted, it will make life so much easier.
@KrelleTG2 жыл бұрын
Hi Kevin, how would you go about closing the dialog by clicking outside the dialog?
@RishabhxShukla2 жыл бұрын
Thanks a lot Kevin!
@pramodkumarrana81782 жыл бұрын
Good stuff ✨✨
@ev7212 жыл бұрын
Fabulous indeed!
@iSaac-kp5lk Жыл бұрын
Thank you mr powell🤝🏾
@Liootas2 жыл бұрын
super as always. ty man
@nro3372 жыл бұрын
Awesome! Thanks for the great content!
@Morrile12 жыл бұрын
Looks like the right type of 'notice' for skipping menus for accessibility.
@KevinPowell2 жыл бұрын
Oh, interesting. Not sure if we could use it for that, since it won't open on focus, so it would mean interactive with a button to then open a modal, and choosing from there, rather than simply being a link that would take less actions to complete 🤔
@a.galvaop.7872 жыл бұрын
This is gold.
@yannickleroy74192 жыл бұрын
OMG This is awesome!
@denhamk Жыл бұрын
super! wish they gave us the modal::backdrop - filter blur option to go with it..
@Victor_Marius2 жыл бұрын
No more bootstrap modals! Although I create my own every time I need one even though I have bootstrap linked because I don't like how bootstrap creates and appends a backdrop element every time you open the modals. And of course it destroys the backdrop when you close it
@kjul.2 жыл бұрын
Why did I not know about the awesome dialog element? I literally built a modal a few weeks ago from scratch by messing around with divs.
@adamlevoy2 жыл бұрын
Found solution to center modal with margin auto. By default the modal is positioned absolute, top left.
@paulo_alchemist97662 жыл бұрын
This is so useful! Thanks.
@Pareshbpatel2 жыл бұрын
Another fine job, keeping us informed on all the latest HTML/CSS trends. Very nicely explained. Thanks. Kevin {2022-03-19}, {2024-02-16}
@ShadowDrakken2 жыл бұрын
Glad there's an easy element for this now. I hope it's widely adopted so we can easily script it into oblivion when it's used to boohoo about my ad blocker doing its job.