Coming from Orbiter, you should be aware of the following changes:
Link,IconLinkandTextLinkhave all been merged into one.LinkAsButtonhas been removed. It is now possible to use theLinkcomponent without anhrefattribute.
A link allows a user to navigate to a different location.
Links are used as navigational elements and can be used on their own or inline with text. They provide a lightweight option for navigation but like other interactive elements, too many links will clutter a page and make it difficult for users to identify their next steps. This is especially true for inline links, which should be used sparingly.
<Link> <Icon /> /* (Optional) An icon in the link */ <Text /> /* (Optional) The text content of the link */ </Link>
A Link uses the following components:
Links can be disabled.
An external text link will render by default with rel="noopener noreferrer" and target="_blank" attributes.
When a <Link> does not have an href prop, it is rendered as a <span role="link"> instead of an <a>. Events will need to be handled in JavaScript with the onPress prop.
Note: this will not behave like a native link. Browser features like context menus and open in a new tab will not apply.
Links can be presented in different variants.
Links can be presented in different sizes.
The size can also be inherited.
Links can contain an icon.
Non standard start icons can be provided to handle special cases. However, think twice before adding start icons, end icons should be your go to.
A link's content can be a single icon. When using this variant, an accessible name must be provided through the aria-label prop. See WCAG practices.
All links can have a quiet style, without an underline. This style should only be used when the placement and context of the link is explicit enough that a visible underline isn't necessary.
All links can have a standalone style, without an underline which is similar to quiet, the difference is this adds block padding to make it more similar to a button.
A button can be rendered as a react router link when using the href property and setting the navigate property on the HopperProvider
When the colors from the variant props are not enough, you can use the color prop to set the color of the link. This removes the hover and focus colors from the link. Use the color props when a link needs to be placed on top of a colored background or visual. Make sure that the background and the link color meet the minimum color contrast ratio.
A link's content can be an image element.
Links are used primarily for navigation, and usually appear within or directly following a sentence. Buttons are used primarily for actions. Differentiating between the two both in the design and code result in:
Use links whenever possible to avoid disorienting users and causing accessibility problems by opening a new tab. When using an external link, always use the NewTab icon beside the link's label. External links should be used when users are:
Use links when you want users to:
Use a button instead of a link for actions that will change data or manipulate how it is displayed, change a state, or trigger an action. Buttons should never be used for navigational actions.
The visual style of the link.
Size of the link.
Whether the link should be displayed with a quiet style.
Whether the link should open in a new tab.
Wheter the link is standalone
The inline style for the element. A function may be provided to compute the style based on component state.
Whether the link is disabled.
Whether the element should receive focus on render.
A URL to link to. See MDN.
Hints at the human language of the linked URL. SeeMDN.
The target window for the link. See MDN.
The relationship between the linked resource and the current page. See MDN.
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
A space-separated list of URLs to ping when the link is followed. See MDN.
How much of the referrer to send when following the link. See MDN.
Options for the configured client side router.
The children of the component. A function may be provided to alter the children based on component state.
The CSS className for the element. A function may be provided to compute the class based on component state.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Not recommended – use onPress instead. onClick is an alias for onPress
provided for compatibility with other libraries. onPress provides
additional event details for non-mouse interactions.
Handler that is called when the element receives focus.
Handler that is called when the element loses focus.
Handler that is called when the element's focus status changes.
Handler that is called when a key is pressed.
Handler that is called when a key is released.
Handler that is called when a hover interaction starts.
Handler that is called when a hover interaction ends.
Handler that is called when the hover state changes.
A slot name for the component. Slots allow the component to receive props from a parent component.
An explicit null value indicates that the local props completely override all props received from a parent.
Defines a string value that labels the current element.
Identifies the element (or elements) that labels the current element.
Identifies the element (or elements) that describes the object.
Identifies the element (or elements) that provide a detailed, extended description for the object.
Coming from Orbiter, you should be aware of the following changes:
Link, IconLink and TextLink have all been merged into one.LinkAsButton has been removed. It is now possible to use the Link component without an href attribute.