--- title: "Link" slug: link category: component type: documentation version: 20.0.0 tokens: 1660 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-link--documentation.txt --- # Link _**Link** is a component that enables redirection to a new page, section, website or other resources:_ ## Overview A **Link** allows users to move through a website by redirecting them to a different page or section. It can also enables **Links** to other resources. | | | |---|---| | Name | Link | | Also known as | Hyperlink, Anchor | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=44-6837 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/link | ## Usage **Links** are used as navigational elements. They are also used when linking to another document. In that case, **Link** description should contain type and size of document. ### When to use a link or a button? Links and buttons serve different purposes, and using them correctly improves both accessibility and user experience. * Use a link when the action navigates the user to another page or resource, either within your application or to an external site * Use a button when the action performs a function or triggers a behavior on the current page, like submitting a form, opening a modal, or toggling a menu. A button should not mimic a link. It can lead to confusion for users and assistive technologies, as buttons are not typically expected to handle navigation. ### Dos & Don'ts **Do** - Use a link to navigate to another page, section, or external website, not to trigger actions - Make link labels clear and descriptive, so users understand where the link will take them - Keep link labels short ideally 1–4 words - Indicate when a link leads to a document or file by including its type and size (e.g., "Annual Report (PDF, 1.2MB)") - Optionally include an icon, but ensure it's styled consistently with the link label **Don't** - Don't use a link to perform actions like "save", "submit", or "cancel", use a button for that - Don't use vague text like "Click here" or "Read more", it provides no context for screen readers or SEO - Don't write entire sentences as link label - Don't apply different colors to a link and its adjacent icon. They should appear as one cohesive element - Don't open a link in a new tab or window unless it's clearly indicated and necessary (e.g., for external sites) - Don't forget to set appropriate rel attributes (e.g., rel="noopener noreferrer") for external links opened in new tabs ### Best Practices in Context 1. **Link** 2. **Label** - optional 3. **Icon** - optional (left or right) ## Placement A **Link** can stand alone on a page, or it can be placed within a sentence or a paragraph. ## Behavior **Link** component can be hovered, focused, clicked and disabled. When disabled, users cannot focus nor click on the **Link**. A **Link** is underlined at rest, 1px in its own color, so that it is not told from the surrounding text by its color alone. On hover, the underline turns 2px and the **Link** keeps its color: the thicker underline is the hover signal. A visited **Link** keeps its visited color. The thicknesses read `--ods-link-underline-thickness` and `--ods-link-underline-thickness-hover`. Set them on a **Link** or on a container, for instance `0` at rest in a navigation where the links are plainly links. A disabled **Link** keeps its rest underline, dimmed with it. An icon-only **Link** made of ODS **Icon** components has no underline at rest. With another icon, such as an inline `` or an icon from another library, the **Link** cannot tell it from a label and keeps the underline: set `--ods-link-underline-thickness: 0` on it. The underline is a pseudo-element drawn by the **Link** box, not a `text-decoration`: `text-decoration: none` does not remove it, `--ods-link-underline-thickness: 0` does. Being drawn by the box, it does not follow a label that wraps over several lines: a **Link** set to `display: inline` draws it under part of its last line, or not at all when it starts mid-sentence, and a **Link** left `inline-flex` draws it across its whole width, under its last line. A printed page also loses it when the print dialog leaves the background graphics out. In forced colors mode, the underline is drawn in the link color of the system palette (`LinkText`), so it stays visible. An optional icon can be displayed on the left or right of the **Link** label content. Icon-only **Link** also exists but it must meet accessibility requirements. See Accessibility section below. When users clicks anywhere on the **Link**, even its optional icon, they are redirected to the expected page or section. ## Navigation ### Focus Management The **Link** component can receive keyboard focus and is part of the standard tab order. ### General Keyboard Shortcuts Pressing `Enter` while a **Link** is focused activates it, navigating to the associated destination. Pressing `Shift` + `Tab` moves focus to the previous interactive element. If a **Link** opens in a new tab, focus remains on the original page unless otherwise specified. ## Accessibility This component complies with the [Link WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/link/). ### Icon-only Link If a **Link** is represented only by an **Icon**, it must have an explicit accessible label to provide context about its destination or action. ```tsx ``` Screen readers will announce the link and its label. ### Link opening in a new tab When a **Link** opens in a new tab (`target="_blank"`), users should be informed to avoid confusion. This can be done by adding a visual indicator (e.g., Icon: "external") and using `aria-label` to provide context. ```tsx ``` The screen reader will announce the link, the opening in a new tab behavior and the link label. ### Downloadable files If a **Link** points to a file download, it should include the file type and size information. ```tsx <> Download WCAG20 Guidelines (PDF, 481 KB) ``` Screen readers will announce the link, the link label with the file name, type and size, ensuring users know they are downloading a file.