{"id":24911424,"url":"https://github.com/accessible-ui/link","last_synced_at":"2025-03-28T03:14:41.791Z","repository":{"id":40794966,"uuid":"230702982","full_name":"accessible-ui/link","owner":"accessible-ui","description":"🅰 A component that adds aria attributes and keydown events to non-A elements in order to make them act like native links","archived":false,"fork":false,"pushed_at":"2023-01-06T02:23:09.000Z","size":3075,"stargazers_count":1,"open_issues_count":16,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T19:47:32.756Z","etag":null,"topics":["a11y","a11y-link","accessibility","accessible","accessible-link","accessible-react","aria-link","react-accessibility"],"latest_commit_sha":null,"homepage":"https://codesandbox.io/s/accessiblelink-examples-rohqw","language":"TypeScript","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/accessible-ui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-12-29T04:35:14.000Z","updated_at":"2020-07-08T04:34:36.000Z","dependencies_parsed_at":"2023-02-05T03:01:19.385Z","dependency_job_id":null,"html_url":"https://github.com/accessible-ui/link","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accessible-ui%2Flink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accessible-ui%2Flink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accessible-ui%2Flink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accessible-ui%2Flink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/accessible-ui","download_url":"https://codeload.github.com/accessible-ui/link/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960812,"owners_count":20700781,"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","a11y-link","accessibility","accessible","accessible-link","accessible-react","aria-link","react-accessibility"],"created_at":"2025-02-02T04:20:06.633Z","updated_at":"2025-03-28T03:14:41.721Z","avatar_url":"https://github.com/accessible-ui.png","language":"TypeScript","readme":"\u003chr\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    \u0026lt;AccessibleLink\u0026gt;\n  \u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=@accessible/link\"\u003e\n    \u003cimg alt=\"Bundlephobia\" src=\"https://img.shields.io/bundlephobia/minzip/@accessible/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n  \u003ca aria-label=\"Types\" href=\"https://www.npmjs.com/package/@accessible/link\"\u003e\n    \u003cimg alt=\"Types\" src=\"https://img.shields.io/npm/types/@accessible/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n  \u003ca aria-label=\"Code coverage report\" href=\"https://codecov.io/gh/accessible-ui/link\"\u003e\n    \u003cimg alt=\"Code coverage\" src=\"https://img.shields.io/codecov/c/gh/accessible-ui/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n  \u003ca aria-label=\"Build status\" href=\"https://travis-ci.org/accessible-ui/link\"\u003e\n    \u003cimg alt=\"Build status\" src=\"https://img.shields.io/travis/accessible-ui/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n  \u003ca aria-label=\"NPM version\" href=\"https://www.npmjs.com/package/@accessible/link\"\u003e\n    \u003cimg alt=\"NPM Version\" src=\"https://img.shields.io/npm/v/@accessible/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n  \u003ca aria-label=\"License\" href=\"https://jaredlunde.mit-license.org/\"\u003e\n    \u003cimg alt=\"MIT License\" src=\"https://img.shields.io/npm/l/@accessible/link?style=for-the-badge\u0026labelColor=24292e\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cpre align=\"center\"\u003enpm i @accessible/link\u003c/pre\u003e\n\u003chr\u003e\n\nA component that adds aria attributes and keydown events to non-A elements in order to make them act like native links.\n\n## Quick Start\n\n[Check out the example on CodeSandbox](https://codesandbox.io/s/accessiblelink-examples-rohqw)\n\n```jsx harmony\nimport {Link as AccessibleLink} from '@accessible/link'\n\nconst LinkButton = () =\u003e (\n  \u003cAccessibleLink\u003e\n    \u003cbutton onClick={() =\u003e (window.location.href = '/foo')}\u003eGo to /foo\u003c/button\u003e\n  \u003c/AccessibleLink\u003e\n)\n```\n\n## API\n\n### \u0026lt;Link\u0026gt;\n\nAdds `role=\"link\"` and `tabIndex={0}` props to its child component unless those props are already\ndefined in the child component's props. Also adds a `keydown` event for the `Enter` key which\ncauses the component's `onClick` property to fire.\n\n#### Props\n\n| Prop     | Type                 | Default     | Required? | Description                                                           |\n| -------- | -------------------- | ----------- | --------- | --------------------------------------------------------------------- |\n| children | `React.ReactElement` | `undefined` | Yes       | The component you want to add accessible roles and keydown events to. |\n\n### useA11yLink(target, onClick)\n\nA React hook for adding a11y properties and link/role=link interop to elements.\n\n```jsx harmony\nconst Link = () =\u003e {\n  const ref = React.useRef(null)\n  const a11yProps = useA11yButton(ref, (event) =\u003e {\n    // This is your `onClick` handler\n    navigate.to('/home')\n    event.preventDefault()\n  })\n  return \u003cbutton {...a11yProps} ref={ref} /\u003e\n}\n```\n\n#### Arguments\n\n| Argument | Type                                                       | Required? | Description                                                                                          |\n| -------- | ---------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------- |\n| target   | \u003ccode\u003eReact.RefObject\u0026lt;T\u0026gt; \u0026#124; T \u0026#124; null\u003c/code\u003e | Yes       | A React ref or HTML element                                                                          |  |\n| children | `React.ReactElement`                                       | Yes       | The component you want to turn into a button that handles focus and `space`, `enter` keydown events. |\n\n#### Returns\n\n```ts\n{\n    readonly onClick: (event: React.MouseEvent\u003cT, MouseEvent\u003e) =\u003e void;\n    readonly role: \"button\";\n    readonly tabIndex: 0;\n}\n```\n\n## LICENSE\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccessible-ui%2Flink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faccessible-ui%2Flink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccessible-ui%2Flink/lists"}