All Projects → scottaohara → aria-switch-control

scottaohara / aria-switch-control

Licence: MIT license
ARIA Switch control component

Programming Languages

HTML
75241 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aria-switch-control

van11y-accessible-hide-show-aria
ES2015 accessible hide-show system (collapsible regions), using ARIA
Stars: ✭ 34 (-10.53%)
Mutual labels:  a11y, aria
A11y tooltips
Accessible Tooltip Component
Stars: ✭ 35 (-7.89%)
Mutual labels:  a11y, aria
Js Offcanvas
A lightweight, flexible jQuery off-canvas navigation plugin which lets you create fully accessible sidebar or top/bottom sliding (or push) panels with keyboard interactions and ARIA attributes.
Stars: ✭ 272 (+615.79%)
Mutual labels:  a11y, aria
alfa
♿ Suite of open and standards-based tools for performing reliable accessibility conformance testing at scale
Stars: ✭ 75 (+97.37%)
Mutual labels:  a11y, aria
Skin
Pure CSS framework designed & developed by eBay for a branded, e-commerce marketplace.
Stars: ✭ 126 (+231.58%)
Mutual labels:  a11y, aria
jquery-accessible-modal-window-aria
jQuery simple and accessible modal window, using ARIA
Stars: ✭ 61 (+60.53%)
Mutual labels:  a11y, aria
jquery-accessible-simple-tooltip-aria
jQuery accessible simple tooltip window, using ARIA
Stars: ✭ 22 (-42.11%)
Mutual labels:  a11y, aria
van11y-accessible-simple-tooltip-aria
ES2015 accessible simple tooltip, using ARIA
Stars: ✭ 22 (-42.11%)
Mutual labels:  a11y, aria
Accordion
Accordion module created in pure javascript & CSS. Very useful to create FAQ lists on your website.
Stars: ✭ 94 (+147.37%)
Mutual labels:  a11y, aria
Accessible Html Content Patterns
♿️ The full HTML5 Doctor Element Index as well as common markup patterns for quick reference.
Stars: ✭ 93 (+144.74%)
Mutual labels:  a11y, aria
jquery-accessible-carrousel-aria
jQuery Accessible Carrousel System, using ARIA
Stars: ✭ 40 (+5.26%)
Mutual labels:  a11y, aria
Eslint Plugin Jsx A11y
Static AST checker for a11y rules on JSX elements.
Stars: ✭ 2,609 (+6765.79%)
Mutual labels:  a11y, aria
a11y-accordion-tabs
A script for an accessible accordion tabs component
Stars: ✭ 50 (+31.58%)
Mutual labels:  a11y, aria
enabler
✋ Accessibility analyzer for your frontend.
Stars: ✭ 19 (-50%)
Mutual labels:  a11y, aria
aria-collapsible
A lightweight, dependency-free JavaScript module for generating progressively-enhanced collapsible regions using ARIA States and Properties.
Stars: ✭ 25 (-34.21%)
Mutual labels:  a11y, aria
Accessible components
Listing of accessible components & patterns
Stars: ✭ 393 (+934.21%)
Mutual labels:  a11y, aria
aria-at
Assistive Technology ARIA Experience Assessment
Stars: ✭ 115 (+202.63%)
Mutual labels:  a11y, aria
Van11y Accessible Tab Panel Aria
ES2015 accessible tabs panel system, using ARIA
Stars: ✭ 58 (+52.63%)
Mutual labels:  a11y, aria
Accessible modal window
Accessible modal dialogs
Stars: ✭ 196 (+415.79%)
Mutual labels:  a11y, aria
Creatability Components
Web components for making creative tools more accessible.
Stars: ✭ 248 (+552.63%)
Mutual labels:  a11y, aria

ARIA Switch Control

Similar to a toggle button or checkbox, a switch control is meant to be used when its visual appearance most resembles an "on and off" "switch".

The expected user experience of a switch control is for an immediate action to take place. For instance, toggling a light/dark theme for a website or application, where the change should instantly take effect.

A checkbox, which is often found within a form, or in other UI where multiple elements can be checked, may not be understood to enact an immediate change to other elements or content in the document/screen. That's not to say additional information couldn't be presented to the user to indicate such functionality for a checkbox, but it's not a standard expectation.

A toggle button and switch are a bit more similar in that they both have an expectation for an immediate change from user interaction. Their primary differences revolve around the manner in which they are supposed to communicate state to assistive technology users, as well as the visual design they each may be most associated with.

A toggle button is typically announced as "pressed" or "selected" in its active state, where a switch should be announced as "on".

How does it work?

The baseline for this component requires one of the following markup patterns:

Start as a <button>

<button type="button" data-switch class="class_here" disabled>
  <!-- Meaningful label here -->
</button>

Start as a checkbox

<label class="class_here">
  <input type="checkbox" data-switch>
  <!-- Meaningful label here -->
</label>

Start as a generic element

For instance, such as a <div> or <span>.

<span class="class_here" data-switch hidden>
  <!-- Meaningful label here -->
</span>

Initial Attribute Breakdown

data-switch is required for each markup pattern to be successfully transformed into a role="switch". All setup and functionality is based around this attribute. The attribute can be set without a value, to default a switch to the "off" state. Setting the value to "on", e.g., data-switch="on will default the switch to the "on" state. Note: if using a checkbox as the base markup element, and the checked attribute will also set the switch to be "on" by default, even if data-switch has no value.

You may notice that examples which do not have a checkbox base element have a default disabled or hidden attribute. This is due to the fact that these versions of the switch will not function without JavaScript. Rather than rendering a partially created that doesn't function, they can instead be disabled (for a <button>) or hidden for elements which would not expose or allow the disabled attribute.

If for some reason a switch should be disabled on initial load, use the data-keep-disabled to stop the script from removing the disabled (aria-disabled) or hidden attributes.

Attributes added by JavaScript

The JavaScript will add a role="switch" to the element with data-switch.

If the switch is not built from a base checkbox, an aria-checked attribute will be added to communicate the current state of the switch. If the base element is a checkbox, then the native checked attribute and the dirty checked state of the element will be used instead. It is not necessary, nor valid, to use an aria-checked attribute on a native checkbox or radio button.

Screen Reader Quirks

Rather than updating this information in multiple places, please review the breakdown of screen reader issues with role="switch". While this particular link goes to an example of using role=switch on a checkbox, the same issues occur if using role=switch on a <button> element as well.

Note: With the release of iOS 12.2 (March 2019) the announcement of state has been fixed. VoiceOver will still announce role="switch" as checkboxes, but at least the checked/unchecked states are correctly exposed.

License & Such

This script was written by Scott O'Hara.

It has an MIT license.

Do with it what you will :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].