A link allows a user to navigate to another page or resource within a web page or application.
Vanilla CSS theme
This sets the
--tint CSS variable used by the Vanilla CSS examples.Theme
isDisabled
Client side routing
By default, links with an href are handled by the browser as regular page navigations. To integrate with a client side router, use the render prop to delegate to your router's link component. This supports features like prefetching on hover and avoids full page reloads.
import {Link} from 'react-aria-components/Link';
import NextLink from 'next/link';
<Link href="/about" render={props => <NextLink {...props} />}>
About
</Link>
import {Link} from 'react-aria-components/Link';
import {Link as RouterLink} from 'react-router';
<Link href="/about" render={props => <RouterLink {...props} to={props.href} />}>
About
</Link>
See the customization guide for more details on the render prop.
Events
Links without an href will be rendered as a <span role="link"> instead of an <a>. Use the onPress event to handle user interaction.
Link
import {Link} from './Link';
<Link onPress={() => alert('Pressed link')}>Link</Link>
API
| Name | Type | |
|---|---|---|
isDisabled | boolean | |
Whether the link is disabled. | ||
children | ChildrenOrFunction | |
The children of the component. A function may be provided to alter the children based on component state. | ||
Default className: react-aria-Link
| Render Prop | CSS Selector |
|---|---|
isCurrent | CSS Selector: [data-current]
|
| Whether the link is the current item within a list. | |
isHovered | CSS Selector: [data-hovered]
|
| Whether the link is currently hovered with a mouse. | |
isPressed | CSS Selector: [data-pressed]
|
| Whether the link is currently in a pressed state. | |
isFocused | CSS Selector: [data-focused]
|
| Whether the link is focused, either via a mouse or keyboard. | |
isFocusVisible | CSS Selector: [data-focus-visible]
|
| Whether the link is keyboard focused. | |
isDisabled | CSS Selector: [data-disabled]
|
| Whether the link is disabled. | |