No video

dialog = the easiest way to make a popup modal

  Рет қаралды 190,656

Kevin Powell

Kevin Powell

Күн бұрын

Пікірлер: 331
@KevinPowell
@KevinPowell 2 жыл бұрын
And 2 days before this went live, dialog and ::backdrop gained support in Safari, and it's now supported in all major browser engines 🥳
@ggsingla
@ggsingla 2 жыл бұрын
🤩🤩
@bushigi5913
@bushigi5913 2 жыл бұрын
Damn, so easy to complement this behavior!!! Thank you Kevin!
@tonyrogers7101
@tonyrogers7101 2 жыл бұрын
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?
@borisvolkov1113
@borisvolkov1113 2 жыл бұрын
Any way to close modal on backdrop click?)
@diemantrabeats7551
@diemantrabeats7551 2 жыл бұрын
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
@danielvillegas7013
@danielvillegas7013 2 жыл бұрын
I was literally trying to build my own modal with css last week. Amazing.
@davidgwyer5169
@davidgwyer5169 2 жыл бұрын
Same. 🙂
@souviksaha5416
@souviksaha5416 2 жыл бұрын
@@davidgwyer5169 how can i close the modal by clicking on the backdrop using vanills js?
@lookupverazhou8599
@lookupverazhou8599 Жыл бұрын
It's still good to build your own to see how it works.
@the-real-tridder
@the-real-tridder 2 жыл бұрын
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!
@ChristianMay21
@ChristianMay21 2 жыл бұрын
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 }.
@curiusrex
@curiusrex 2 жыл бұрын
Had the same problem here any display property for the element in CSS keeps it open...
@bernpaul9868
@bernpaul9868 Жыл бұрын
How can I pass data inside or something like ajax ?
@outerpreneurconsulting6304
@outerpreneurconsulting6304 Жыл бұрын
Your comment save me some good time! thank you!
@eric.slyfield
@eric.slyfield Жыл бұрын
Very important note here! Thanks for providing clarity.
@ThePessimisticPothead
@ThePessimisticPothead Жыл бұрын
Thank you so much for this comment. I've spent hours trying to figure out why my modal wasn't closing
@TheKrajcovicFamily
@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
@Stan-l-e-y Жыл бұрын
thank you legend
@StockyJabberwockyGaming
@StockyJabberwockyGaming Жыл бұрын
Thank you!
@harryprowess9871
@harryprowess9871 Жыл бұрын
Thanks man👍
@katiecollins6867
@katiecollins6867 2 ай бұрын
Thank you for your comment, this helped me with my project :)
@Ferdam
@Ferdam 2 жыл бұрын
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
@47818
@47818 2 жыл бұрын
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!
@abishekbaiju1705
@abishekbaiju1705 3 ай бұрын
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.
@bisedaniel1487
@bisedaniel1487 2 жыл бұрын
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
@ScottLee64
@ScottLee64 2 жыл бұрын
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.
@jcollins519
@jcollins519 2 жыл бұрын
, showModal(), and close()... Easy!
@wlockuz4467
@wlockuz4467 Жыл бұрын
Doesn't make sense to have to close and closeModal if they're doing the same thing
@carradee
@carradee Жыл бұрын
I made a polyfill for "dialog" several years ago, and I'm honestly glad it's *finally* outdated. It's about time.
@J3llyman
@J3llyman 2 жыл бұрын
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.
@rozneg
@rozneg 2 жыл бұрын
Amazing that it comes with that much functionality out of the box, saves a lot of time. Good job, thanks for sharing it!
@mamaburroughs3016
@mamaburroughs3016 16 күн бұрын
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
@NathanHedglin
@NathanHedglin 2 жыл бұрын
Was just looking at this. Great video and perfect timing!
@tundeakinniyi6190
@tundeakinniyi6190 2 жыл бұрын
Thanks Kevin for this. You are that special person God has given this generation. Thanks for the updates. I like your explanation always
@pyplacca
@pyplacca 2 жыл бұрын
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
@spirobel2.0 Ай бұрын
have a thumbs up sir
@mxjxn-art
@mxjxn-art 2 жыл бұрын
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"
@tflitsch
@tflitsch 2 жыл бұрын
🤯
@KevinPowell
@KevinPowell 2 жыл бұрын
You aren't the only one, lol. I've tried slowing down to make it more clear
@oliver139
@oliver139 2 жыл бұрын
Miracle! I just need this in my interview test and youtube recommend this to me!
@hovhadovah
@hovhadovah 2 жыл бұрын
This is awesome! Pleasantly surprised to see that also traps focus by default for accessibility.
@CyberTechBits
@CyberTechBits 2 жыл бұрын
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!
@bradpirochta9293
@bradpirochta9293 2 жыл бұрын
Very nice. I'm an angular developer, and it is nice to use native elements for stuff like this.
@shibazhussain2889
@shibazhussain2889 6 ай бұрын
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; }
@dragonprince08
@dragonprince08 2 жыл бұрын
The idea of native HTML modals is so cool!!!!!
@victoriakolberg9096
@victoriakolberg9096 2 жыл бұрын
I had to pause the video halfway through and subscribe to his channel. So great, thanks!
@pi11sburydoeboy
@pi11sburydoeboy 2 жыл бұрын
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!!!
@tonyrogers7101
@tonyrogers7101 2 жыл бұрын
There’s never been a better time to give Bootstrap the boot. 👢 ;-)
@sirQuilly
@sirQuilly 2 жыл бұрын
This is mind boggling - just yesterday I was searching the net for this exact solution... Thanks Kevin!
@abdulsalphan
@abdulsalphan 2 жыл бұрын
It's like he reads our mind and delivers us what we need.
@dougc84
@dougc84 2 жыл бұрын
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.
@IdleAtre
@IdleAtre 2 жыл бұрын
I am surprised there is no "for" indeed.
@GloriousCoconut
@GloriousCoconut 2 жыл бұрын
After doing on/off hobbiest web dev for like 15 years I've spent so many hours making stupid modals this changes everything forever.
@losrobbosful
@losrobbosful 2 жыл бұрын
Exactly the thing I was waiting for. Kevin saved my life again once again
@andertker4460
@andertker4460 2 жыл бұрын
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.
@StuckDuck
@StuckDuck 2 жыл бұрын
My life has been changed since this video dropped
@walkingin6375
@walkingin6375 2 жыл бұрын
Absolutely what I need right now for my project. Thanks Kevin
@heisthazey7311
@heisthazey7311 2 жыл бұрын
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.
@trplnr
@trplnr 2 жыл бұрын
I've been trying to find out how to make these and i didnt know it was this easy, Thanks!
@fabhi
@fabhi 2 жыл бұрын
Front End Friends! Yes! Great improvement
@mikhailvasilev5798
@mikhailvasilev5798 2 жыл бұрын
woooooooow awesome, my life will never be the same Thanks!!!
@karek9593
@karek9593 2 жыл бұрын
this makes things 10x easier love it
@christian-schubert
@christian-schubert 7 ай бұрын
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
@shahfaisal3923
@shahfaisal3923 2 жыл бұрын
This is one of the amazing video I've ever seen. Thanks a lot Kevin for this amazing video.
@HaNaxHeart
@HaNaxHeart 2 жыл бұрын
I havent watch the video, but I already know its gonna be awesome, love your videos.
@littlebit725
@littlebit725 Жыл бұрын
This is freaking dreamy. Thanks for sharing!
@Ana_Alien
@Ana_Alien 2 жыл бұрын
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
@dannyt503
@dannyt503 2 жыл бұрын
For JS stuff, try looking up the channel called "Fireship". He explains stuff in short easy to understand videos.
@tonyrogers7101
@tonyrogers7101 2 жыл бұрын
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.
@gabyramosita
@gabyramosita 6 ай бұрын
You explain things so well!! I'm learning and this helped a lot, thank you!
@cintron3d
@cintron3d 2 жыл бұрын
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)
@veritatas678
@veritatas678 2 жыл бұрын
I loved this new element so much that I already put it in production code :=
@DjLeonSKennedy
@DjLeonSKennedy 2 жыл бұрын
Native dialog is amazing! Thank you
@lucienchu9649
@lucienchu9649 2 жыл бұрын
Finally, it could be possible to drop MUI modal, which is pretty nice.
@pazzoeo
@pazzoeo 2 жыл бұрын
This puts such a big smile on my face
@archiem6323
@archiem6323 2 жыл бұрын
I will make this one. Thanks. Always a fan.🤗
@haekalalexander3031
@haekalalexander3031 2 жыл бұрын
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
@hiddenninja7792
@hiddenninja7792 2 жыл бұрын
amazing tutorial on how to create a popup modal. thanks a lot for the vid.
@kylevandeusen
@kylevandeusen 2 жыл бұрын
Totally nailed frontend friends on this one bud!
@keremunce1972
@keremunce1972 2 жыл бұрын
DUDE THAST SUPER EASY THANK YOU KEVIN
@bobdinitto
@bobdinitto 2 жыл бұрын
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!
@abhinayganu
@abhinayganu 2 жыл бұрын
Thanking you, I have been trying to learn practice anyway.
@soggygooseman
@soggygooseman 2 жыл бұрын
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!
@strot2103
@strot2103 2 жыл бұрын
i join the question
@josvelema2362
@josvelema2362 2 жыл бұрын
with an eventlistener on click yes you can; something like this: modal.addEventlistener("click"" , (event) => { if( event.target.className == "backdrop" ) { modal.style.display = "none"; } })
@soggygooseman
@soggygooseman 2 жыл бұрын
@@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
@josvelema2362
@josvelema2362 2 жыл бұрын
@@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.
@KevinPowell
@KevinPowell 2 жыл бұрын
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
@josesavioli3982
@josesavioli3982 2 жыл бұрын
Very useful tag! Didn't know about it
@stellanwae5050
@stellanwae5050 10 ай бұрын
You made it soooooo easy. Thanks Kevin
@DaVince21
@DaVince21 2 жыл бұрын
This is really useful functionality!
@gregtasi
@gregtasi 2 жыл бұрын
This is absolutely amazing! Had so much trouble making my own custom modals...
@thedacian123
@thedacian123 2 жыл бұрын
Awsome.There are sofisticated widgets library that have this(eg Anguular Materials) and now it is available out of the box
@Stoney_Eagle
@Stoney_Eagle 2 жыл бұрын
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 😉
@jonmayer
@jonmayer 2 жыл бұрын
This is really interesting and saves so much set up. Very cool.
@omkarp9943
@omkarp9943 2 жыл бұрын
Thanks Mr. Powell !
@user-hg8bo3em5y
@user-hg8bo3em5y 2 жыл бұрын
Wow that's really cool I didn't even this existed
@fallonmassey4714
@fallonmassey4714 Жыл бұрын
I think I'm in love 😅😅😅 *This has been a long time coming,* I hate the confirm dialog!🤨
@erikjansson1790
@erikjansson1790 2 жыл бұрын
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.
@JoeBonez
@JoeBonez 2 жыл бұрын
I think this will definitely replace the MudBlazor dialogs I’m currently using.
@ziadamer7621
@ziadamer7621 2 жыл бұрын
I am eagerly waiting for the videos to be uploaded by Professor ❤❤
@AabhusanAryalOfficial
@AabhusanAryalOfficial 2 жыл бұрын
The last time I watched your video, you said "Hello there my friend and friends" in your intro
@valentinkhoroshkov9709
@valentinkhoroshkov9709 2 жыл бұрын
Excellent! Thank you, Kevin!
@1bcx
@1bcx Жыл бұрын
In ::backdrop You can use the following method background-filter : blur(“add how many px with blur ”) i use 5px
@robertzeurunkl8401
@robertzeurunkl8401 2 жыл бұрын
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
@ashtonblignaut4565
@ashtonblignaut4565 2 жыл бұрын
Omw this is amazing! Thanks for sharing!
@the_end_boss
@the_end_boss 2 жыл бұрын
Nice tutorial with some handy tips of variations.
@aleksandr95
@aleksandr95 2 жыл бұрын
Thank you so much, Kevin!
@welling1
@welling1 2 жыл бұрын
Wow. Simple! (And I even understood the Javascript! )
@valeriousmonk654
@valeriousmonk654 2 жыл бұрын
This is revolutionary!
@chezchezchezchez
@chezchezchezchez 2 жыл бұрын
Life will never be the same.
@MrSteini124
@MrSteini124 2 жыл бұрын
So cool and simple. Thanks a ton!
@Jeer963
@Jeer963 2 жыл бұрын
OMG Thank you so much, you are my hero
@riman8493
@riman8493 2 жыл бұрын
This is awesome! :D Thanks for sharing!!
@kiddhkane
@kiddhkane 2 жыл бұрын
Very useful, thank you man!
@wvaviator3408
@wvaviator3408 2 жыл бұрын
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.
@dannyt503
@dannyt503 2 жыл бұрын
Yeah it has all the accessibility stuff baked in by default. It's great 😊
@SuperGylden
@SuperGylden 2 жыл бұрын
@@dannyt503 Unfortunately it hasn't. Yet
@dannyt503
@dannyt503 2 жыл бұрын
@@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.
@SuperGylden
@SuperGylden 2 жыл бұрын
@@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.
@KrelleTG
@KrelleTG 2 жыл бұрын
Hi Kevin, how would you go about closing the dialog by clicking outside the dialog?
@RishabhxShukla
@RishabhxShukla 2 жыл бұрын
Thanks a lot Kevin!
@pramodkumarrana8178
@pramodkumarrana8178 2 жыл бұрын
Good stuff ✨✨
@ev721
@ev721 2 жыл бұрын
Fabulous indeed!
@iSaac-kp5lk
@iSaac-kp5lk Жыл бұрын
Thank you mr powell🤝🏾
@Liootas
@Liootas 2 жыл бұрын
super as always. ty man
@nro337
@nro337 2 жыл бұрын
Awesome! Thanks for the great content!
@Morrile1
@Morrile1 2 жыл бұрын
Looks like the right type of 'notice' for skipping menus for accessibility.
@KevinPowell
@KevinPowell 2 жыл бұрын
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.787
@a.galvaop.787 2 жыл бұрын
This is gold.
@yannickleroy7419
@yannickleroy7419 2 жыл бұрын
OMG This is awesome!
@denhamk
@denhamk Жыл бұрын
super! wish they gave us the modal::backdrop - filter blur option to go with it..
@Victor_Marius
@Victor_Marius 2 жыл бұрын
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.
@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.
@adamlevoy
@adamlevoy 2 жыл бұрын
Found solution to center modal with margin auto. By default the modal is positioned absolute, top left.
@paulo_alchemist9766
@paulo_alchemist9766 2 жыл бұрын
This is so useful! Thanks.
@Pareshbpatel
@Pareshbpatel 2 жыл бұрын
Another fine job, keeping us informed on all the latest HTML/CSS trends. Very nicely explained. Thanks. Kevin {2022-03-19}, {2024-02-16}
@ShadowDrakken
@ShadowDrakken 2 жыл бұрын
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.
More HTML elements that almost no one uses (but should!)
15:47
Kevin Powell
Рет қаралды 49 М.
:has() opens up new possibilities with CSS
14:30
Kevin Powell
Рет қаралды 285 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН
Алексей Щербаков разнес ВДВшников
00:47
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 74 МЛН
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 76 МЛН
The New dialog HTML Element Changes Modals Forever
12:09
Web Dev Simplified
Рет қаралды 584 М.
React Dialogs (the right way)
15:46
Coding in Public
Рет қаралды 7 М.
Learn flexbox the easy way
34:04
Kevin Powell
Рет қаралды 700 М.
Best Way to Add Popup Modals in React
26:19
Colby Fayock
Рет қаралды 7 М.
Revealing the Differences between HTML Dialogs and the Popover API
24:14
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 8 М.
Using CSS custom properties like this is a waste
16:12
Kevin Powell
Рет қаралды 167 М.
5 super useful CSS properties that don't get enough attention
16:23
Kevin Powell
Рет қаралды 144 М.
Thinking on ways to solve DIALOG
16:07
Chrome for Developers
Рет қаралды 39 М.
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 968 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН