Clickable text element used to navigate to page section, another page or open an overlaid window such as modal dialog or popover
Display within body copy for articles, hub cards, footer, or recommendations.
Display independently with a Call to Action. Some examples are for finding a store, or viewing related products.
Display standalone link with icon on left.
Display standalone link with icon on right.
Use the tag
prop to render a button that looks like a link. Can be used inline with other text. Should trigger an action rather than navigate to a new page.
To render a link that has the spacing and sizing of a button, use CdrButton with link modifier. To visually render a button that behaves like a link, use a CdrButton with link tag.
Many WCAG requirements are contextual to their implementation. To ensure that usage of this component complies with accessibility guidelines you are responsible for the following:
<button>
element for the tag
prop when there is no href
attribute that can be applied to the link. Examples are:
<a>
element for a link that navigates the user to the location specified by the href
attribute <cdr-link>
Start here <span class="cdr-sr-only">for help finding the proper sleeping bag </span>
</cdr-link>
href
attribute. Empty href
attributes are not considered true links and are not accessible to keyboard users.alt
attribute acts as the link text. Describe the action or hyperlink that the image representsaria-label
or aria-labelledby
to provide a more descriptive name when the text content of the link cannot be changed.This component has compliance with following WebAIM’s accessibility guidelines:
Use link labels that describe the link’s destination when clicked or tapped:
alt
text that can be read by screen readersalt
text could be “Learn more about pick up in store”When making decisions about using this component styled as a link or a button, consider the following:
Links | Buttons |
---|---|
Answers the question, "Where can I go" | Answers the question, "What can I do" |
Search engine crawlers can follow anchors for links (<a> ) | Search engine crawlers cannot follow links that are submitted by input or button |
Default keyboard behavior is triggered using the Enter key | Default keyboard behavior is triggered using the Space or Enter key |
Cannot be disabled like buttons but can be made inert with tabindex="-1" and aria-hidden="true" | Can be disabled with disabled attribute |
Apply the following use cases when deciding when to use links as anchors or buttons:
Links | Buttons |
---|---|
Navigating user to a new page or view | Toggling a display to full screen |
Changing the URL | Opening a modal window |
Causing a browser redraw/refresh | Triggering a popup menu |
Supporting internal page jumps | Playing media content |
WebAIM: Links and Hypertext Introduction to Links and Hypertext (opens new window)
This component will bind any attribute that a native HTML anchor element (opens new window) accepts.
tag
name
string
type
'a'
default
Sets valid HTML element tag. Possible values: { ‘a’ | ‘button’ }
modifier
name
string
type
N/A
default
Modifies the style variant for this component. Possible values: { ‘standalone’ }
href
name
string
type
'#'
default
Sets URL to ‘cdr-link’ href property. The tag prop requires value of <a>.
Find more information about using Slots in the article Installing Cedar.
default
name
Sets the innerHTML for CdrLink. This includes text and html markup for icons.
All event listeners are passed through to/from the component.
By default, the component renders using an anchor element and requires an href
attribute to render a valid, accessible link.
<cdr-link href="http://rei.com">
Visit REI
</cdr-link>
Use the tag
prop to render the link as a <button>
element that appears as a link, but without an href
attribute.
<cdr-link tag="button">
Show Details
</cdr-link>
Following variants are available to the cdr-link
modifier attribute:
Value | Description |
---|---|
'standalone' | Change visual presentation by removing the underline for the normal state. Intended to be use for an independent Call to Action to expand content, remove filters, or provide additional information. |