Link
Links allow users to click their way from page to page. This component is styled to resemble a hyperlink and semantically renders an <a>
Installation
The above command is for individual installation only. You may skip this step if @nextui-org/react
is already installed globally.
Import
Usage
Disabled
Sizes
Colors
Underline
External
If you pass the isExternal
prop, the link will have the target="_blank"
and rel="noopener noreferrer"
attributes.
Custom Anchor Icon
Block Link
If you pass the isBlock
prop, the link will be rendered as a block element with a hover
effect.
Polymorphic Component
NextUI components expose a as
prop that allows you to customize the React element type that is used to render the component.
Routing
The <Link>
component works with frameworks and client side routers like Next.js and
React Router. See the Routing guide to learn how to set this up.
Custom Implementation
In case you need to customize the link even further, you can use the useLink
hook to create your own implementation.
Data Attributes
Link
has the following attributes on the base
element:
- data-focus: When the link is being focused. Based on useFocusRing
- data-focus-visible: When the link is being focused with the keyboard. Based on useFocusRing
- data-disabled:
When the link is disabled. Based on
isDisabled
prop.
Accessibility
- Support for mouse, touch, and keyboard interactions.
- Support for navigation links via
<a>
elements or custom element types via ARIA. - Support for disabled links.
- Keyboard users may activate links using the Enter key.
API
Link Props
Prop | Type | Default |
size |
| "md" |
color |
| "primary" |
underline |
| "none" |
href |
| |
target |
| |
rel |
| |
download |
| |
ping |
| |
referrerPolicy |
| |
isExternal |
| false |
showAnchorIcon |
| false |
anchorIcon |
| |
isBlock |
| false |
isDisabled |
| false |
disableAnimation |
| false |
Link Events
Prop | Type | Default |
onPress |
| |
onPressStart |
| |
onPressEnd |
| |
onPressChange |
| |
onPressUp |
| |
onKeyDown |
| |
onKeyUp |
| |
onClick |
|