Skip to Content
πŸŽ‰ Coral x Panda has been released πŸŽ‰ Read the Migration Guide

Link

This component provides a visual cue that indicates interactivity of plain text

Basic Usage

Note: The Link component should always be wrapped inside a Typography component, so that the Link font size and weight will inherit from the font around it.

import { Link } from '@krakentech/coral'; <Typography> <Link href="#">This is a link</Link> </Typography>

This is a link

Properties

color

<Typography> <Link href="#" color="dark"> This is a link </Link> </Typography> <Typography color="error"> <Link href="#" color="inherit"> This is a link </Link> </Typography>

This is a link

This is a link

download

<Typography> <Link href="#" download> This tells the browser to download rather than redirect </Link> </Typography>

This tells the browser to download rather than redirect

target

<Typography> <Link href="#" target="_blank"> This is a link that opens in a new window </Link> </Typography>

This is a link that opens in a new window

Responsiveness

<Typography> <Link href="#" color={{ base: "tertiary500", md: "secondary500" }}> This is a link </Link> </Typography>

This is a link

Full API

NameTypeDefault
colorResponsiveVariant<"secondary500" | "tertiary500" | "inherit">

A custom link color prop, can be used when a link is used on different background colors.

tertiary500
downloadboolean

Causes the browser to treat the linked URL as a download

hrefstring

The URL that the hyperlink points to

relstring

The relationship of the linked URL as space-separated link types.

target"_self" | "_blank" | "_parent" | "_top"

Where to display the linked URL, as the name for a browsing context (a tab, window, or iframe)

typestring

Hints at the linked URL’s format with a MIME type

onClickMouseEventHandler<HTMLAnchorElement | HTMLButtonElement>

A callback function to be triggered upon clicking the link

idstring

An optional ID to give the link

rolestring

An optional role to give the link

tostring

Link href for the router dom link

ignoreLinkComponentboolean

Ignore any router passed in ThemeProvider and ask this link to inherit normal anchor tag behaviour from the browser

false
childrenReactNode
attributesAttributes

This prop can be used to pass HTML attributes directly to the component. We currently allow passing data-* and aria-* attributes and the id. However, you can pass anything else with a type hack if necessary since this object is despread in to the component, without filtering its content.

Example usage:

AttributesProps: { 'id': 'close-button', 'aria-label': 'Close button', 'data-testid': 'close-button' };
refRef<HTMLAnchorElement> | undefined

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

keyKey | null | undefined

Design

Good to know

Choose a link when you want to redirect the user to an external site or to a document, this will usually precede or follow some text e.g β€œDon’t have an account? Sign up”. It is really important that link copy isn’t super vague, make it specific, clear and friendly.

The short answer is a button does something and a link goes somewhere. The longer answer, buttons perform an action, should attract users attention and usually encourage conversion. Links should re-direct.

Why are there two colour variations?

Our primary theme is our voltage link, this should be used 99% of the time. Our secondary ink variation is to be used on top of ice.

Component breakdown

  • Text: Button text
  • Resting colour: Voltage & Ink
  • Hover colour: Aquamarine & Blue Tang
Last updated on