Links are used to navigate to a new location, open or download an asset, or serve as an inline action.
The Link component may be used as a regular hyperlink or an inline button. As a hyperlink, the Link uses a native HTML <a> element. With an onClick handler and no href, a native HTML <button> will be used instead. Using these elements maintains proper semantic roles and meaning and ensure the Link's purpose is accurately communicated to assistive technology.
External links have the safe HTML attributes target="_blank" and rel="noopener noreferrer" applied automatically to ensure that the original tab cannot be improperly accessed.
| Element | Attribute | Description |
|---|---|---|
| Link | aria-disabled | Set to true when the link is disabled. |
The disabled attribute is used to prevent interaction with the form control it's applied to and its descendants. However, it's not supported on the <a> element. To address this, when the Link is disabled, the aria-disabled and tabIndex="-1" attributes are added to remove the element from the tab order, prevent click events, and make the Link's disabled state clear to assistive technology.
| Key | Function |
|---|---|
| Enter | Activates the Link. |
| Enter/Space | Activates the Link when an onClick handler is present with no href. |
| Shift+Tab | Moves focus to the previous focusable element. |
| Tab | Moves focus to the next focusable element. |