Link
A link enables users to navigate to a different page, page section, or resource (like a downloadable file).
#Examples
Links provide a way for users to move between different parts of the application or access external resources. They should be used to enhance navigation and provide access to relevant information.
Need to change the style of a link? You can easily customize the appearance of links using the properties described in the following sections.
#Basic usage
Use the default variation for standalone links, providing a clear visual indication of interactivity. It features an arrow to indicate that it's a link without relying on color alone, ensuring proper communication to color-blind users.
<Link href="https://www.google.com">Medium standalone link (default)</Link>
#Size
Use this property to adjust how attention-grabbing a standalone link should be.
<Link href="https://www.google.com" size="small">
Small standalone link
</Link>
<br />
<Link href="https://www.google.com" size="medium">
Medium standalone link (default)
</Link>
<br />
<Link href="https://www.google.com" size="large">
Large standalone link
</Link>
<br />
#Inline
Use within sentences or paragraphs, maintaining the flow of text while providing clear navigation. It features an underline, instead of an arrow, to indicate without color that it is a link. This variant inherits its size from the text it's part of. To avoid localization problems, do not use a placeholder for the link text.
This is an example of an inline link, which is part of a sentence.
<Paragraph>
This is an example of an{" "}
<Link href="https://www.google.com" inlineInText>
inline link
</Link>
, which is part of a sentence.
</Paragraph>
#Unstyled
Use for interface elements that need to behave like a link without the standard link styling. Its custom styling and the UI context in which it's used should make clear that it's a link and where it links to.
#Open in new tab or window
When a link points to a page on another domain, it's generally best to open it in a new tab or window (depending on the user's browser setting). This can be achieved by setting the openNew
property to true
.
<Link href="https://www.google.com" openNew>
Medium standalone link (default)
</Link>
#Download linked resource
When a link leads to a resource intended to be downloaded rather than displayed in the browser the download
property can be set to true
. Provide a string value to specify the default file name like so: download="filename.pdf"
. Best practice is to not open a link, intendded to be downloaded, in a new tab, so avoid using openNew
and download
together.
#Link container and Link text
If you want some of the content to not have the link text styling but still be part of the link.
<LinkContainer href="https://www.google.com" openNew>
<Badge>Pre:</Badge> <LinkContainer.LinkText>Styled link text</LinkContainer.LinkText>
</LinkContainer>
Property | Description | Defined | Value |
---|---|---|---|
hrefRequired | string Url of the page the link redirects to | ||
openNewOptional | boolean Opens the link in a new tab if set to true | ||
downloadOptional | | unknown Downloads the linked resource (instead of displaying it in the browser) if set to true. Provide a string to specify the default file name. | ||
childrenOptional | element Label for the link | ||
onClickOptional | function Callback for onClick events | ||
inlineInTextOptional | boolean Renders the link inline if set to true, should be used when the link is part of a text block | ||
aria-labelOptional | string Screen reader text for the link | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | number Tab index of the outermost HTML element of the component | ||
onKeyDownOptional | function Callback for onKeyDown event | ||
onMouseDownOptional | function Callback for onMouseDown event | ||
onMouseEnterOptional | function Callback for onMouseEnter event | ||
onMouseLeaveOptional | function Callback for onMouseLeave event | ||
onFocusOptional | function Callback for onFocus event | ||
onBlurOptional | function Callback for onBlur event | ||
unstyledOptional | boolean Renders the link without style if set to true | ||
sizeOptional | "large" | "medium" | "small" Size of the link, defaults to `"medium"` | ||
disableWordBreakOptional | boolean When link is wrapped into single words |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications