# Tile

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.

Status: Stable. Group: Data.

## When to use

- Entry points on a home screen: Colour, Spacing, Buttons, each a tile with its count.
- One headline number: 86% token coverage, 12 open changes.

## When not to use

- It lists rows or holds several values. Use Panel instead.
- It reports a status inline. Use Badge instead.
- It must stand out as the main call to action. Use Button instead.

## Scenarios

### 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.

### Headline metric

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.

## Do and avoid

- Do: Give each tint one meaning on a screen: lime for ready, pink for talk.
- Avoid: Use all four tints at once with no meaning behind them.
- Do: Keep the title to a few words and the caption to one short line.
- Avoid: Wrap a paragraph into a tile; link to the page that has it.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tint` | `'lime' \| 'pink' \| 'blue' \| 'violet'` |  | Required. Picks the gradient and the ink. The tile never takes any other colour. |
| `title` | `string` |  | Required. The name or the number: Colour, 86%. |
| `caption` | `string` |  | A line under the title: 48 tokens. |
| `size` | `'md' \| 'lg'` |  | md (default) is a name such as Colour. lg is a headline number such as 86%: 34 px at weight 600. |
| `art` | `ReactNode` |  | Art in the lower end corner, 96 px square, hidden from assistive tech. It draws with the ink colour unless it is an image. |
| `artPlacement` | `'corner' \| 'top' \| 'top-end'` |  | corner (default) puts the art in the lower end corner. top centres it at the top, for a tile that holds a button below. top-end sits inside the padding at the top end, for a stat tile. |
| `artSize` | `'md' \| 'sm'` | `'md'` | md is 96 px. sm is 44 px, for a narrow tile where the art must clear the text and sit inside the padding. |
| `children` | `ReactNode` |  | Extra content under the caption, such as a button or a short list. |
| `className` | `string` |  | Extra classes on the tile, such as a height. |

## Anatomy

1. Tile (`data-part="root"`): Radius lg (22 px), 16 px padding, a vertical gradient from the tint to its wash, minimum height 144 px.
2. Title (`data-part="title"`): Text 17/24 at weight 600 in the tint ink, tracking -0.015em.
3. Caption (`data-part="caption"`): Label 13/16 at weight 500 in the same ink.
4. Art (`data-part="art"`): 96 px square in the lower end corner, bleeding 4 px past the edge. Decorative.

## Motion

| Interaction | Property | Duration | Easing | From the keyboard |
| --- | --- | --- | --- | --- |
| None | none: a static surface. A tile that links uses the link-card lift of its parent | none | out | Same. |

## Accessibility

| Keys | Action |
| --- | --- |
| Tab | A tile is not focusable. Wrap it in a link or button, or put a Chip beside it, when it opens something. |

- The art is aria-hidden: it repeats what the title says.
- The title and caption are plain paragraphs, so a tile inside a link reads as one name.

## Code

### Tile.tsx

```tsx
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>
  )
}
```

## HTML

The default example as plain HTML, for any stack. Needs nacre-theme.css.

```html
<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 [&amp;&gt;*]:size-full [&amp;&gt;*]: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>
```

## Related

- [Chip](https://enxm.me/services/design-systems/nacre/components/chip)
- [Badge](https://enxm.me/services/design-systems/nacre/components/badge)
- [Panel](https://enxm.me/services/design-systems/nacre/components/panel)
