All Projects → scottaohara → aria_disclosure_widget

scottaohara / aria_disclosure_widget

Licence: MIT license
Progressively enhanced hide/show content areas with vanilla JS & appropriate ARIA attributes

Programming Languages

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

Projects that are alternatives of or similar to aria disclosure widget

Van11y Accessible Tab Panel Aria
ES2015 accessible tabs panel system, using ARIA
Stars: ✭ 58 (+152.17%)
Mutual labels:  accessibility, aria
Aria Query
Programmatic access to the ARIA specification
Stars: ✭ 129 (+460.87%)
Mutual labels:  accessibility, aria
Accessible Html Content Patterns
♿️ The full HTML5 Doctor Element Index as well as common markup patterns for quick reference.
Stars: ✭ 93 (+304.35%)
Mutual labels:  accessibility, aria
Accessible components
Listing of accessible components & patterns
Stars: ✭ 393 (+1608.7%)
Mutual labels:  accessibility, aria
jquery-accessible-simple-tooltip-aria
jQuery accessible simple tooltip window, using ARIA
Stars: ✭ 22 (-4.35%)
Mutual labels:  accessibility, aria
A11y tooltips
Accessible Tooltip Component
Stars: ✭ 35 (+52.17%)
Mutual labels:  accessibility, aria
Skin
Pure CSS framework designed & developed by eBay for a branded, e-commerce marketplace.
Stars: ✭ 126 (+447.83%)
Mutual labels:  accessibility, aria
enabler
✋ Accessibility analyzer for your frontend.
Stars: ✭ 19 (-17.39%)
Mutual labels:  accessibility, aria
Creatability Components
Web components for making creative tools more accessible.
Stars: ✭ 248 (+978.26%)
Mutual labels:  accessibility, aria
Eslint Plugin Jsx A11y
Static AST checker for a11y rules on JSX elements.
Stars: ✭ 2,609 (+11243.48%)
Mutual labels:  accessibility, aria
Vue Simple Suggest
Feature-rich autocomplete component for Vue.js
Stars: ✭ 324 (+1308.7%)
Mutual labels:  accessibility, aria
aria-at
Assistive Technology ARIA Experience Assessment
Stars: ✭ 115 (+400%)
Mutual labels:  accessibility, 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 (+1082.61%)
Mutual labels:  accessibility, aria
Accessibility Checklist
Stars: ✭ 41 (+78.26%)
Mutual labels:  accessibility, aria
van11y-accessible-hide-show-aria
ES2015 accessible hide-show system (collapsible regions), using ARIA
Stars: ✭ 34 (+47.83%)
Mutual labels:  accessibility, aria
Accordion
Accordion module created in pure javascript & CSS. Very useful to create FAQ lists on your website.
Stars: ✭ 94 (+308.7%)
Mutual labels:  accessibility, aria
jquery-accessible-modal-window-aria
jQuery simple and accessible modal window, using ARIA
Stars: ✭ 61 (+165.22%)
Mutual labels:  accessibility, aria
a11y tab widget
Accessible Tab Widget built with ARIA
Stars: ✭ 25 (+8.7%)
Mutual labels:  accessibility, aria
Accessible modal window
Accessible modal dialogs
Stars: ✭ 196 (+752.17%)
Mutual labels:  accessibility, aria
tailwindcss-aria-attributes
TailwindCSS variants for aria-* attributes
Stars: ✭ 92 (+300%)
Mutual labels:  accessibility, aria

ARIA Disclosure Widgets

A disclosure widget consists of a trigger (<button>) that toggles the hidden state of its associated content.

Check out the demo page for markup patterns and variations.

How does it work?

Use either a <disclosure-inline> (for display: inline-block) or <disclosure-block> (for display: block) custom element wrapping element.

Whichever wrapping element used, it MUST contain a <disclosure-content> element. This element represents the content you want to show/hide.

The minimal expected markup pattern for this script to work is as follows:

<disclosure-block> <!-- or disclosure-inline -->
  <disclosure-content>
    ...
  </disclosure-content>
</disclosure-block>

The trigger

A <button> element to toggle the <disclosure-content> will be auto generated by the script. Use the data-trigger attribute on the <disclosure-inline> or <disclosure-block> element to provide this element a visible label and its accessible name. If the data-trigger attribute is not specified, the generated <button> will render a fallback label of "More info".

<disclosure-inline data-trigger="Unique name goes here">
  <disclosure-content>
    ...
  </disclosure-content>
</disclosure-inline>

If you want more control over the placement of the generated <button> element, and thus also include additional structured and semantic content to your disclosure widget, then you can use the data-insert-trigger to specify the element where the <button> will be generated. The content of the chosen element will become the content of the <button> element.

<disclosure-block>
  <h5 data-insert-trigger>
    <img src=... alt>
    <span>Visible text label</span>
  </h5>
  <disclosure-content>
    ...
  </disclosure-content>
</disclosure-block>

Per the above markup, the <button> will be insterted into the <h5> element. The resulting markup will render as follows:

<h5 ...>
  <button aria-expanded=...>
    <img ...>
    <span>Visible text label</span>
  </button>
</h5>

Alternatively, the <button> can be injected into another element as an inline trigger. This will render the <button> with only the down arrow/chevron icon, and use an aria-label="More info" to provide it an accessible name. Consider the following markup:

<disclosure-inline>
  <h5>
    My topic here
    <span data-insert-trigger="inline"></span>
  </h5>
  ...
</disclosure-inline>

The resulting markup will render as follows:

<h5>
  My topic here
  <span ...>
    <button ... aria-expanded="..." aria-label="More info"></button>
  </span>
</h5>

Other options

The following attributes are available to use on the wrapping <disclosure-block> or <disclosure-inline> element:

  • data-open – Use to open a disclosure widget by default.
  • data-disabled - Will add a disabled attribute to the generated <button>.
  • data-left-align - Will render the down arrow / chevron on the left of the <button>, rather than the default right position.
  • data-popup - The <disclosure-content> will be displayed as a faux "popup". If keyboard focus is detected outside of the widget, the popup content will auto-collapse and the <button> will return to the aria-expanded=false state. When identified as a "popup", the content panel will be provided a tabindex=-1 and a role=note. Comments describing why are provided in the JavaScript file.

Keyboard controls

The <button> element allows for default Space and Enter keys to toggle the expanded and collapsed state of the associated content.

If the disclosure widget is rendered as a popup, then the Esc key can be used to collapse the content if focus is on the <button> element, or within the expanded disclosure widget content container. Pressing Esc will return focus to the <button> element of the disclosure widget.

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].