Link
Color and style variations for anchor links
Link styles
The Link component can be used to render plain text links.
<> Learn more about{' '} <Link to="https://www.facebook.com/Thumbtack/"> Thumbtack on Facebook </Link> . </>
Secondary links
<Link theme="secondary" to="https://www.thumbtack.com/privacy/" > Privacy Policy </Link>
Tertiary links
These links render as white text with an underline. They work well on dark backgrounds.
<div style={{ color: '#ffffff' }} > Learn more about{' '} <Link theme="tertiary" to="https://www.facebook.com/Thumbtack/" > Thumbtack on Facebook </Link> . </div>
Link with an icon to the left
The Link component provides a iconLeft prop to help vertically position icons alongside text.
<Link iconLeft={<ContentActionsPhoneCallSmall />} to="https://example.com/" > Call this Pro </Link>
Link with an icon to the right
The Link component also allows an icon to the right of the text.
<Link iconRight={<ContentActionsPhoneCallSmall />} to="https://example.com/" > Call this Pro </Link>
Link with an icon that inherits color of parent
This link inherits the color of its parent with theme="inherit".
<div style={{ color: '#ffffff' }} > <Link accessibilityLabel="Share this page" iconLeft={<ContentActionsShareMedium />} theme="inherit" to="https://example.com/" /> </div>
Changing the font size
Links inherit the font size of their container.
<div style={{ fontSize: '14px' }} > Learn more about{' '} <Link to="https://www.facebook.com/Thumbtack/"> Thumbtack on Facebook </Link> . </div>
Changing the font weight
Links also inherit the font weight of their container.
<> Learn more about{' '} <span className="b"> <Link to="https://www.facebook.com/Thumbtack/"> Thumbtack on Facebook </Link> </span> . </>
Opening links in new tabs
The shouldOpenInNewTab prop will open links in a new tab. It also handles the target="_blank" security vulnerability.
<> Learn more about{' '} <Link shouldOpenInNewTab to="https://www.facebook.com/Thumbtack/" > Thumbtack on Facebook </Link> . </>
Themed links
The ThemedLink component renders <a> tags that visually look like buttons.
These are the available ThemedLink styles for use on light background colors.
<ButtonRow> <ThemedLink theme="primary" to="https://example.com/" > Primary </ThemedLink> <ThemedLink theme="secondary" to="https://example.com/" > Secondary </ThemedLink> <ThemedLink theme="tertiary" to="https://example.com/" > Tertiary </ThemedLink> <ThemedLink theme="caution" to="https://example.com/" > Caution </ThemedLink> </ButtonRow>
Use on dark backgrounds
The solid theme works well on dark backgrounds.
<ThemedLink theme="solid" to="https://example.com/" > Solid </ThemedLink>
Size options
The ThemedLink component also has a small variation.
<ButtonRow> <ThemedLink size="small" theme="primary" to="https://example.com/" > Primary </ThemedLink> <ThemedLink size="small" theme="secondary" to="https://example.com/" > Secondary </ThemedLink> <ThemedLink size="small" theme="tertiary" to="https://example.com/" > Tertiary </ThemedLink> <ThemedLink size="small" theme="caution" to="https://example.com/" > Caution </ThemedLink> </ButtonRow>
Disabled themed links
The isDisabled prop visually and functionally disables the link.
<ButtonRow> <ThemedLink isDisabled theme="primary" to="https://example.com/" > Primary </ThemedLink> <ThemedLink isDisabled theme="secondary" to="https://example.com/" > Secondary </ThemedLink> <ThemedLink isDisabled theme="tertiary" to="https://example.com/" > Tertiary </ThemedLink> <ThemedLink isDisabled theme="caution" to="https://example.com/" > Caution </ThemedLink> </ButtonRow>
Full width
<ThemedLink to="https://example.com/" width="full" > Send Quote </ThemedLink>
Full width on small screens
This link becomes full width on viewports that are smaller than our small breakpoint. The width is auto on larger screens.
<ThemedLink to="https://example.com/" width="full-below-small" > Send Quote </ThemedLink>
Icon left within the ThemedLink
<ThemedLink icon={<ContentModifierMessageSmall />} to="https://example.com/" > Send Message </ThemedLink>
Icon right within the ThemedLink
<ThemedLink iconRight={<ContentModifierMessageSmall />} to="https://example.com/" > Send Message </ThemedLink>
Props
Link
childrenContents displayed within the anchor.
TypeReact.ReactNodeaccessibilityLabelDescription of the link’s content. It is required if the link contains an icon and no descriptive text.
TypestringisDisabledFunctionally 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.
TypebooleanDefaultfalsetoPage to navigate to when the anchor is clicked.
TypestringonClickFunction to fire when clicking on the anchor. This should be used alongside the
toprop.Type() => voidonMouseEnterFunction that runs when the user hovers on the link.
Type() => voidonMouseOverFunction that runs when the user hovers on the link. Unlike
onMouseEnter,onMouseOverfires each time a child element receives focus.Type() => voidonFocusFunction that runs when the link receives focus.
Type() => voidonMouseLeaveFunction that runs when the user hovers away from the link.
Type() => voidonBlurFunction that runs when the link loses focus.
Type() => voidrelThe anchor
relattribute. Setting this value will add to any default values provided by Thumbprint for therelattribute.TypestringiconLeftIcon from Thumbprint Icons to render left of the text within
Link.TypeReact.ReactNodeiconRightIcon from Thumbprint Icons to render right of the text within
Link.TypeReact.ReactNodetargetThe anchor
targetattribute. Set this to_blankto open in a new tab, or to an arbitrary string to open the link in an<iframe>with the samename.TypestringshouldOpenInNewTabdeprecatedNote:Opens the URL in a new tab when clicked.
TypebooleanDefaultfalsethemeSets the anchor’s text color.
inheritwill make the anchor inheritcolorfrom its parent.Type'primary' | 'secondary' | 'tertiary' | 'inherit'Default'primary'dataTestIdA selector hook into the React component for use in automated testing environments.
TypestringdataTestdeprecatedA selector hook into the React component for use in automated testing environments.
Note:Deprecated in favor of the
dataTestIdpropTypestringtitleAdds the
titleattribute to the anchor. This should be used infrequently since it's better to use descriptive text inchildren.Typestring
ThemedLink
childrenContents displayed within the button.
TypeReact.ReactNodeaccessibilityLabelDescription of the link’s content. It is required if the link contains an icon and no descriptive text.
TypestringisDisabledVisually and functionally disables the button.
TypebooleanDefaultfalsetoPage to navigate to when the anchor is clicked.
TypestringonClickFunction to fire when clicking on the anchor. This should be used alongside the
toprop.Type() => voidonMouseEnterFunction that runs when the user hovers on the link.
Type() => voidonMouseOverFunction that runs when the user hovers on the link. Unlike
onMouseEnter,onMouseOverfires each time a child element receives focus.Type() => voidonFocusFunction that runs when the link receives focus.
Type() => voidonMouseLeaveFunction that runs when the user hovers away from the link.
Type() => voidonBlurFunction that runs when the link loses focus.
Type() => voidrelThe anchor
relattribute. Setting this value will add to any default values provided by Thumbprint for therelattribute.TypestringtargetThe anchor
targetattribute. Set this to_blankto open in a new tab, or to an arbitrary string to open the link in an<iframe>with the samename.TypestringshouldOpenInNewTabOpens the URL in a new tab when clicked.
TypebooleanDefaultfalseiconIcon from Thumbprint Icons to render left within the button. It must be one of the
smallicons.TypeReact.ReactNodeiconRightIcon from Thumbprint Icons to render right within the button. It must be one of the
smallicons.TypeReact.ReactNodethemeControls the button's background, text, and border theme.
Type'primary' | 'secondary' | 'tertiary' | 'caution' | 'solid'Default'primary'sizeChanges the button's
line-height,padding,border-radius, andfont-size.Type'small' | 'large'Default'large'widthThemed links are as wide as the content that is passed in. The
fulloption will expand the width to100%on all screens.full-below-smallwill expand the width to 100% on devices smaller than oursmallbreakpoint.Type'auto' | 'full' | 'full-below-small'Default'auto'dataTestIdA selector hook into the React component for use in automated testing environments.
TypestringdataTestdeprecatedA selector hook into the React component for use in automated testing environments.
Note:Deprecated in favor of the
dataTestIdpropTypestringtitleAdds the
titleattribute to the anchor. This should be used infrequently since it's better to use descriptive text inchildren.Typestring