Best way to make this Frontend Mentor challenge accessible?
I was looking at this UI challenge by Frontend Mentor and I was wondering what would be the most accessible way to implement it?
https://www.frontendmentor.io/challenges/pricing-component-with-toggle-8vPwRMIC
The design features a toggle switch that will show different prices depending on the option that is toggled. My main question is, what would be a good way to implement the toggle switch?
I tried looking popular websites to see how they implemented similar features and it seems like every website I visit has a completely different implementation.
I’ve seen an implementation as plain buttons, radio buttons, some with role=“tab”, etc.
Thanks!
Relevant links:
https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
https://www.w3.org/WAI/ARIA/apg/patterns/switch/
Frontend Mentor
Frontend Mentor | Pricing component with toggle coding challenge
This challenge will get you thinking about building an accessible custom toggle control and also test your layout skills.
Web Accessibility Initiative (WAI)
Tabs Pattern
Accessibility resources free online from the international standards organization: W3C Web Accessibility Initiative (WAI).
Web Accessibility Initiative (WAI)
Switch Pattern
Accessibility resources free online from the international standards organization: W3C Web Accessibility Initiative (WAI).
17 Replies
for me 2 radio buttons make the most sense, it's one of the 2 options that you choose.
the annually and monthly would be the labels for these radio buttons
thats what i was thinking. and netlify seems to have implemented it that way though their implemetation is styled a bit differently
i will see if i can make a little demo
no need to trouble yourself. I'm pretty handy with CSS already. I appreciate it though!
think this would be my way to implement it
so double labels, 1 for the text and 1 for the switch
i see. so multiple labels are acceptable?
yea, can't see a reason why not
cool. i'll try to use this pattern
good luck!
i'll update here if i find any other solutions
here's my implementation https://frontend-mentor-pricing.vercel.app/
Frontend Mentor - Pricing Component with Toggle
Solution for Frontend Mentor Pricing Component with Toggle using only HTML and CSS. ZERO JavaScript.
how do people toggle something with css?
a quick answer would be fine
then i can do research
Checkboxes and/radio inputs
I used the
:has()
selector a lot with radio inputs
yes you would use checkboxes
but what do u do
Mark has an example code block above. Using labels and hiding the checkbox. There are tons of examples to research and it depends on what you're trying to accomplish. A menu button? Toggle button ? Accordion? Tabs? The opportunities are endless so its difficult to answer your question.
If you want to see my code I have the GitHub repo linked on the page