Can I Create Accessible CSS Toggle Buttons?

  ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 243,014

Web Dev Simplified

Web Dev Simplified

Π”Π΅Π½ΡŒ Ρ‚ΠΎΠΌΡƒ

CSS toggles are an incredibly common UI component, but most people just use standard checkboxes since they assume toggles are too difficult to create. In this video I will be attempting to create an accessible CSS toggle live for the first time.
πŸ“š Materials/References:
GitHub Code: github.com/WebDevSimplified/c...
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:36 - HTML
01:30 - Hide Input CSS
04:07 - Toggle Switch CSS
20:26 - Disabled CSS
#CSSToggle #WDS #CSS

ΠšΠžΠœΠ•ΠΠ’ΠΠ Π†: 178
@aayushsingh9220
@aayushsingh9220 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
It was nice to see an expert web developer struggling like we do. These small components look simple but they are super hard to make right. And I could relate to the moment when you removed the animation.
@MrGarfield
@MrGarfield 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Yeah nice to see the struggle we have sometimes, so we are not alone πŸ™‚
@nolannoble6323
@nolannoble6323 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@MrGarfield I’m on jn non &9’ko
@Ankit-ov4yc
@Ankit-ov4yc 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
πŸ‘
@luispato9335
@luispato9335 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I really love your JS videos!!! πŸ˜ƒ I also had to implement an accessible toggle component a couple of days ago, so here are a couple of tips / ideas: - Don't use the label to create the switch UI. It would be nicer to decouple the input and the label. To do that you can add css "appearance: none" to the input, and then you can style it like you would any other element (even use ::before and ::after on the input itself) - If we really want to make it accessible, adding a 'role="switch"' to it would be a nice improvement. - another accessibility tip is that users tabbing through the page don't really need to be able to focus both on the input and on the label (that is actually confusing). You can add an 'aria-hidden' attribute to the label and then add the aria-labelledby attribute to the input (pointing to the label) so it still gets the correct description on assistive technologies - If you use the input instead of the label, you will get automatically the correct "on" / "off" states for assistive technology users - it would be nice to add those transitions only for users that don't have the "prefers-reduced-motion" turned on Sorry if this feels like i am criticizing your video. that isn't my intention. I did a lot of research on this topic and i am just happy to share what i have learned and to make the web a little bit more accessible. People like you have a lot of viewers and can reach a lot of webdevelopers, so if you can get them interested in accessibility i think it is GREAT! Thanks :)
@erickbonk
@erickbonk 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
As I was watching the video I thought about those things as well, I would also add the fact that those colors don't have a great contrast red on red and green on green. But you really said everything I wanted to say. I am glad more content creators are getting into a11y lately, the industry seriously needs more accessible websites so I appreciate this video a lot.
@natalieeuley1734
@natalieeuley1734 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks for these extra tips! Bumping this so more can see it :)
@MrHerbalite
@MrHerbalite 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks, I've combined trhis tutorial with your acccessibhility tips into one. Works superb. I've added CSS variables to make it super easy to customize. sizes, color,s light and dark mode There is one thing that needs mention, in terms of sizes. Using CSS calc() all of the dimensions can be automated. To make it work proper, instead of useding em I had to use rem. Now accessibilty is perfect for my use case.
@bjoernuhlig
@bjoernuhlig 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Just adding to what people said before, I am not trying to repeat what was said, just to add to the justification of some of the proposed solutions and add some reasoning (disclaimer: I am a web-accessibility tester). I like your content, and I dont want to sound overly critical. I am quite happy that devs are starting to pay more attention to a11y, as there are more and more laws compelling us to be more compliant. Yet, I do actually want to highlight more stuff, because digital accessibility needs to be done right to be helpful to the people needing it. If you build custom UI a lot can break and actually make things less accessible. - Zoomfactor and the focus highlight: As was pointed out before: using focus-visible instead of focus is the solution to resolve the flashing focus highlight when clicking the element. Adding to this and explaining why the zoom factor alone is not suficient: "Normal zoom is smaller, it should not be a problem anymore." This is not true. Users with visual impariments often use very high zoom factors, 200% and more. It is a problem, and there is the easy solution with focus-visible. - Color Contrast: Was mentioned by ProGamer before. It is not just "not great contrast", it fails by wcag AA standards: webaim.org/resources/contrastchecker/?fcolor=81E052&bcolor=E0F7D4&api (and it fails for all three, green on green, red on red, and grey over white). Adding to Color: If u use a chrome browser you can emulate the deuteranpopia (r-g-colorblindness) settings: Developer Tools -> Settings -> More Tools -> Rendering -> "Emulate vision deficiencies" -> Deuteranopia, and see the issue with using red and green als indicators. This is actually still okay here. Because the information is conveyed by more than just color alone. By form and by the symbol. It should be conveyed by text as well, I mean a role and a status (checked / unchecked) which indicates to Screen reader users the state and the role of the element. - Adding a role was mentioned before as well. This is important for screen readers. I am not sure about role="switch", it might be enough. I would propose to use aria-checked="false" and role="checkbox" including a function to toogle the status. See: www.w3.org/TR/wai-aria-practices-1.1/examples/checkbox/checkbox-1/checkbox-1.html - When building a custom UI all the inherent semantics of HTML5 are lost because HTML5 is not used. These semantics are by default accessible. If you do not use them, you have to painfully recreate the. Considers this when implementing custom UI. I am not saying to not do it. Just be aware. - Before and After are problematic for adding content. They are not accessible if non-decorative content is added. The Checkmark symbol and the Multiplication x are not just decorative. They convey meaning. Browsers and AT (assistive technologies) interact differently with before and after. CSS must be disabled sometimes and meaningful content should then remain visible and in place. MacOS' VoiceOver Screen Reader will read out the content elements (in Firefox, not in Chrome, as another user also pointed out already): "Checked, Multiplication x" or "Checked, Checkmark". This might add confusion.
@luispato9335
@luispato9335 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@bjoernuhlig the role=switch already adds the on/off state (different from checked/unchecked), which are read by assistive technologies. The other points you mention are important and i think you explained them well! :)
@vineethtrv
@vineethtrv 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I am surprised to see this. I feel really honoured that you have used my Codepen as reference. More than happy. Thank you
@flow7502
@flow7502 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Nicely done bro
@vineethtrv
@vineethtrv 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@flow7502 thank you
@nemethricsi
@nemethricsi 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Great vid Kyle! One more subtle thing I like to do at disabled state is: cursor: not-allowed
@CirTap
@CirTap 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
nice one! Use an offset of `-101vw` to move the checkbox off the screen - *any* screen (even one that's 10000px wide) and there's no need to bother for the top value. For better a11y add `role="switch"` instead of class .toggle and use its attribute selector: you now only get a fancy toggle if it's also accessible :) -- the two birds, one stone thing. For the :disabled state I'd add `pointer-events:none` and `cursor.default` to the label, that makes the whole pack unclickable and finaly: to dim the :disabled colours you can also try filter: grayscale(1) and/or saturate(0), depends on the actual colours.
@bobsonwong9422
@bobsonwong9422 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
I experimented with -100%, and it seems to work. Could there be a potential problem that I'm not aware of?
@CirTap
@CirTap Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
@@bobsonwong9422 percentages always refer to the parent element's own width which may not be wide enough for an "off screen" position. If that parent is also somehow moved to the opposite direction (a right sidebar) then your "starting point" would be off, especially if that parent has a position:relative. vh always refers to the absolute width of the screen so it's value is typically large enough to move things out of the away even if the (relative positioned parent is located at the very right edge of the screen.
@bobsonwong9422
@bobsonwong9422 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
@@CirTap Oh yeah! That totally didn't occur to me because I was just adding the toggle to the . Thanks for the insight. :)
@aprilwarren5511
@aprilwarren5511 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
It's really nice seeing you keep accessibility in mind, so many UKposts tutorials (and post secondary institutions) neglect accessibility entirely, which is both a shame, and a now crime here in Canada. Great work!
@jjfattz
@jjfattz 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I would also add "user-select: none;" to the labels so that the text doesn't highlight when toggling. Very nice tutorial.
@aram5642
@aram5642 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I wonder if that selection blinking can be heard in screen readers "selection made!".
@U20E0
@U20E0 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@aram5642 that could be a problem…
@leo_leo814
@leo_leo814 4 місяці Ρ‚ΠΎΠΌΡƒ
I think it's the best practice to create a toggle checkbox that i've ever seen, thanks a lot
@devwithbrian1534
@devwithbrian1534 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Thanks Kyle. Always appreciate the way you deconstruct problem solving
@jasonji1152
@jasonji1152 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hey man, great content. Learned a lot from it. 4:50 The reason it didn't work is because you didn't set the `display` property on the pseudo element. Elements by default has a `display` of `inline`, and setting `width` on inline elements has no effects. The width of inline elements will always fit its content (empty string in your case, hence width of 0). Your giving its wrapper element a `display: flex` works because children of flex-ed parent will behave like block elements no matter what is set on them. Add `display: inline-block` to the pseudo element is best for your case.
@bhavyajain638
@bhavyajain638 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thankyou. I was wondering why did making flex affect the pseudo child. This solves it.
@ThijmenCodes
@ThijmenCodes 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This video definitely didn’t feel like 24 minutes! Well spoken, good pace - thanks!
@izyo8146
@izyo8146 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Well said! it felt like 3 minutes, regardless of me watching on 1.75x speed πŸ˜‚
@TheDicampos
@TheDicampos 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I love this video, its very nice to see an expert dealing with "normal" problems haha
@Rocadamis
@Rocadamis 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I'm sure you see now that at 19:42 you didn't replace the "forward" direction, which is why it wasn't fading.
@briannnnnnnnnn1037
@briannnnnnnnnn1037 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
i was screaming over here loool
@matizbrave
@matizbrave 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Great tutorial. The only remark i have is that whenever a problem arose your reaction basically was: ok, welp, let's move on. I'm well aware that those small issues are sometimes really hard to debug, but things like that happen all the time and you, as a tutor, should teach how to deal with them (like you mentioned at the begining of this video).
@MrGarysjwallace
@MrGarysjwallace 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I agree, it’s nice to see Trav go through what we go through with CSS. Backend is cool ( functions/classes: using Java or Python) for data, but the front-end is what the user sees. -without the frontEnd, there’s no API happening.
@hariskhanzada7507
@hariskhanzada7507 6 місяців Ρ‚ΠΎΠΌΡƒ
Hats off for detailed explanation and Great Tutorial, I implemented it and worked great, Thanks Man !
@daanduvillier8803
@daanduvillier8803 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Thanx so much for this video! Just what I was looking for. Love the way you thoroughly explain things!
@albiummid
@albiummid 6 місяців Ρ‚ΠΎΠΌΡƒ
Amazing approach within CSS. Just ❀ πŸŽ‰
@MarioKreeft
@MarioKreeft 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
very, very helpful method of explaining this, thank you!
@samhaze9688
@samhaze9688 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks for this awesome video!
@Sortexx
@Sortexx 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks again Kyle!
@bon9010
@bon9010 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Great video! I would also love to see you create your own textbox from scratch
@Derek_Pixel
@Derek_Pixel 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
These are my favourite of your videos :)
@CalebHesse01
@CalebHesse01 3 місяці Ρ‚ΠΎΠΌΡƒ
There is something extremely satisfying about slider checkboxes.
@torrex4
@torrex4 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Nice explanation
@martoten
@martoten 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Good one! I'm guessing the problem with transition that was somehow weird was that the only moment the content changed was at 100%, that means that from 0% to 99.99% of the keyframes the content was still an X and then at final keyframe it switched to a checkmark. I'm not sure, I haven't code for a while but hopefully it makes sense. Cheers everyone!
@omarmahat2924
@omarmahat2924 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I love your videos and how you elaborate your tutorials, you've helped me out so much, can you please make javascript tutorials for beginners from the start covering every topic like you did with css. Thank you
@joelkronqvist6089
@joelkronqvist6089 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This was both entertaining and educational, thank you! Just curious, can you fix that blinking outline by modifying the selector so that it matches the checkbox's ::before also when the focus is on the label?
@HorizonHuntxr
@HorizonHuntxr 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Wouldn't "left: -100vw" and "top: -100vh" be a better way to ensure that the checkbox is never on the page? That way no matter what the viewport size becomes it'll never appear on screen
@TheZmthall
@TheZmthall 9 місяців Ρ‚ΠΎΠΌΡƒ
A simple fix to the outline on click looking weird each click is to use: input[type="checkbox"].toggle:focus:not(:focus-visible) + label::before { outline: none; } This will remove all focus styles for non keyboard focus. This wouldn't affect the accessibility due to the fact that the button can still be highlighted with keyboard and the effects on the button when using the mouse stay the same so it's noticeably toggleable. 😁
@arturmoreira9716
@arturmoreira9716 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Awesome my brother πŸ‘πŸΌπŸ‘πŸΌπŸ‘πŸΌπŸ‘πŸΌπŸ‘πŸΌ
@CreativeTutorialsWeb
@CreativeTutorialsWeb 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Amazing video πŸ‘πŸ˜
@e11e7en
@e11e7en 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Thanks for the video! πŸ™ Thought I would request a tutorial for an accessible hamburger menu with pure css and html. Again, love your videos, very well done!
@Asasino21
@Asasino21 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Amazing video
@jerryfalkman640
@jerryfalkman640 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hi Kyle, Can you tell me what editor you are using for your videos. I would like to see the real-time changes as I modify my code. Thanx
@pneujai
@pneujai 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
5:54-7:17 he was following my mind, doing things i was thinking!
@freinheit6923
@freinheit6923 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
thanks dude
@deepshah234
@deepshah234 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Your content is awesome!! Btw can u make a video on how to make custom toasts in website?
@simpingsyndrome
@simpingsyndrome 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
use right: 0; to move the circle to far right, and we can still use display:none to interact w/the checkbox,love your tips πŸ‘πŸ»πŸ‘πŸ»
@nemethricsi
@nemethricsi 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I believe you cannot tab into the checkbox if you use display: none so it would be inaccessible
@christianjansson6806
@christianjansson6806 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Wow, CSS has always been like black magic to me, but you really broke it down perfectly - it all makes sense! But, I guess it takes a couple of hours to learn all syntax and available commands?πŸ™‚
@MysticWhiteDragon.
@MysticWhiteDragon. 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I used a checkbox and CSS only to create a side out menu with similar methods. Glad to see people use pure CSS rather than doing fluky stuff with jQuery when unnecessary.
@mrclips999
@mrclips999 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I LOVE IT❀❀
@neelabhdutta6691
@neelabhdutta6691 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
How can we create a keyboard navigation( up/down arrow keys) of a list, please create a video on this ?
@VirtualDarKness
@VirtualDarKness 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
2:12 why not use display none and handle the interaction with the label? (e.g. having the input inside the label)
@ladis_aka_ladyz
@ladis_aka_ladyz 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
2:06 I'm pretty sure you can interact with "display: none;" checkbox just fine. I haven't watched the entire video yet, but the ":checked" label coloring works and I assume all the other things will be positioned relatively to the label, as you moved the input out of the page anyways.
@alexandrsachishin962
@alexandrsachishin962 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
it won't work with screen readers, such as element with zero height and width might be hidden for them
@sheepforwheat
@sheepforwheat 6 місяців Ρ‚ΠΎΠΌΡƒ
You're the man
@ChannelN11
@ChannelN11 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Kyle will you please make a tutorial on window.indexedDB? I'm new to this kind of a database and the documentation is so opaque...
@darcipeeps
@darcipeeps 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
To make more β€˜accessible’, could make the text more bold and disabled box visually different besides color
@damiansabadsag2530
@damiansabadsag2530 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
what extension is which shows you what to write in animation
@matheotitakis
@matheotitakis 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Is it good instead of absolute positioning the input just give it a width and height of 0?
@jayaprakash933
@jayaprakash933 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hey kyle can you make video of , contact syncing? I have been working with the IONIC + React project. It become really confusing to handle contact syncing. I don't know how famous apps like Whatsapp, Telegram syning the user contacts. There are so many questions how to detect contact changes in realtime, how to know if your is deleted the contact, how to know if my friends installed the app. Make my development process simple. Thank you...
@usmanasghar8779
@usmanasghar8779 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Awesome πŸ‘
@giahuyha6189
@giahuyha6189 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
even with dispkay none, the checked still trigger when you click its label
@Marjolein_1979
@Marjolein_1979 9 місяців Ρ‚ΠΎΠΌΡƒ
I made a toggle button using the label of a checkbox, as shown in the video. Does anyone know how to enable keyboard-only users to toggle the button? I made it possible to focus on the toggle button using the tab key, but once in focus, it can't be interacted with using the keyboard.
@hjetwd
@hjetwd 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
outline should not be shown when you click on an element with the mouse. you have it, you know what's different :focus, :focus-within & :focus-visible ? :focus - any focus, even from the mouse (that's why you have this black outline shown, although this is not normal). :focus-visible - only Tab on the keyboard (wow! such a miracle exists?). :focus-within is the same as :focus, but with all child elements, any of them will be in focus, the style will be applied to the parent. try replacing :focus with :focus-visible p/s/ good video, release more =)
@def_NaN
@def_NaN 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
just out of curiosity, why did you go for a checkbox over a range input?
@alexandrsachishin962
@alexandrsachishin962 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
add please aria-label and aria-disabled for better accessibility: screen readers see disabled control but better to use aria-disabled in these cases. and aria-label could help to understand the meaning of a switch, because usual word "checked?" gives no information about the control purpose
@sparkedit9819
@sparkedit9819 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
i am creating a website where users can upload photos so what should i use ? firebase or sql ?
@saktipujoedi113
@saktipujoedi113 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hi can you make a redux vs recoil comparison video? Nice video btw.
@doronsages983
@doronsages983 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
awesome video, but I gotta say if you'd user-select: none and remove that border color on focus, it would look much better
@ashley_engle
@ashley_engle 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Only stopped in to answer your question. Yes, you can do anything you put your mind to πŸ§πŸ˜‰πŸ’•
@XILikeTrainsX
@XILikeTrainsX 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
While setting top and left should do the trick, couldn't you just z-index the page to a positive while putting the checkbox to -1 or something?
@themalmana
@themalmana 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Is it normal to move an element far off the page for hiding it?
@riflan0ahmed
@riflan0ahmed 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
How are you remembering the color?
@wilco1334
@wilco1334 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Just a note here, that for screen readers that X and checkmark are going to show up. Probably best not to use them that way. You may want to install the axe accessibility linter too. It might find that duplicate ID problem you had.
@TribalHeartMusic
@TribalHeartMusic 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I mean honestly, using fully CSS toggles is not good in general, it's messy and it completely ignores the separation of concerns, it's just a challenge, at least that's how I see it
@aram5642
@aram5642 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
As always great to watch your videos, there's always something interesting in there. But (sorry if I ruin the party) IMO messing around with form controls is as bad as messing with scrolling. It needs much more attention and thought. This specific switch design is very unfortunate and has been promoted by Material Design. It tries to resemble the physical switches on real devices, but these usually have two (or more) labels that clearly describe all possible states. I actually think your first idea to remove the indicator on disabled state was correct. By leaving it in place you ended up having a disabled state that - to the eye of a color-blind user - hardly differs from not disabled. I would really appreciate a video where you actually test this checkbox accessibility with a screen reader, and impairment simulator. Thanks.
@amirrezaranjbar2853
@amirrezaranjbar2853 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I’ve started learning react, but I’m so lost in the area of state management. I’ve pretty much tried every state management library but I still don’t know which one is the right one. I would really appreciate it if you make a video on it and tell which one you use.
@snoowwe
@snoowwe 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
If you're learning react you DEFINITELY don't need a state management library. I use React for a living and I don't even use a state management library. So far the context API has been more than enough.
@amirrezaranjbar2853
@amirrezaranjbar2853 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
@@snoowwe you’re absolutely right, but I have a special use case where I’m making a chess game and I need to update the squares that need updating, but at the same time I need to be able to update all of the squares at once and I have really been struggling to find a good way to achieve both.
@kiwicrafter
@kiwicrafter 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I would like to add a Like button on my website, I have been playing with it, I have two thumbs up images, one plain and one green, I am working on collecting their IP address so that when they come back to that page, it already shows they have hit the like button., any help to be found for this?
@13caban
@13caban 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
sometimes "label" is wrapped around "input", I have experimenting with such format, but it does not work. Any hints ?
@The_Auslander
@The_Auslander 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
why not use appearance none? on the checkbox instead of opacity and negative positions?
@muskaka1268
@muskaka1268 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I like video with mistake and thoughts process.. Make us look normal with our mistake
@ChanyArpin
@ChanyArpin 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I would probably have used appearance: none; and apply the toggle appearance on the input directly. I would have also used role="switch" on the input.
@oliviacinnamon5060
@oliviacinnamon5060 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Why we cannot do this using simple divs and translations? It's better practice this way?
@jackgreenearth452
@jackgreenearth452 Π Ρ–ΠΊ Ρ‚ΠΎΠΌΡƒ
Shouldn't the height of the after element be halved as the margin left isn't shared, but the margin top and bottom are only half as big as the margin left as they are shared between the height property.
@genechristiansomoza4931
@genechristiansomoza4931 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Nice. Pure css custom checkbox. That's very reusable.
@EnricoColautti
@EnricoColautti 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
For accessibility you should add attributes aria-labelledby and aria-checked and handle keydown events
@WebDevSimplified
@WebDevSimplified 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This should already all be handled by the input element and label element.
@skillzorskillsson8228
@skillzorskillsson8228 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
You should probably set user-select to none on the labels too. Its pretty annoying when it highlights the text when you click on the label
@grinsk3ks
@grinsk3ks 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Pretty sure the page would scroll to the top every time you click the toggle. If you interact with an input the browser Scrolls it into view. If the input is at -9000 the browser should scroll top.
@__Phederal__
@__Phederal__ 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
My Boiiiiiiii
@speedy-b
@speedy-b 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Toggle Kyle's hair with accessibility
@DuyTran-ss4lu
@DuyTran-ss4lu 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Great
@tuccig9289
@tuccig9289 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
and then there’s me who doesn’t know 75% of the css properties
@TheVideogamemaster9
@TheVideogamemaster9 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
lol I have that exact same mindset where I try something, it doesn't work as I expected despite my code likely being correct, and then just going "bah, I don't need it anyway!" XD
@mayankpratap9634
@mayankpratap9634 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Pleaseake these type of videos
@geforcesong
@geforcesong 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
i tried, display:none works as well, don't need -9999px to hide the control
@mat5844
@mat5844 3 місяці Ρ‚ΠΎΠΌΡƒ
There isn't a quicker/ leaner way to do this? No hate to him AT ALL, on the contrary. I'm just mind blown. I'm still a baby in js, isn't there a better way to do code toggles? Genuine question. πŸ™πŸ»
@TheOne-qv3xw
@TheOne-qv3xw 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Bro Big Bro Please i am the Who always click Like Button Before watching i know you always create awsome video Actually i want to know LIke in donwload we got progress baar how much is downloaded etc But in api call it is download behind and just come in folder directly when download completed so From api how i can get progress or completion report of download or api response in simple word progress info of api response is it possible
@AZHARakaGoat
@AZHARakaGoat 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
That is exactly what we want to smashhhhhh subscribe buttonnnnn!!!!!-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@nivkor6671
@nivkor6671 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
The left/top: -9000px looks like an aweful idea. I'd just use pointer-events: none
@parikshitrawat8680
@parikshitrawat8680 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
20:08 relatable
@_jb5261
@_jb5261 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
This is really cool. With just that little html
@amansharma7865
@amansharma7865 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
CSS God
@Ankit-ov4yc
@Ankit-ov4yc 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Best
@webjohn
@webjohn 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Hey, i tried this a couple days ago myself. This can be done much much easier using a simple library like AlpineJS, just take a Button element with role="switch", x-on:click="checked = !checked" x-bind:aria-checked="checked" and give it a aria-labelledby property. Then you can style it just how you want without bothering with pseudo elements and absolute positioning. A neat trick to do the animation (left-right) by having a flex container with justify-content: end with two elements: 1. your circle, 2. a random span element with flex: 1 property based on the state of the widget. thats it you got a accessible toggle switch without bothering with absolute positioning or any of that. Just think it is cleaner that way
@Mike-tb2hw
@Mike-tb2hw 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
I think the reason the animation wasn’t working at 20:00 was because you put β€˜reverse’ and forgot to delete β€˜forwards’
@stephen5187
@stephen5187 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
The entire dragonball fanbase is disappointed that you dind't put the initial checkbox 9001px off the page.
@eset
@eset 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Very good video but I just can't get over the small misalignments
@abulazaiemabas5070
@abulazaiemabas5070 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Never heard of user-select ?
@sitedel
@sitedel 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
Having several checkbox with the same name will post sn array instead of a single value. Sometimes this is the expected behavior when these checkbox are set for each row of a table. But... this array will not contain any disabled checkbox !
@Curlack
@Curlack 2 Ρ€ΠΎΠΊΠΈ Ρ‚ΠΎΠΌΡƒ
All of this will break if there is no label or the label is not directly after the input
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 876 тис.
Creating a CSS-Only Toggle Switch (Custom Checkbox) - Tutorial
13:40
dcode
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 17 тис.
didn't want to let me in #tiktok
00:20
Анастасия Варасова
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 8 ΠΌΠ»Π½
Moyens bizarres et cool de faire entrer des bonbons sans se faire prendre
00:40
Mini-mimi
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 27 ΠΌΠ»Π½
Learn Every CSS Selector In 20 Minutes
19:38
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 432 тис.
Can I Create Online Tutorial’s Magic CSS Indicator?
1:04:16
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 92 тис.
Incredible scroll-based animations with CSS-only
32:23
Kevin Powell
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 318 тис.
10 Tailwind Classes I Wish I Knew Earlier
13:31
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 151 тис.
How This Test Saved Kent’s Site
7:04
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 44 тис.
You might not need useEffect() ...
21:45
Academind
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 132 тис.
You Suck At Accessibility (But You Don't Have To)
13:23
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 50 тис.
CSS Tips And Tricks I Wish I Knew Before
12:12
Lama Dev
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 394 тис.
Can I Create This Simple CSS Hover Animation?
41:41
Web Dev Simplified
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 114 тис.
Learn CSS Animations In 20 Minutes - For Beginners
21:22
Slaying The Dragon
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 911 тис.
didn't want to let me in #tiktok
00:20
Анастасия Варасова
ΠŸΠ΅Ρ€Π΅Π³Π»ΡΠ΄Ρ–Π² 8 ΠΌΠ»Π½