Link API
Import
Section titled “Import”import { Link } from '@cimpress-ui/react';Accessibility notes
Section titled “Accessibility notes”Link component can be activated by pressing the Enter key, similar to a native HTML link.
Style inheritance
Section titled “Style inheritance”Links rendered within the text component will inherit the style of the surrounding text. Certain styles like color and text decoration will not be inherited, so that links remain visually distinct.
The example below renders two paragraphs of text with nested links. Notice that the links match the style of the containing paragraph, even though the link markup doesn’t change.
This paragraph contains a nested link that inherits its style.
This paragraph also contains a nested link that inherits its style.
import { Link, Stack, Text } from '@cimpress-ui/react';
export default function Demo() { return ( <Stack gap={16}> <Text as="p" variant="title-5" tone="base"> This paragraph contains a <Link href="#">nested link</Link> that inherits its style. </Text>
<Text as="p" variant="medium" tone="subtle" fontStyle="italic"> This paragraph also contains a <Link href="#">nested link</Link> that inherits its style. </Text> </Stack> );}API reference
Section titled “API reference”Displays a textual link that allows users to navigate to another page or resource.
- Ref<HTMLAnchorElement>
-
The
reftype for this component.
LinkProps
- string
href *
Section titled “ href * ” -
A URL to link to.
- ReactNode
children *
Section titled “ children * ” -
Text to display. Allows nesting other typography components.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- undefined
routerOptions
Section titled “ routerOptions ” -
Options for the configured client side router.
- ReactNode
iconStart
Section titled “ iconStart ” -
An icon displayed before the link text.
- ReactNode
iconEnd
Section titled “ iconEnd ” -
An icon displayed after the link text.
- 'small' | 'medium' | 'title-1' | 'title-2' | 'title-3' | 'title-4' | 'title-5' | 'title-6' | 'body' | 'body-semibold' | 'medium-semibold' | 'small-semibold'
variant
Section titled “ variant ” -
Determines the visual variant of text.
- 'normal' | 'italic'
fontStyle
Section titled “ fontStyle ” -
Whether the font should be styled with a normal or italic face.
- 'center' | 'end' | 'start' | 'justify'
alignment
Section titled “ alignment ” -
Horizontal alignment of text.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the link is disabled.
- string
hrefLang
Section titled “ hrefLang ” -
Hints at the human language of the linked URL. SeeMDN.
- HTMLAttributeAnchorTarget
target
Section titled “ target ” -
The target window for the link. See MDN.
- string
-
The relationship between the linked resource and the current page. See MDN.
- string | boolean
download
Section titled “ download ” -
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
- string
-
A space-separated list of URLs to ping when the link is followed. See MDN.
- HTMLAttributeReferrerPolicy
referrerPolicy
Section titled “ referrerPolicy ” -
How much of the referrer to send when following the link. See MDN.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.