Web and native

Link in kanso-ui 0.59.0, for React.

import { Link } from '@kanso-labs/kanso-ui'

A navigational link that takes its size and face from the text it sits in.

Material Design has no inline link, so this follows the nearest component, the text button: its label's primary colour on no container, and the disabled treatment every page gives content. What says it can be followed is its own underline, a 1px rule that turns fully primary on hover.

What you provide

  • children: the link text, naming where it leads.
  • href. Without one, or while disabled, it renders a span announced as a link, since a disabled anchor is no link at all.
  • Surrounding text, usually a Text, to set its size and face.

Props

PropTypeDefaultDescription
childrenReactNode—
classNameClassNameOrFunction<LinkRenderProps>—A function may compute the class from the link's render state.
styleStyleOrFunction<LinkRenderProps>—A function may compute the style from the link's render state.
tone'inherit' | 'primary''primary'Which colour to render in. `primary` is Kanso's link, in the product's accent; `inherit` is its quiet link, in the colour of the text around it, for supporting lines and captions where the accent would compete with the screen's one highlighted action.
underline'always' | 'hover' | 'none''always'When to draw the rule. `always` is Kanso's link, underlined in every state, so colour is never the only thing separating it from the sentence. `hover` and `none` are deprecated, since Kanso never drops the underline; for a calmer line, use `tone="inherit"` instead.

Also takes the props of AriaAttributes, LinkDOMProps.

Example

import { Link, Text } from '@kanso-labs/kanso-ui'

<Text block variant="bodyLarge">
  A paragraph of supporting copy with <Link href="#first">a link inside it</Link>.
</Text>

<Link href="#first" tone="inherit" underline="hover">First item</Link>

The design’s classes

k-link, k-link--quiet.

Maps to Link in kanso-ui and react-native-kanso-ui.