Skip to content
Norn
Menu

norn-card

A card: a heading, then its text, on a raised surface. A heading link makes the whole card a link, and a card with an accent has a 2px line along its top. Pass the heading and body in the default slot, as in <norn-card><h3><a href="…">Title</a></h3><p>…</p></norn-card>. Pick the heading level for the outline: h3 under an h2. A link in the heading is stretched over the card, so the card is one target. The pointer over the card takes a hover layer, and focus on the link draws the ring around the card. The link is not underlined until the pointer is over it. In a norn-card-grid the cards share their rows: the first child, the second, and the third (a footer, such as a link) each take a row shared with the neighboring cards, so they line up. A card with a fourth child lays out on its own.

<norn-card> a container, from @allons-y/webc-patterns

Examples

Color scheme
Width

Open on its own

Source
<norn-card>
	<h3>Plain card</h3>
	<p>A short line of body text.</p>
</norn-card>
Color scheme
Width

Open on its own

Source
<norn-card>
	<h3><a href="https://example.com/">Linked card</a></h3>
	<p>A short line of body text.</p>
</norn-card>
Color scheme
Width

Open on its own

Source
<norn-card>
	<h3>Configure the build for a project with several workspaces and a shared theme</h3>
	<p>Each workspace keeps its own pages and data. The shared theme sets the colors, the type, and the spacing once, and every workspace follows it.</p>
</norn-card>
Color scheme
Width

Open on its own

Source
<norn-card>
	<template slot="image" webc:nokeep><img src="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 16 9%22%3E%3Crect width=%2216%22 height=%229%22 fill=%22%23c9ced8%22/%3E%3C/svg%3E" alt=""></template>
	<h3><a href="https://example.com/">Card with an image</a></h3>
	<p>A short line of body text.</p>
</norn-card>
Color scheme
Width

Open on its own

Source
<norn-card>
	<h3>Card with a footer link</h3>
	<p>A short line of body text.</p>
	<p><a href="https://example.com/">Read the post</a></p>
</norn-card>
Color scheme
Width

Open on its own

Source
<norn-card-grid>
	<li>
		<norn-card>
			<h3>Three children</h3>
			<p>A short line of body text.</p>
			<p><a href="https://example.com/">Read more</a></p>
		</norn-card>
	</li>
	<li>
		<norn-card>
			<h3>Four children</h3>
			<p>A short line of body text.</p>
			<p>A second paragraph.</p>
			<p><a href="https://example.com/">Read more</a></p>
		</norn-card>
	</li>
</norn-card-grid>
Color scheme
Width

Open on its own

Source
<norn-card-grid>
	<li>
		<norn-card @accent="accent">
			<h3><a href="https://example.com/">An accent line</a></h3>
			<p>A short line of body text.</p>
		</norn-card>
	</li>
	<li>
		<norn-card>
			<h3><a href="https://example.com/">No accent</a></h3>
			<p>A short line of body text.</p>
		</norn-card>
	</li>
</norn-card-grid>
Color scheme
Width

Open on its own

Source
<div style="display: grid; gap: 1.5rem">
	<div style="display: grid; gap: 0.5rem">
		<p><code>accent = accent</code></p>
		<div>
			<norn-card @accent="accent">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>accent = info</code></p>
		<div>
			<norn-card @accent="info">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>accent = success</code></p>
		<div>
			<norn-card @accent="success">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>accent = warning</code></p>
		<div>
			<norn-card @accent="warning">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>accent = danger</code></p>
		<div>
			<norn-card @accent="danger">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>title-face = mono</code></p>
		<div>
			<norn-card @title-face="mono">
				<h3>Plain card</h3>
				<p>A short line of body text.</p>
			</norn-card>
		</div>
	</div>
</div>

Props

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

NameTypeDescription
@accent string A 2px line along the top, in a global color: accent takes --norn-ui-accent, and info, success, warning, and danger take the matching --norn-status-* color. none draws no line.
@title-face string mono sets the heading in the mono face, as for package names.

Slots

NameDescription
default The heading, then the body.
image An image across the top of the card, cropped to 16:9, such as <img slot="image" src="…" alt="">. A card with an image lays out on its own, so keep image cards in a row of their own.

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-focus-widthFocus ring width. One ring on every focusable element. <length> 2px
--norn-ui-focus-offsetGap between an element and its focus ring. An element the ring would clip draws it inset, at the negative of this. <length> 2px
--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-surface-raisedRaised surface. <color> light-dark(hsl(40, 14%, 96%), #242932)
--norn-text-mutedSecondary text color. <color> light-dark(#4b5160, #a4abba)
--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-font-headingHeading face. Follows the body face until the project sets one. <font-family> var(--norn-font-body, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif)
--norn-font-monoCode face. <font-family> ui-monospace, SFMono-Regular, Menlo, Consolas, monospace
--norn-font-size-mBody text. <length> 1rem
--norn-font-size-lLede, card title, and third-level heading. <length> 1.25rem
--norn-space-sSmall spacing step. <length> 0.75rem
--norn-space-mMedium spacing step. <length> 1.25rem
--norn-status-infoInformation. The color of a note or an information notice. <color> light-dark(#1b4fc4, #8fb0ff)
--norn-status-successSuccess. The color of a tip, a success notice, and a copied mark. <color> light-dark(#0b6b3a, #7ed6a1)
--norn-status-warningWarning. <color> light-dark(#9a4a00, #ffb36b)
--norn-status-dangerDanger. The color of a caution and an error. <color> light-dark(#b42318, #ff8a80)