# Grainy Gradient (`grainy-gradient`)

> Near-white pages, light black display type and hairline rails, with colour given only to film-grained gradients and product renders, set like a headphone brand's own launch page.

This is a worked example: one concept, built for one fictional client. Study how its concept turned into decisions and borrow the craft. Do not ship its surface (palette, motifs, component looks) for a different client unless your own concept, drawn from that client's world, leads to the same place.

- Chinese name: 颗粒渐变. 近白页面、黑色细体大字和发丝细线，颜色只给带胶片颗粒的渐变和产品渲染图，像一家耳机品牌自己的发布页。
- Category: Modern. Tags: Premium, Calm, Light, Sans-serif, Grid, Gradient, Texture, 3D render, Micro-interactions, WebGL.
- Live page: [English](/en/sites/grainy-gradient/full/) · [Chinese](/sites/grainy-gradient/full/) · [viewer with desktop and mobile views](/en/sites/grainy-gradient/)
- Built with Astro, React, TypeScript and Tailwind CSS 4, plus Paper Shaders, Magic UI, Motion.

## Where the concept came from

From Afterglow's own material: the three noise modes on the earbuds (Quiet, Aware, Off), the cancelling curve measured in an anechoic chamber, the decibel levels of planes, metros, streets and offices, studio shots of the two models, nine rows of specs and the listening rooms. The grainy gradients come from long-exposure light trails and dusk skies; in the hero the field changes colour and composition with the noise mode.

## When it fits

Good for:
- Consumer electronics such as earbuds, speakers and wearables: one lead product, one feature to demonstrate and one spec table fill the page.
- Smart-hardware and small-appliance brands selling overseas that need a refined page with specs, prices and channels that read at a glance.
- Software and AI products: with nothing physical to shoot, grained gradients provide the large colour fields and interface screenshots sit on them.

Avoid when:
- Heritage, handmade and rural brands: the gradients and light type read as a tech company.
- Loud promotional pages: a black-and-white interface and light type cannot carry discounts and countdowns.
- Companies without good product images: the gradient is only the ground, and without a sharp product on it the page is just a blur of colour.

Industry fit (1-5): Export factory 4, Creative brand 4, Attraction 2, Hotel & homestay 2, Education 2, Tour guide 1, Artisan 1, Restaurant 1, Farm produce 1.

## Adapting it to another client

Keep:
- A black, white and grey interface: buttons, headings, tables and charts in ink and greys, with colour only in large grained gradient fields and the product renders.
- One live demo tied to what the product does: here, switching noise modes, with the gradient taking new colours and flowing into a new composition before it settles; the interface is one readout and three buttons, with no narration.
- The headline names the product and category, section headings are nouns like the navigation, and specs are set out as a plain table: cancelling depth, battery, weight, microphones, codecs.
- Light display type inside hairline rails, carried by size and space, with product renders large enough to read at a glance.

Change:
- The gradient colours belong to these earbuds: navy and apricot for Quiet, deep brown and orange for Aware, slate for Off. For another client take colours from its product, materials and settings, never the default purple-blue.
- The noise-mode switch belongs to headphones; demonstrate the client product's own states instead: a speaker's volume, a lamp's colour temperature, a purifier's fan speeds.
- The ambient-noise table and the anechoic curve are acoustic data; swap in the client trade's own measurements and charts.

## Essentials

- **Color.** Near-white #fafaf9 and ink #0a0a0a, body text #3d3c3a, secondary text #6e6c68, hairlines #e8e6e2, panels #f2f1ee. Colour comes only in large fields: the live grained gradient in the hero (navy #0b1640 with apricot #f0a27e for Quiet, deep brown #3a1306 with orange #d9541f for Aware, slate #1c2330 for Off) and the static gradient images in the section cards. Every primary button is ink with white text; secondary buttons are white with a hairline or an ink outline, and the selected mode on the hero card is white with ink text. Dark gradient cards get a translucent #121a30 veil under white type, about 7:1 for body text; the pastel Buy card gets white washes from the top-left corner and the bottom under ink type, at 4.5:1 or more; the lower part of the hero card has a black scrim fading from 65% to nothing, so the readout stays legible wherever the gradient flows. The chart is a solid ink line and a dashed grey one, with no colour.
- **Type.** Geist Variable for Latin: display at weight 380, −0.045em tracking and 0.98 line height, the product name up to 8rem and section headings up to 5rem; readouts and decibel figures at 400 and −0.03em. Noto Sans SC Variable for Chinese: display at 300, −0.01em and line height 1.14, readouts at 350; body 15–17 px at line height 1.75–1.8. Product names, models and decibel figures stay in Geist on the Chinese page (marked lang="en"). Geist Mono only on the chart axes. Headings are nouns, with no italic.
- **Layout.** A 1280 px column framed by hairline rails, a hairline between sections and 20 px card radii. The hero sets the product name and category in two lines across eight columns, with one line of specs, the buy button and the price in the other four; below it sits the full-width live card (4:5 on phones, 16:10 on tablets, 23:10 on desktop) with the product centred, the readout bottom left and the three modes bottom right. Noise cancelling splits seven to five: a gradient card with adaptive cancelling and a four-row decibel table, and a light panel with the measured curve. Models uses the two product tiles as table headers over nine spec rows; on phones each label takes its own line above the two values. News is three cards that swipe sideways on phones. Where to buy is one full-width pastel gradient card, then three columns: service, listening rooms and the flagship address.
- **Imagery.** Studio-grade renders of the two models, the case and both earbuds in three-quarter view, keyed from a green screen to transparent PNGs and set on the gradients with a two-layer drop shadow, above the grain so they stay sharp. The gradient grounds are long-exposure light trails and dusk skies under a tiled 256 px noise texture (overlay blend at 50%). Only the listening-room photograph goes without grain.
- **Motion.** The hero headline and buy button have no entrance and are final at first paint; the noise-cancelling and news blocks fade up 14 px with BlurFade. The hero gradient holds a still frame with no loop; switching modes swaps its colours and flows the field over 0.9 s into that mode's composition (frame 2400, 1200, 3600) while the layer clears from a 28 px blur. The canvas renders at a pixel ratio of at most 1.5 (1 on standard screens), and only during a switch. With reduced motion a switch changes only the colours, with no blur or flow, and content renders finished.

## Common mistakes

- Putting colour in the UI: buttons, headings, icons and charts stay black and white, with colour only in the gradients and product renders; orange or blue buttons and chart lines turn it back into a template.
- Slogan headlines and sentence headings: the headline names the product and category (Afterglow One noise-cancelling earbuds), and the sections are Noise cancelling, Models, News and Where to buy.
- Letting the gradient stand in for the product: the gradient is only the ground, the product sits on it sharply, and the grain goes beneath the product or white earbuds look like sandpaper.
- Propping it up with fake UI: drop chat bubbles, stats strips, now-playing track names and scroll hints; the scenes are a plain decibel table and the mode card carries only the readout and three buttons.
- Too many live shaders, run too hard: only the hero is live, and everything else is a static gradient image under a noise texture; even the hero holds a still frame and renders only during a mode switch, at a pixel ratio of at most 1.5, because a 60 fps loop at device resolution ties up the main thread. Keep the gradients soft and the grain fine.

## Design tokens

| Token | Value | Role |
| --- | --- | --- |
| `--color-paper` | `#fafaf9` | Page ground |
| `--color-stone` | `#f2f1ee` | The chart card and the Studio panel |
| `--color-hairline` | `#e8e6e2` | Rails, section rules and table rows |
| `--color-mute` | `#6e6c68` | Secondary text and the previous model's dashed curve |
| `--color-graphite` | `#3d3c3a` | Body text, the hero category line and the black buttons on hover |
| `--color-ink` | `#0a0a0a` | Headings, primary buttons and the measured curve |

Semantic colors with shadcn/ui names, ready for `globals.css`:

```css
:root {
  --background: #fafaf9;
  --foreground: #0a0a0a;
  --card: #f2f1ee;
  --primary: #0a0a0a;
  --primary-foreground: #fafaf9;
  --muted-foreground: #6e6c68;
  --border: #e8e6e2;
  --ring: #0a0a0a;
}
```

Fonts. The stacks use Fontsource family names; with Google Fonts or `next/font`, drop the " Variable" suffix. Each npm package holds the CSS and its unicode-range sliced font files. The jsDelivr links are for prototypes only: Google Fonts is blocked in mainland China and jsDelivr is unreliable there, so a production site for mainland visitors bundles the packages, or copies each CSS file with its `files/` folder to its own server or object storage and links that. A Chinese family costs about 100 KB of render-blocking CSS per weight (31 KB gzipped, about 100 slices); browsers then download only the slices for the characters on the page, so link only the weights you use.

- `--font-sans`: "Geist Variable", "Noto Sans SC Variable", "PingFang SC", ui-sans-serif, system-ui, sans-serif
- `--font-mono`: "Geist Mono Variable", "Noto Sans SC Variable", ui-monospace, monospace
- Geist Variable: `npm install @fontsource-variable/geist`, then `import '@fontsource-variable/geist'`. Plain-HTML prototype: `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5.3.0/index.css">`
- Geist Mono Variable: `npm install @fontsource-variable/geist-mono`, then `import '@fontsource-variable/geist-mono'`. Plain-HTML prototype: `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">`
- Noto Sans SC Variable: `npm install @fontsource-variable/noto-sans-sc`, then `import '@fontsource-variable/noto-sans-sc'`. Plain-HTML prototype: `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/noto-sans-sc@5.3.1/index.css">`

Easing:

- `--ease-soft`: `cubic-bezier(0.22, 1, 0.36, 1)`

Textures used in `styles.css`:

- [noise.webp](/assets/grainy-gradient/noise.webp)

All tokens: [tokens.css](/styles/grainy-gradient/tokens.css) · [tokens.json](/styles/grainy-gradient/tokens.json)

## Page structure

Screenshots are 1440 × 900 (desktop) and 390 × 844 (mobile) viewports, on the Chinese page unless marked English. Sections taller than the screen, such as pinned scroll chapters, are captured part-way through.

1. **Header** (`:is(body, main) > header`): [components/Header.astro](/sources/grainy-gradient/components/Header.astro.txt). Visible in the Hero screenshots
2. **Hero** (`#top`): [components/Hero.astro](/sources/grainy-gradient/components/Hero.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/top-desktop.jpg) · [mobile](/shots/grainy-gradient/top-mobile.jpg) · [desktop, English](/shots/grainy-gradient/top-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/top-mobile-en.jpg)
3. **NoiseCancelling** (`#anc`): [components/NoiseCancelling.astro](/sources/grainy-gradient/components/NoiseCancelling.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/anc-desktop.jpg) · [mobile](/shots/grainy-gradient/anc-mobile.jpg) · [desktop, English](/shots/grainy-gradient/anc-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/anc-mobile-en.jpg)
4. **Compare** (`#compare`): [components/Compare.astro](/sources/grainy-gradient/components/Compare.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/compare-desktop.jpg) · [mobile](/shots/grainy-gradient/compare-mobile.jpg) · [desktop, English](/shots/grainy-gradient/compare-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/compare-mobile-en.jpg)
5. **News** (`#news`): [components/News.astro](/sources/grainy-gradient/components/News.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/news-desktop.jpg) · [mobile](/shots/grainy-gradient/news-mobile.jpg) · [desktop, English](/shots/grainy-gradient/news-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/news-mobile-en.jpg)
6. **Buy** (`#buy`): [components/Buy.astro](/sources/grainy-gradient/components/Buy.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/buy-desktop.jpg) · [mobile](/shots/grainy-gradient/buy-mobile.jpg) · [desktop, English](/shots/grainy-gradient/buy-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/buy-mobile-en.jpg)
7. **Footer** (`:is(body, main) > footer`): [components/Footer.astro](/sources/grainy-gradient/components/Footer.astro.txt). Screenshots: [desktop](/shots/grainy-gradient/footer-desktop.jpg) · [mobile](/shots/grainy-gradient/footer-mobile.jpg) · [desktop, English](/shots/grainy-gradient/footer-desktop-en.jpg) · [mobile, English](/shots/grainy-gradient/footer-mobile-en.jpg)

## Key components

### Noise-mode card

The live hero card: an Afterglow One render on a GrainGradient shader, one readout bottom left (Noise cancelling 48 dB) and the three modes bottom right (a radiogroup that arrow keys can move). Each mode has its own colours and still composition, and nothing renders at rest; a switch flows the field into the new composition while the layer clears from a blur. A ResizeObserver sets the pixel budget from the card size, capping the canvas at a pixel ratio of 1.5 (1 on standard screens); with reduced motion a switch only changes the colours.

- Source: [components/NoiseControl.tsx](/sources/grainy-gradient/components/NoiseControl.tsx.txt) (Paper Shaders)
- Appears in: Hero (`top`)

### Grain overlay

.grain::after tiles a 256 px noise image over the gradient cards with an overlay blend, close to a live shader’s grain at a fraction of the cost; the product renders sit above it, so the grain falls only on the gradients.

- Source: [styles.css](/sources/grainy-gradient/styles.css.txt)

### Noise cancelling

A gradient card on adaptive cancelling with a decibel table for plane, metro, street and office in large light figures, beside a white chart of the measured curve drawn as SVG from data: Afterglow One as a solid ink line, the previous model as a dashed grey one. The group fades in with BlurFade.

- Source: [components/NoiseCancelling.astro](/sources/grainy-gradient/components/NoiseCancelling.astro.txt) (Magic UI)
- Also needs: [components/BlurReveal.tsx](/sources/grainy-gradient/components/BlurReveal.tsx.txt), [components/ui/blur-fade.tsx](/sources/grainy-gradient/components/ui/blur-fade.tsx.txt)
- Built on Magic UI `blur-fade` ([components/ui/blur-fade.tsx](/sources/grainy-gradient/components/ui/blur-fade.tsx.txt), restyled): `npx shadcn@latest add https://magicui.design/r/blur-fade.json`
- Appears in: NoiseCancelling (`anc`)

### Models

A real table: the two models’ product tiles on gradients as column headers with name, price, launch note and buy button, over nine spec rows split by hairlines; on phones each label takes its own line. Below it, the Studio custom-acoustics panel with a contact button on a light ground.

- Source: [components/Compare.astro](/sources/grainy-gradient/components/Compare.astro.txt)
- Appears in: Compare (`compare`)

### Where to buy

A full-width pastel gradient card with a large ink heading, one line on equal pricing and three channel buttons (the official store solid ink, Tmall and JD.com outlined), then three columns: service, listening rooms by city and the flagship’s address and hours.

- Source: [components/Buy.astro](/sources/grainy-gradient/components/Buy.astro.txt)
- Appears in: Buy (`buy`)

## Dependencies

`npm install @paper-design/shaders-react motion`

## Source files

Read only what you need:

- [Site.astro](/sources/grainy-gradient/Site.astro.txt): the whole page, with fonts, sections and scripts
- [styles.css](/sources/grainy-gradient/styles.css.txt): tokens and component classes
- [i18n.ts](/sources/grainy-gradient/i18n.ts.txt): all copy, in Chinese and English
- [meta.ts](/sources/grainy-gradient/meta.ts.txt): this guide as data
- [components/Header.astro](/sources/grainy-gradient/components/Header.astro.txt): section
- [components/Hero.astro](/sources/grainy-gradient/components/Hero.astro.txt): section
- [components/NoiseCancelling.astro](/sources/grainy-gradient/components/NoiseCancelling.astro.txt): section
- [components/Compare.astro](/sources/grainy-gradient/components/Compare.astro.txt): section
- [components/News.astro](/sources/grainy-gradient/components/News.astro.txt): section
- [components/Buy.astro](/sources/grainy-gradient/components/Buy.astro.txt): section
- [components/Footer.astro](/sources/grainy-gradient/components/Footer.astro.txt): section
- [components/BlurReveal.tsx](/sources/grainy-gradient/components/BlurReveal.tsx.txt)
- [components/NoiseControl.tsx](/sources/grainy-gradient/components/NoiseControl.tsx.txt)
- [components/ui/blur-fade.tsx](/sources/grainy-gradient/components/ui/blur-fade.tsx.txt): Magic UI `blur-fade`, restyled

Everything in one file: [/sources/grainy-gradient.txt](/sources/grainy-gradient.txt) (about 15K tokens).

Before building, read the [design guide](/guide.md): the process and rules that apply to every site.
