Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tetracalibers/polym-a11y


https://github.com/tetracalibers/polym-a11y

Last synced: 26 days ago
JSON representation

Awesome Lists containing this project

README

        

# @polym/a11y

**Collection of helpers for implementing React components with accessibility in mind**

## Install

```
npm i --save @polym/a11y
```

or

```
yarn add @polym/a11y
```

## VisuallyHidden

**Containers for elements that are visually obscured and whose presence is communicated only to the screen reader**

[Click here for full documentation and demo](https://tetracalibers.github.io/polym-a11y/?path=/docs/visuallyhidden-document--page)

### Usecase

```ts
import { VisuallyHidden } from '@polym/a11y'

export const NumberInput = () => {
const [count, setCount] = useState(0)

return (

setCount((now) => now - 1)}
/>
setCount(e.target.value)} />

{label}

setCount((now) => now + 1)}
/>

{count}


)
}
```

Even if you do not want the label to appear in the design, do not use `display:none;` to erase its existence.

Without labels, screen reader users have no way of knowing what the input field is.

```ts

{label}

```

The screen reader reads out changes in input values.

There is no need to display the numbers for this reading, which is where `VisuallyHidden` comes in.

```ts

{count}

```