<AccessibleLink>
npm i @accessible/link
A component that adds aria attributes and keydown events to non-A elements in order to make them act like native links.
Quick Start
import AccessibleLink from '@accessible/link'
const Component = () => (
<AccessibleLink>
<span onClick={() => (window.location.href = '/foo')}>Go to /foo</span>
</AccessibleLink>
)
API
<AccessibleLink>
Adds role="link"
and tabIndex={0}
props to its child component unless those props are already
defined in the child component's props. Also adds a keydown
event for the Enter
key which
causes the component's onClick
property to fire.
Props
Prop | Type | Default | Required? | Description |
---|
children | React.ReactElement | undefined | Yes | The component you want to add accessible roles and keydown events to. |
LICENSE
MIT