# Silk

Folds of silk catching the light: smooth sheets that ripple and shift, with a bright highlight along each crest.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. The dithercn agent skill, for building any dither on the engine, is at [/.well-known/agent-skills/dithercn/SKILL.md](/.well-known/agent-skills/dithercn/SKILL.md).

<ComponentPreview src="examples/silk-demo.tsx" size="full" align="stretch" controls="silkControls">
  <SilkDemo />
</ComponentPreview>

## Installation [#installation]

<InstallBlock name="silk" />

## Usage [#usage]

```tsx
import { Silk } from "@/components/dithercn/silk";

export function Hero() {
  return (
    <section className="relative isolate min-h-[480px]">
      <Silk className="absolute inset-0 -z-10" />
      <h1>Your headline</h1>
    </section>
  );
}
```

The cloth is a height field of folds bent by slow waves. It is lit from the top left: faces turned to the light are bright, the far sides of each fold fall smoothly into shadow, and a narrow highlight runs along every crest. The folds slide and change width over time. It defaults to the 8×8 matrix, which suits its long soft gradients.

## Examples [#examples]

### Behind a headline [#behind-a-headline]

Fewer `folds`, a sharper `sheen` and an `intensity` of 0.45 keep the brightest crest below full ink.

<ComponentPreview src="examples/silk-headline.tsx" size="lg" align="stretch">
  <SilkHeadline />
</ComponentPreview>

### Champagne [#champagne]

Eight folds on a diagonal through four warm golds, from near-black to a pale cream highlight.

<ComponentPreview src="examples/silk-champagne.tsx" size="full" align="stretch">
  <SilkChampagne />
</ComponentPreview>

## Props [#props]

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `folds` | `number` | `6` | How many folds cross the box. |
| `angle` | `number` | `110` | Direction the folds run, in degrees as in CSS: 90 runs them left to right. |
| `sheen` | `number` | `0.6` | How narrow and bright the highlight on each fold is, from 0 to 1. |
| `intensity` | `number` | `1` | The brightest tone, from 0 to 1. Lower it to put text on top. |
| `palette` | `[DitherColor, DitherColor, ...DitherColor[]]` | `Paper, two tints of --dither-ink, then --dither-ink` | Colours from paper to ink: palette names such as "blue", CSS variable names, or any CSS colour. |
| `matrix` | `"bayer2" \| "bayer4" \| "bayer8" \| "blue-noise"` | `"bayer8"` | The threshold pattern. See Dither engine. |
| `cell` | `number` | `--dither-cell` | Size of one dither cell in CSS pixels. |
| `speed` | `number` | `1` | How fast the folds move. |
| `animate` | `boolean` | `true` | false draws one still frame. |
| `className` | `string` | `–` | Size and position. The cloth fills this box. |

## Notes [#notes]

* It is decorative and hidden from assistive technology. Put real text on top of it, not inside it.
* With reduced motion turned on, it draws one still frame and stops.
* It pauses when scrolled out of view or when the tab is hidden, and releases its WebGL context when far offscreen. Without WebGL it shows soft diagonal stripes in CSS.