Link
Examples
Base
<chi-link href="#">Link</chi-link>
<a class="chi-link" href="#">Link</a>
Disabled
Make links appear inactive by adding the disabled
boolean attribute
or -disabled
class.
<chi-link href="#" disabled>Link</chi-link>
<a class="chi-link -disabled" href="#">Link</a>
No Underline
Use to remove a link's underline.
<chi-link href="#" no-underline>Link</chi-link>
<a class="chi-link -no-underline" href="#">Link</a>
No Underline on Hover
Use to remove a link's underline on hover.
<chi-link href="#" no-hover-underline>Link</chi-link>
<a class="chi-link -no-hover-underline" href="#">Link</a>
CTA
Call to action (CTA) links are prominent links used primarily on marketing web pages to encourage users to perform a specific action (e.g. Get started, Learn more). Use link sizes to render CTA links larger or smaller.
<chi-link href="#" cta>Learn more</chi-link>
<a class="chi-link -cta" href="#">Learn more</a>
Labeled Icon Link
Use labeled icon links to render both text and icons inside link tags.
<chi-link href="#">
<chi-icon icon="circle-question-outline"></chi-icon>
<span>Help</span>
</chi-link>
<a class="chi-link" href="#">
<div class="chi-link__content">
<i class="chi-icon icon-circle-question-outline" aria-hidden="true"></i>
<span>Help</span>
</div>
</a>
Icon Link
Use icon links to render icons inside link tags.
Note: All icon links without text labels
must define a label in the alternative-text
attribute for accessibility.
<chi-link href="#" alternative-text="View helpful information about this topic">
<chi-icon icon="circle-question-outline"></chi-icon>
</chi-link>
<a class="chi-link" href="#" aria-label="View helpful information about this topic">
<div class="chi-link__content">
<i class="chi-icon icon-circle-question-outline" aria-hidden="true"></i>
</div>
</a>
Target
Use target to specify where to open a link. Supported values are:
_self
, _blank
, _parent
, _top
,
or a custom named frame framename
. The default value is _self
.
<!-- Open a link in the same frame as it was clicked (default) -->
<chi-link href="#" target="_self">Link</chi-link>
<!-- Open a link in a new window or tab -->
<chi-link href="#" target="_blank">Link</chi-link>
<!-- Open a link in the parent frame -->
<chi-link href="#" target="_parent">Link</chi-link>
<!-- Open a link in the full body of the window -->
<chi-link href="#" target="_top">Link</chi-link>
<!-- Open a link in a custom named frame -->
<chi-link href="#" target="framename">Link</chi-link>
<!-- Open a link in the same frame as it was clicked (default) -->
<a class="chi-link" href="#" target="_self">Link</a>
<!-- Open a link in a new window or tab -->
<a class="chi-link" href="#" target="_blank">Link</a>
<!-- Open a link in the parent frame -->
<a class="chi-link" href="#" target="_parent">Link</a>
<!-- Open a link in the full body of the window -->
<a class="chi-link" href="#" target="_top">Link</a>
<!-- Open a link in a custom named frame -->
<a class="chi-link" href="#" target="framename">Link</a>
Rel
Use rel to set the relationship between the current page and the linked page.
Rel supports all HTML a
attribute values. Examples include:
alternate
, external
, next
,
nofollow
, noreferrer
, noopener
,
prev
, and more.
<chi-link href="#" rel="noopener">Link</chi-link>
<a class="chi-link" href="#" rel="noopener">Link</a>
Download
Use download to prompt users to save a page or document instead of navigating to it. The download attribute accepts an optional value used to name the file. If no value is provided, the original filename is used.
<!-- Use default filename -->
<chi-link href="#" download>Link</chi-link>
<!-- Specify custom filename -->
<chi-link href="#" download="custom-filename">Link</chi-link>
<!-- Use default filename -->
<a class="chi-link" href="#" download>Link</a>
<!-- Specify custom filename -->
<a class="chi-link" href="#" download="custom-filename">Link</a>
Hreflang
Use to set the language of the link.
<chi-link href="#" hreflang="en">Link</chi-link>
<a class="chi-link" href="#" hreflang="en">Link</a>
Additional Sizes
Links support the following sizes:
xs
, sm
, md
, lg
,
and xl
. By default, links inherit the font-size of their parent element.
xs
sm
md
lg
xl
<!-- xs -->
<chi-link href="#" size="xs">Link</chi-link>
<!-- sm -->
<chi-link href="#" size="sm">Link</chi-link>
<!-- md -->
<chi-link href="#" size="md">Link</chi-link>
<!-- lg -->
<chi-link href="#" size="lg">Link</chi-link>
<!-- xl -->
<chi-link href="#" size="xl">Link</chi-link>
<!-- xs -->
<a class="chi-link -xs" href="#">Link</a>
<!-- sm -->
<a class="chi-link -sm" href="#">Link</a>
<!-- md -->
<a class="chi-link -md" href="#">Link</a>
<!-- lg -->
<a class="chi-link -lg" href="#">Link</a>
<!-- xl -->
<a class="chi-link -xl" href="#">Link</a>
Web Component
Properties
Accessibility
Keyboard Navigation
Key | Function |
---|---|
Tab | Moves focus to the next focusable element |
Shift + Tab | Moves focus to the previous focusable element |
Enter | Activates the link |
For comprehensive details on keyboard support for buttons, refer to our Keyboard Control Guide.
Visit WebAIM for keyboard techniques.
Find live examples in the A11y style guide.
Roles and attributes
Below are some key considerations to ensure that our components are fully accessible in various scenarios within your interfaces. These points outline the necessary roles and attributes to keep in mind.
Role | Attribute | Element | Usage |
---|---|---|---|
link | - | span ,img | Identifies the span /img element as a link. |
- | tabIndex="0" | span ,img | Includes the link element in the page Tab sequence. |
- | alt | img | Defines the accessible name of the link. |
- | aria-label | span | Defines the accessible name of the link. |
Resources
- W3 Link Example: Contains comprehensive details regarding the accessibility behavior of the link.
- A11y Style Guide: Gives core recommendations for accessible links.
- Mozilla Resources for Developers: Find examples of accessible links.
Other recommendations
Explore additional accessibility tips in the general Accessibility Guide.
WCAG 2.2 Guidelines
- Non-text Content: All non-text content that is presented to the user has a text alternative that serves the equivalent purpose. (Level A)
- Info and Relationships: Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)
- Headings and Labels: Headings and labels describe topic or purpose. (Level AA)
- Labels or Instructions: Labels or instructions are provided when content requires user input. (Level A)
- Name, Role, Value: For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)