A11y Tools
Collection of simple accessibility helpers.
Installation
npm install a11y-tools
ARIA
Hide/Show
import { ariaHide, ariaShow } from 'a11y-tools'
ariaHide(element)
ariaShow(element)
Disable/Enable
import { ariaDisable, ariaEnable } from 'a11y-tools'
ariaDisable(element)
ariaEnable(element)
Input States
import { ariaCheck, ariaUncheck, ariaSelect, ariaUnselect, ariaPress, ariaUnpress } from 'a11y-tools'
ariaCheck(element)
ariaUncheck(element)
ariaSelect(element)
ariaUnselect(element)
ariaPress(element)
ariaUnpress(element)
Current
import { ariaCurrent } from 'a11y-tools'
ariaCurrent(element)
ariaCurrent(element, false)
ariaCurrent(element, 'page')
ariaCurrent(element, null)
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)
ariaContract(element)
ariaExpand(element, { container, label = 'Close' })
ariaContract(element, { container, label = 'Open' })
Focus
Trap focus
import { trapFocus } from 'a11y-tools'
const focusTrapUndoFunction = trapFocus(element, {
unfocusElements: true
})
focusTrapUndoFunction()
Focus element
import { focus } from 'a11y-tools'
focus(element, { scroll: false })
Speech
Announce to screenreaders
import { speak } from 'a11y-tools'
speak('Navigated to page: About')
License
MIT