@substrate-system/a11y
v0.0.5
Published
Accessibility helpers
Downloads
1,009
Readme
a11y
Factoring out some common CSS utilities, so there is less duplication across projects.
featuring
install
npm i -S @substrate-system/a11y
Use
This package exposes CSS only.
example
Put the relevant classes in your HTML.
const myEl = document.querySelector('div')
myEl?.innerHTML = `<button>
<svg><!-- icon here --></svg>
<span class="visually-hidden">Button text</span>
</button>`
Import CSS
If using a bundler, import the package as normal.
import '@substrate-system/a11y'
Or minified:
import '@substrate-system/a11y/min'
Minified CSS
If you don't want to use a bundler, this package exposes minified CSS files too. You can copy them to a location that is accessible to your web server, then link to them directly in HTML.
copy
cp ./node_modules/@substrate-system/a11y/dist/index.min.css ./public/a11y.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="./a11y.css">
</head>
</html>
API
This package exposes CSS that will look for the following classes.
visually-hidden
Use this to create accessible buttons with no visible text.
See this article.
<button class="${classes}">
<svg><!-- icon here --></svg>
<span class="visually-hidden">Button text</span>
</button>