{"id":17275115,"url":"https://github.com/daun/a11y-tools","last_synced_at":"2025-03-26T13:42:56.664Z","repository":{"id":57171683,"uuid":"445262379","full_name":"daun/a11y-tools","owner":"daun","description":"Simple accessibility helpers","archived":false,"fork":false,"pushed_at":"2022-01-06T18:15:42.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T15:15:56.836Z","etag":null,"topics":["a11y","accessibility","helpers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-06T17:55:57.000Z","updated_at":"2024-09-04T10:09:26.000Z","dependencies_parsed_at":"2022-08-24T13:30:46.397Z","dependency_job_id":null,"html_url":"https://github.com/daun/a11y-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fa11y-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fa11y-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fa11y-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fa11y-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daun","download_url":"https://codeload.github.com/daun/a11y-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245667102,"owners_count":20652897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","accessibility","helpers"],"created_at":"2024-10-15T08:55:28.224Z","updated_at":"2025-03-26T13:42:56.640Z","avatar_url":"https://github.com/daun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A11y Tools\n\n[![NPM version](https://img.shields.io/npm/v/a11y-tools)](https://www.npmjs.com/package/a11y-tools)\n[![Bundle size](https://img.shields.io/bundlephobia/minzip/a11y-tools?label=size)](https://bundlephobia.com/result?p=a11y-tools)\n[![GitHub license](https://img.shields.io/github/license/daun/a11y-tools)](./LICENSE)\n\nCollection of simple accessibility helpers.\n\n- [ARIA](#aria)\n- [Focus](#focus)\n- [Speech](#speech)\n\n## Installation\n\n```bash\nnpm install a11y-tools\n```\n\n## ARIA\n\n### Hide/Show\n\n```js\nimport { ariaHide, ariaShow } from 'a11y-tools'\n\nariaHide(element) // set aria-hidden=\"true\"\nariaShow(element) // set aria-hidden=\"false\"\n```\n\n### Disable/Enable\n\n```js\nimport { ariaDisable, ariaEnable } from 'a11y-tools'\n\nariaDisable(element) // set aria-disabled=\"true\"\nariaEnable(element)  // set aria-disabled=\"false\"\n```\n\n### Input States\n\n```js\nimport { ariaCheck, ariaUncheck, ariaSelect, ariaUnselect, ariaPress, ariaUnpress } from 'a11y-tools'\n\nariaCheck(element)    // set aria-checked=\"true\"\nariaUncheck(element)  // set aria-checked=\"false\"\n\nariaSelect(element)   // set aria-selected=\"true\"\nariaUnselect(element) // set aria-selected=\"false\"\n\nariaPress(element)    // set aria-pressed=\"true\"\nariaUnpress(element)  // set aria-pressed=\"false\"\n```\n\n### Current\n\n```js\nimport { ariaCurrent } from 'a11y-tools'\n\nariaCurrent(element)         // set aria-current=\"true\"\nariaCurrent(element, false)  // set aria-current=\"false\"\nariaCurrent(element, 'page') // set aria-current=\"page\"\nariaCurrent(element, null)   // remove aria-current\n```\n\n### Expand/Contract\n\n`element` = Toggle element (button)\n`label` = Text content of toggle element\n`container` = Content container (DOM element)\n\n```js\nimport { ariaExpand, ariaContract } from 'a11y-tools'\n\nariaExpand(element)   // set aria-expanded=\"true\"\nariaContract(element) // set aria-expanded=\"false\"\n\nariaExpand(element, { container, label = 'Close' })\nariaContract(element, { container, label = 'Open' })\n```\n\n## Focus\n\n### Trap focus\n\n```js\nimport { trapFocus } from 'a11y-tools'\n\n// Trap focus inside element\nconst focusTrapUndoFunction = trapFocus(element, {\n  unfocusElements: true // aria-hide sibling containers?\n})\n\n// Restore focus to previously focused element\nfocusTrapUndoFunction()\n```\n\n### Focus element\n\n```js\nimport { focus } from 'a11y-tools'\n\n// Focus first tabbable child element without scrolling to it\nfocus(element, { scroll: false })\n```\n\n## Speech\n\n### Announce to screenreaders\n\n```js\nimport { speak } from 'a11y-tools'\n\nspeak('Navigated to page: About')\n```\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fa11y-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaun%2Fa11y-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fa11y-tools/lists"}