All effectsVisual styles

Grain Texture

颗粒质感

Fine, irregular speckles break up a smooth surface like film grain or uncoated paper.

Compare the smooth half with the textured half

Where to use it

Give an otherwise flat color field a tactile printed quality. Keep the grain fine enough to read as part of a paper or film surface, and place it under text and controls.

Practical example

A letterpress studio adds fine, irregular speckles to the cream block behind its paper swatches. The surface recalls uncoated stationery while sample prices and order buttons remain crisp.

AI prompt

Add Grain Texture to [target background]. Place a small tiled noise texture above the color field at low opacity. Keep it off the text layer, avoid individual high-contrast speckles, and check readability after scaling.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Grain Texture</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .visual-specimen {
      width: min(100%, 290px);
      height: 124px;
      display: grid;
      place-items: center;
      position: relative;
      isolation: isolate;
    }
    .grain-comparison { overflow: hidden; width: min(100%, 220px); border-radius: 11px; }
    .grain-comparison canvas { width: 100%; display: block; height: auto; }
  </style>
</head>
<body>
  <main class="demo">
    <div class="visual-specimen" aria-hidden="true"><div class="grain-comparison"><canvas width="220" height="96"></canvas></div></div>
  </main>
  <script>
    const canvas = document.querySelector('canvas');
    const context = canvas.getContext('2d');
    const { width, height } = canvas;
    const gradient = context.createLinearGradient(0, 0, width, height);
    gradient.addColorStop(0, '#ffe398');
    gradient.addColorStop(1, '#ba5976');
    context.fillStyle = gradient;
    context.fillRect(0, 0, width, height);

    const half = width / 2;
    const texture = context.getImageData(half, 0, half, height);
    for (let index = 0; index < texture.data.length; index += 4) {
      const grain = (Math.random() - .5) * 54;
      for (let channel = 0; channel < 3; channel++) {
        texture.data[index + channel] += grain;
      }
    }
    context.putImageData(texture, half, 0);
  </script>
</body>
</html>

Original example by UI Skills