{"id":243,"date":"2021-01-24T14:04:10","date_gmt":"2021-01-24T14:04:10","guid":{"rendered":"https:\/\/html5accessibility.com\/stuff\/?p=243"},"modified":"2023-02-23T17:07:13","modified_gmt":"2023-02-23T17:07:13","slug":"a-simple-custom","status":"publish","type":"post","link":"https:\/\/html5accessibility.com\/stuff\/2021\/01\/24\/a-simple-custom\/","title":{"rendered":"A simple custom"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-371 size-full\" src=\"https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1.jpg\" alt=\"A smiling face obscured by a scabrous arm.\" width=\"1582\" height=\"449\" srcset=\"https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1.jpg 1582w, https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1-300x85.jpg 300w, https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1-1024x291.jpg 1024w, https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1-768x218.jpg 768w, https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1-1536x436.jpg 1536w, https:\/\/html5accessibility.com\/stuff\/wp-content\/uploads\/2021\/01\/davesmile1-1200x341.jpg 1200w\" sizes=\"auto, (max-width: 1582px) 100vw, 1582px\" \/><\/p>\n<p>For whatever reason some people don&#8217;t like the standard HTML <code>checkbox<\/code> and <code>radio button<\/code>, they seek to jazz &#8217;em up and in the process the often <em>jizz<\/em> up the usability\/accessibility of these controls.<\/p>\n<p>There are some good efforts out there to win over developers\/designers to using native controls, or minimally customized controls. Here I provide my simple variation:<\/p>\n<h2>Key coding items<\/h2>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Use of CSS <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/Adjacent_sibling_combinator\">adjacent sibling selector<\/a> to provide visible focus<\/li>\n<li>Use of <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/::before\">CSS <code>::before<\/code><\/a> to provide visual UI\/state<\/li>\n<li>Tucked <code>input<\/code> under <code>label<\/code> <code>::before<\/code> content using negative <code>margin<\/code> and hid\u00a0<code>input<\/code> visually via <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/opacity\"><code>opacity:0<\/code><\/a><\/li>\n<li>Added <a href=\"https:\/\/html5accessibility.com\/stuff\/2020\/11\/07\/not-so-short-note-on-aria-label-usage-big-table-edition\/\"><code>aria-label<\/code><\/a> to <code>inputs<\/code> and <a href=\"https:\/\/www.w3.org\/TR\/wai-aria-1.1\/#aria-hidden\"><code>aria-hidden=true<\/code><\/a> to <code>label<\/code> elements to ensure <code>::before<\/code> content <strong>is not<\/strong>, but <a href=\"https:\/\/www.w3.org\/TR\/accname-1.1\/#dfn-accessible-name\">accessible name<\/a> <em>is<\/em> announced by screen readers<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p class=\"codepen\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\" data-height=\"300\" data-theme-id=\"5390\" data-default-tab=\"result\" data-user=\"stevef\" data-slug-hash=\"poEmKXo\" data-pen-title=\"poEmKXo\">See the Pen <a href=\"https:\/\/codepen.io\/stevef\/pen\/poEmKXo\"><br \/>\npoEmKXo<\/a> by steve faulkner (<a href=\"https:\/\/codepen.io\/stevef\">@stevef<\/a>)<br \/>\non <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/cpwebassets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/3KrXfJzJlXk?start=49&amp;cc_load_policy=1\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h3>Transcript<\/h3>\n<pre>Now smile.\r\n- I beg your pardon?\r\n- Smile.\r\n- Why?\r\n- Just do it.\r\nI'm afraid I can't smile without a\r\nreason.\r\nSmile.\r\n- What's there to smile about?\r\n- Just do it.\r\nWhy?\r\nDon't ask why.\r\nWhat's there to smile about?\r\n<\/pre>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/wVku7XDtMkY\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<details>\n<summary>Lyrics<\/summary>\n<pre>If you have a friend\r\nOn whom you think you can rely\r\nYou are a lucky man\r\nAnd if you found the reason\r\nTo live on and not to die\r\nYou are a lucky man\r\nThe preachers, and the poets\r\nAnd the scholars don't know it\r\nThe temples, and the statues\r\nAnd steeples don't show it\r\nIf you've got the secret\r\nJust try not to blow it\r\nStay a lucky man\r\nStay a lucky man\r\nBecause on and on\r\nAnd on and on we go\r\nAnd it's around the world\r\nIn circles turning\r\nEarning what we can\r\nWhile others dance away\r\nThe chance to light your way\r\nSo you know that if you have a friend\r\nOn whom you think you can rely\r\nYou are a lucky man\r\nAnd if you've found the reason\r\nTo live on and not to die\r\nYou are a lucky man\r\nYou know the preachers, and the poets\r\nAnd the scholars don't know it\r\nAnd the temples, and statues\r\nAnd steeples won't show it\r\nIf you've got the secret\r\nJust try not to blow it\r\nStay a lucky man\r\nOh, stay a lucky man\r\nAnd it's around and round, and round\r\nAnd round, and round we go\r\nAnd it's around the world\r\nIn circles turning\r\nEarning what we can\r\nWhile others dance away\r\nThe chance to light your day\r\nSo it's on, and on and on\r\nAnd it's on, and on and on\r\nAround the world in circles turning\r\nEarning what we can\r\nWhile others dance away\r\nThe chance to light your day\r\n<\/pre>\n<\/details>\n<h3>Further reading<\/h3>\n<ul>\n<li><a href=\"https:\/\/24ways.org\/2018\/inclusive-considerations-when-restyling-form-controls\/\">Inclusive Considerations When Restyling Form Controls<\/a><\/li>\n<li><a href=\"https:\/\/adrianroselli.com\/2017\/05\/under-engineered-custom-radio-buttons-and-checkboxen.html\">Under-Engineered Custom Radio Buttons and Checkboxen<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>For whatever reason some people don&#8217;t like the standard HTML checkbox and radio button, they seek to jazz &#8217;em up and in the process the often jizz up the usability\/accessibility of these controls. There are some good efforts out there to win over developers\/designers to using native controls, or minimally customized controls. Here I provide [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-htmlaccessibility"],"_links":{"self":[{"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":19,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":866,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/posts\/243\/revisions\/866"}],"wp:attachment":[{"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html5accessibility.com\/stuff\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}