Token categories
A Panel holds a row of two tiles, Colour in lime and Spacing in blue, each with the number of tokens and a glass icon.
Components / DataStable
A soft pastel block that names one thing, with a short caption and art in the corner. It opens a screen or shows a headline number.
Colour
48 tokens
import type { ReactNode } from 'react'
// Nacre Tile: a soft pastel block that names one thing and shows its main number or a piece of art. React plus
// Tailwind classes only; needs nacre-theme.css. The fill is a vertical gradient from the tint to its wash, and the
// text uses the tint's own ink, so it stays readable in both themes. No motion. Put tiles in a Panel, two to a row.
export type TileTint = 'lime' | 'pink' | 'blue' | 'violet'
export type TileSize = 'md' | 'lg'
export type TileArtPlacement = 'corner' | 'bleed' | 'top' | 'top-end'
export type TileArtSize = 'md' | 'sm' | 'lg'
export type TileProps = {
tint: TileTint
/** The name or number. Leave it out for a tile that is only art and one action. */
title?: string
caption?: string
/** md is a name (Colour); lg is a headline number (86%). */
size?: TileSize
/** Art in the lower end corner: a 3D icon, an illustration, a ring. Decorative, so it is hidden from assistive tech. */
art?: ReactNode
/** corner (default) puts the art in the lower end corner, top centres it at the top of the tile. */
artPlacement?: TileArtPlacement
/** md is 112 px; sm is 44 px, for a narrow tile where the art must sit inside the padding and clear the text; lg is 128 px, meant to bleed off the corner. */
artSize?: TileArtSize
/** Extra content under the caption, such as a button or a short list. */
children?: ReactNode
className?: string
}
const tints: Record<TileTint, string> = {
lime: 'bg-linear-to-b from-tint-lime to-tint-lime-wash text-tint-lime-ink',
pink: 'bg-linear-to-b from-tint-pink to-tint-pink-wash text-tint-pink-ink',
blue: 'bg-linear-to-b from-tint-blue to-tint-blue-wash text-tint-blue-ink',
violet: 'bg-linear-to-b from-tint-violet to-tint-violet-wash text-tint-violet-ink',
}
const titles: Record<TileSize, string> = {
md: 'text-[1.0625rem] leading-6 font-[600] tracking-[-0.015em]',
lg: 'text-[1.875rem] leading-[1.15] font-[600] tracking-[-0.025em]',
}
const arts: Record<TileArtPlacement, string> = {
corner: '-end-1 -bottom-1',
bleed: '-end-4 -bottom-4',
top: 'top-1 start-1/2 -translate-x-1/2 rtl:translate-x-1/2',
'top-end': 'top-2.5 end-3',
}
const artSizes: Record<TileArtSize, string> = { md: 'size-28', sm: 'size-11', lg: 'size-32' }
export function Tile({ tint, title, caption, size = 'md', art, artPlacement = 'corner', artSize = 'md', children, className = '' }: TileProps) {
return (
<div data-part="root" data-tint={tint} className={`relative isolate flex min-h-36 min-w-0 flex-col overflow-hidden rounded-lg p-4 ${tints[tint]} ${className}`}>
{title && <p data-part="title" className={titles[size]}>{title}</p>}
{caption && <p data-part="caption" className="text-label font-[500]">{caption}</p>}
{children}
{art && (
<div data-part="art" aria-hidden="true" className={`pointer-events-none absolute grid ${artSizes[artSize]} place-items-center [&>*]:size-full [&>*]:object-contain ${arts[artPlacement]}`}>
{art}
</div>
)}
</div>
)
}
<div data-part="root" data-tint="lime" class="relative isolate flex min-h-36 min-w-0 flex-col overflow-hidden rounded-lg p-4 bg-linear-to-b from-tint-lime to-tint-lime-wash text-tint-lime-ink w-44">
<p data-part="title" class="text-[1.0625rem] leading-6 font-[600] tracking-[-0.015em]">Colour</p>
<p data-part="caption" class="text-label font-[500]">48 tokens</p>
<div data-part="art" aria-hidden="true" class="pointer-events-none absolute grid size-28 place-items-center [&>*]:size-full [&>*]:object-contain -end-1 -bottom-1">
<svg viewBox="0 0 96 96" fill="none" stroke="currentColor" stroke-width="9" stroke-linecap="round">
<circle cx="48" cy="48" r="32" opacity="0.22"></circle>
<path d="M48 16a32 32 0 0 1 30.4 41.8"></path>
</svg>
</div>
</div>/* The Tailwind theme lines Tile uses. They come from nacre-theme.css (Resources, Tokens), which also defines
the --nx-* values these lines point at. Import that file once; this list is what this component needs from it. */
@theme inline {
--color-tint-lime: var(--nx-tint-lime);
--color-tint-lime-wash: var(--nx-tint-lime-wash);
--color-tint-lime-ink: var(--nx-tint-lime-ink);
--color-tint-pink: var(--nx-tint-pink);
--color-tint-pink-wash: var(--nx-tint-pink-wash);
--color-tint-pink-ink: var(--nx-tint-pink-ink);
--color-tint-blue: var(--nx-tint-blue);
--color-tint-blue-wash: var(--nx-tint-blue-wash);
--color-tint-blue-ink: var(--nx-tint-blue-ink);
--color-tint-violet: var(--nx-tint-violet);
--color-tint-violet-wash: var(--nx-tint-violet-wash);
--color-tint-violet-ink: var(--nx-tint-violet-ink);
--text-label: 0.8125rem;
--text-label--line-height: 1rem;
--text-label--letter-spacing: 0em;
--text-label--font-weight: 600;
--spacing: 0.25rem;
--radius-lg: 1.375rem;
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
}
A Panel holds a row of two tiles, Colour in lime and Spacing in blue, each with the number of tokens and a glass icon.
A single violet tile reads 12 open changes with a ring in the corner. It is the only tile on the screen, so the number is the first thing seen.
DoGive each tint one meaning on a screen: lime for ready, pink for talk.
Don'tUse all four tints at once with no meaning behind them.
DoKeep the title to a few words and the caption to one short line.
Don'tWrap a paragraph into a tile; link to the page that has it.
Colour
48 tokens
Colour
48 tokens