Skip to content
Norn
Menu

norn-link-button

A link styled as a button, for a call to action. It navigates, so it stays a link: use a <button> for an action on the page. The default slot is the link text, and may hold a norn-icon. A hover and a press take a layer of the text color over the background, and the text is never underlined.

<norn-link-button> a component, from @allons-y/webc-patterns

Examples

Color scheme
Width

Open on its own

Source
<norn-link-button @href="#start">Get started</norn-link-button>
Color scheme
Width

Open on its own

Source
<norn-link-button @href="#next">Next step <norn-icon @name="arrow-end"></norn-icon></norn-link-button>
Color scheme
Width

Open on its own

Source
<norn-link-button @href="#sponsor" @variant="secondary">Sponsor</norn-link-button>
Color scheme
Width

Open on its own

Source
<norn-link-button @href="#feed" @icon-only>
	<template slot="label" webc:nokeep>Next step</template>
	<norn-icon @name="arrow-end"></norn-icon>
</norn-link-button>
Color scheme
Width

Open on its own

Source
<p>
	<norn-link-button webc:for="(variant, index) of $data.csf.argTypes.props.variant.options" :@href="['#start', '#source', '#changes'][index] || '#'" :@variant="variant"><span webc:nokeep @text="['Get started', 'View the source', 'Read the changes'][index] || variant"></span></norn-link-button>
</p>
Color scheme
Width

Open on its own

Source
<div style="display: grid; gap: 1.5rem">
	<div style="display: grid; gap: 0.5rem">
		<p><code>variant = primary</code></p>
		<div>
			<norn-link-button @href="#start" @variant="primary">Get started</norn-link-button>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>variant = secondary</code></p>
		<div>
			<norn-link-button @href="#start" @variant="secondary">Get started</norn-link-button>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>variant = quiet</code></p>
		<div>
			<norn-link-button @href="#start" @variant="quiet">Get started</norn-link-button>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>tone = current</code></p>
		<div>
			<norn-link-button @href="#start" @tone="current">Get started</norn-link-button>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>icon-only = true</code></p>
		<div>
			<norn-link-button @href="#start" @icon-only>Get started</norn-link-button>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>icon-only = false</code></p>
		<div>
			<norn-link-button @href="#start">Get started</norn-link-button>
		</div>
	</div>
</div>

Props

Write them with the @ prefix, and :@ for an expression.

NameTypeDescription
@href required string The link's URL.
@variant string primary, a filled accent; secondary, a 1px outline; or quiet, text with no border. Falls back to primary.
@tone string accent, the accent text color; or current, the surrounding text color, for a secondary or quiet button inside a colored container such as norn-notice. A primary button keeps its fill and text.
@icon-only boolean Show only the icon, in a square at the control height. The default slot holds the norn-icon, and the label slot the link's name, read but not shown.

Slots

NameDescription
default The link text, which may hold a norn-icon.
label The link's name for @icon-only, such as <span slot="label">Subscribe by RSS</span>.

Tokens

The global tokens from tokens.json the component reads. Set one in a project's tokens.css to change it everywhere.

Type a value to try it in every example above. Reset puts the default back.

Token Type Default Override
--norn-ui-accentThe brand color, shared by every component. <color> #2346d4
--norn-ui-border-radiusCorner radius. <length> 6px
--norn-ui-state-hoverShare of the text color mixed into the background while the pointer is over a control. <percentage> 8%
--norn-ui-state-pressShare of the text color mixed into the background while a control is pressed, and of the accent on a selected or current item. <percentage> 12%
--norn-ui-motion-durationLength of a state change, such as a hover layer. <time> 150ms
--norn-ui-motion-easingEasing for every transition. <easing-function> cubic-bezier(0.2, 0, 0, 1)
--norn-ui-control-heightHeight of a button, field, or tab. A component raises it to 2.75rem for a coarse pointer. <length> 2.25rem
--norn-text-accentThe accent for text and links: darkened in light mode, lightened in dark mode. The lightness caps keep any accent at 4.5:1 or better. <color> light-dark(oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 82%, black) min(l, 0.5) c h), oklch(from color-mix(in oklch, var(--norn-ui-accent, #2346d4) 55%, white) max(l, 0.72) c h))
--norn-text-on-accentBlack or white text for an accent background, whichever contrasts more: at least 4.58:1. Switches at relative luminance 0.1791. <color> color(from var(--norn-ui-accent, #2346d4) xyz-d65 calc(0.95047 * clamp(0, calc((0.1791 - y) * 1000000), 1)) clamp(0, calc((0.1791 - y) * 1000000), 1) calc(1.08883 * clamp(0, calc((0.1791 - y) * 1000000), 1)))
--norn-space-2xsSmallest spacing step. <length> 0.25rem
--norn-space-xsExtra small spacing step. <length> 0.5rem
--norn-space-mMedium spacing step. <length> 1.25rem