Skip to content

Commit

Permalink
Docs: Link usage updates (carbon-design-system#1138)
Browse files Browse the repository at this point in the history
* Docs: Link usage updates

* docs: screen reader copy

* Docs: typo

* Docs: update inline image

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: emyarod <emyarod@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: emyarod <emyarod@users.noreply.github.com>

* Docs: type update

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Update src/pages/components/link/usage.mdx

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>

* Docs: updates

Co-authored-by: Jan Child <44503588+janchild@users.noreply.github.com>
Co-authored-by: emyarod <emyarod@users.noreply.github.com>
  • Loading branch information
3 people authored and natashadecoste committed May 19, 2021
1 parent c565507 commit 0343db4
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 131 additions & 8 deletions src/pages/components/link/usage.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
---
title: Link
description: Links are used primarily as a navigational element. Links may also change what or how data is displayed.
description: Links are used as navigational elements. They may appear on their own, within a sentence or paragraph, or directly following the content.
tabs: ["Usage", "Style", "Code", "Accessibility"]
---

<PageDescription>

Links are used as navigational elements. They may appear on their own, within a sentence or paragraph, or directly following the content.

</PageDescription>

<AnchorLinks>

<AnchorLink>Overview</AnchorLink>
<AnchorLink>Formatting</AnchorLink>
<AnchorLink>Content</AnchorLink>
<AnchorLink>Behaviors</AnchorLink>
<AnchorLink>Link types</AnchorLink>
<AnchorLink>Modifiers</AnchorLink>
<AnchorLink>Related</AnchorLink>
<AnchorLink>Feedback</AnchorLink>

</AnchorLinks>

<ComponentDemo
components={[
{
Expand All @@ -28,14 +47,118 @@ tabs: ["Usage", "Style", "Code", "Accessibility"]
`}</ComponentVariant>
</ComponentDemo>

## General guidance
## Overview

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.

### When to use

Use links when you want users to:

- Navigate to a different page within the application
- Navigate to an entirely different site
- Jump to an element on the same page
- Link to emails or phone numbers

### When not to use

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.

### Types

| Type | Usage |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Standalone](#standalone-link) | These links are the default link type. They are used on their own or directly following content and they do not use underlines. They can be paired with an icon. |
| [Inline](#inline-link) | Inline links are used within a sentence or paragraph and are styled with an underline. They should not be paired with an icon. |

_Links_ are used primarily as a navigational element. Links may also change what or how data is displayed (i.e., view more, show all). If the action taken by the user will change or manipulate data, use a [button](/components/button/usage).
## Formatting

### Anatomy

<Row>
<Column colLg={8}>

![link anatomy image](images/01_link_anatomy_608.png)

</Column>
</Row>

1. **Label:** Communicates what is being linked to.

## Content

- Use text for links rather than graphics or icons.
- Links should be three words or less.
- Text should be consistent with the title of the intended destination.
- Use caution with links that are several words long. It is recommended that links are long enough to be understood by the user, but short enough to prevent text wrapping.
- Avoid the term “click here,” other links to “here,” or the web address itself. Instead, use a meaningful descriptive label for the link, and match the destination site name.
We recommend links be three words or fewer. Because links take users to a new location, it is important that their labels accurately reflect the content users will find at the link destination. Use meaningful labels for links and avoid terms like "click here" or the web address itself.

Links need to be clear enough to be understood by the user, but should not be so long that the text wraps unless used inline.

For further content guidance, see Carbon's [content guidelines](/guidelines/content/action-labels).

## Behaviors

### Interactions

#### Mouse

Users can open a link by clicking anywhere along the link text or on the associated icon.

#### Keyboard

Users can open a link by pressing `Enter` while the link has focus. For additional keyboard interactions, see the Accessibility tab.

#### Screen readers

VoiceOver: Users can open a link by pressing `Control-Option-Space` or `Enter`.

JAWS: Users can open a link by pressing `Enter`.

NVDA: Users can open a link by pressing `Enter`.

For additional information, see [screen reader tests](accessibility/#macos-screen-reader-tests).

## Link types

### Standalone link

Standalone links are used on their own directly following content. They should not be used within sentences or paragraphs. Standalone links are the default link style for Carbon and only have an underline in the hover state.

The standalone link component can be paired with an icon. Use 16px icons and place them to the right of the link. Icons should always be the same color as the link text.

<Row>
<Column colLg={8}>

![link with icon example](images/02_link_icon_608.png)

</Column>
</Row>

### Inline link

Inline links are used in sentences or paragraphs of text. The inline link behaves the same as the standalone link but it is styled with an underline. This helps differentiate them from the text they are placed next to and makes it clear users can interact with them.

Inline links should not be used on their own and should not be paired with icons.

<Row>
<Column colLg={8}>

![inline link example](images/03_link_inline_608.png)

</Column>
</Row>

## Modifiers

### Visited style

By default, the link component does not use a visited style. Visited links indicate that a user has already opened the link so they can be a helpful indicator during task completion. Visited styles should be used sparingly because they often clutter the the page and add further visual noise as users are trying to navigate a product. They can be used if it is important that a user knows they have already clicked on a link.

### Links that trigger actions

Some links trigger actions to aid task completion in addition to navigation. These links should still serve a navigation purpose. A common example is linking phone numbers so clicking the website automatically opens and calls the phone number when clicked. The label and any accompanying icons should make it clear what action will be triggered and where the user will be directed.

## Related

- [Button component](https://www.carbondesignsystem.com/components/button/usage/)

## Feedback

Help us improve this component by providing feedback, asking questions, and leaving any other comments on [GitHub](https://github.com/carbon-design-system/carbon-website/issues/new?assignees=&labels=feedback&template=feedback.md).

0 comments on commit 0343db4

Please sign in to comment.