Components
Color and style variations for anchor links.
| Version: | 14.18.2 •View source•Changelog•Report issue | |
|---|---|---|
| Install: | yarn add @thumbtack/thumbprint-react | |
| Import: | import { Link, ThemedLink } from '@thumbtack/thumbprint-react'; | |
The Link component can be used to render plain text links.
These links render as white text with an underline. They work well on dark backgrounds.
The Link component provides a iconLeft prop to help vertically position icons alongside text.
The Link component also allows an icon to the right of the text.
This link inherits the color of its parent with theme="inherit".
Links inherit the font size of their container.
Links also inherit the font weight of their container.
The shouldOpenInNewTab prop will open links in a new tab. It also handles the target="_blank" security vulnerability.
The ThemedLink component renders <a> tags that visually look like buttons.
These are the available ThemedLink styles for use on light background colors.
The solid theme works well on dark backgrounds.
The ThemedLink component also has a small variation.
The isDisabled prop visually and functionally disables the link.
This link becomes full width on viewports that are smaller than our small breakpoint. The width is auto on larger screens.
Anchor link that renders as text.
childrenContents displayed within the anchor.
React.ReactNodeaccessibilityLabelDescription of the link’s content. It is required if the link contains an icon and no descriptive text.
stringisDisabledFunctionally disables the anchor. We discourage the use of this prop since it is difficult to visually indicate that a link is disabled. Consider not rendering the link if it is not interactive.
booleanfalsetoPage to navigate to when the anchor is clicked.
stringonClickFunction to fire when clicking on the anchor. This should be used alongside the to prop.
() => voidonMouseEnterFunction that runs when the user hovers on the link.
() => voidonMouseOverFunction that runs when the user hovers on the link. Unlike onMouseEnter, onMouseOver
fires each time a child element receives focus.
() => voidonFocusFunction that runs when the link receives focus.
() => voidonMouseLeaveFunction that runs when the user hovers away from the link.
() => voidonBlurFunction that runs when the link loses focus.
() => voidrelThe anchor rel attribute. Setting this value will add to any default values provided by
Thumbprint for the rel attribute.
stringiconLeftIcon from Thumbprint Icons to render left of the text within Link.
React.ReactNodeiconRightIcon from Thumbprint Icons to render right of the text within Link.
React.ReactNodetargetThe anchor target attribute. Set this to _blank to open in a new tab, or to an arbitrary
string to open the link in an <iframe> with the same name.
stringshouldOpenInNewTabbooleanfalsethemeSets the anchor’s text color.
inherit will make the anchor inherit color from its parent.
This prop can be one of the following 4 types:
'primary''secondary''tertiary''inherit''primary'dataTestIdA selector hook into the React component for use in automated testing environments.
stringdataTestA selector hook into the React component for use in automated testing environments.
Note: Deprecated in favor of the `dataTestId` prop
stringtitleAdds the title attribute to the anchor. This should be used infrequently since it’s better
to use descriptive text in children.
stringAnchor link that visually looks like a button.
childrenContents displayed within the button.
React.ReactNodeaccessibilityLabelDescription of the link’s content. It is required if the link contains an icon and no descriptive text.
stringisDisabledVisually and functionally disables the button.
booleanfalsetoPage to navigate to when the anchor is clicked.
stringonClickFunction to fire when clicking on the anchor. This should be used alongside the to prop.
() => voidonMouseEnterFunction that runs when the user hovers on the link.
() => voidonMouseOverFunction that runs when the user hovers on the link. Unlike onMouseEnter, onMouseOver
fires each time a child element receives focus.
() => voidonFocusFunction that runs when the link receives focus.
() => voidonMouseLeaveFunction that runs when the user hovers away from the link.
() => voidonBlurFunction that runs when the link loses focus.
() => voidrelThe anchor rel attribute. Setting this value will add to any default values provided by
Thumbprint for the rel attribute.
stringtargetThe anchor target attribute. Set this to _blank to open in a new tab, or to an arbitrary
string to open the link in an <iframe> with the same name.
stringshouldOpenInNewTabOpens the URL in a new tab when clicked.
booleanfalseiconIcon from Thumbprint Icons to render left within the
button. It must be one of the small icons.
React.ReactNodeiconRightIcon from Thumbprint Icons to render right within the
button. It must be one of the small icons.
React.ReactNodethemeControls the button’s background, text, and border theme.
This prop can be one of the following 5 types:
'primary''secondary''tertiary''caution''solid''primary'sizeChanges the button’s line-height, padding, border-radius, and font-size.
This prop can be one of the following 2 types:
'small''large''large'widthThemed links are as wide as the content that is passed in. The full option will
expand the width to 100% on all screens. full-below-small will expand the width to 100%
on devices smaller than our small breakpoint.
This prop can be one of the following 3 types:
'auto''full''full-below-small''auto'dataTestIdA selector hook into the React component for use in automated testing environments.
stringdataTestA selector hook into the React component for use in automated testing environments.
Note: Deprecated in favor of the `dataTestId` prop
stringtitleAdds the title attribute to the anchor. This should be used infrequently since it’s better
to use descriptive text in children.
string