Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a11y-tools

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a11y-tools

Simple accessibility helpers

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

A11y Tools

NPM version Bundle size GitHub license

Collection of simple accessibility helpers.

Installation

npm install a11y-tools

ARIA

Hide/Show

import { ariaHide, ariaShow } from 'a11y-tools'

ariaHide(element) // set aria-hidden="true"
ariaShow(element) // set aria-hidden="false"

Disable/Enable

import { ariaDisable, ariaEnable } from 'a11y-tools'

ariaDisable(element) // set aria-disabled="true"
ariaEnable(element)  // set aria-disabled="false"

Input States

import { ariaCheck, ariaUncheck, ariaSelect, ariaUnselect, ariaPress, ariaUnpress } from 'a11y-tools'

ariaCheck(element)    // set aria-checked="true"
ariaUncheck(element)  // set aria-checked="false"

ariaSelect(element)   // set aria-selected="true"
ariaUnselect(element) // set aria-selected="false"

ariaPress(element)    // set aria-pressed="true"
ariaUnpress(element)  // set aria-pressed="false"

Current

import { ariaCurrent } from 'a11y-tools'

ariaCurrent(element)         // set aria-current="true"
ariaCurrent(element, false)  // set aria-current="false"
ariaCurrent(element, 'page') // set aria-current="page"
ariaCurrent(element, null)   // remove aria-current

Expand/Contract

element = Toggle element (button) label = Text content of toggle element container = Content container (DOM element)

import { ariaExpand, ariaContract } from 'a11y-tools'

ariaExpand(element)   // set aria-expanded="true"
ariaContract(element) // set aria-expanded="false"

ariaExpand(element, { container, label = 'Close' })
ariaContract(element, { container, label = 'Open' })

Focus

Trap focus

import { trapFocus } from 'a11y-tools'

// Trap focus inside element
const focusTrapUndoFunction = trapFocus(element, {
  unfocusElements: true // aria-hide sibling containers?
})

// Restore focus to previously focused element
focusTrapUndoFunction()

Focus element

import { focus } from 'a11y-tools'

// Focus first tabbable child element without scrolling to it
focus(element, { scroll: false })

Speech

Announce to screenreaders

import { speak } from 'a11y-tools'

speak('Navigated to page: About')

License

MIT

Keywords

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc