CSS Carbon Fiber Background

A carbon fiber background in pure CSS: the diagonal twill weave of carbon cloth, built from angled slivers and banded rows. Set the weave size and colors live.

#223b8c
#222564
20px
.bg-carbon-fiber {
  --bg: #223b8c;
  --fg: #222564;
  --size: 20px;
  background-color: var(--fg);
  background-image:
    linear-gradient(27deg, color-mix(in srgb, var(--fg) 90%, var(--bg)) calc(var(--size) / 4), transparent 0),
    linear-gradient(207deg, color-mix(in srgb, var(--fg) 90%, var(--bg)) calc(var(--size) / 4), transparent 0),
    linear-gradient(27deg, color-mix(in srgb, var(--fg) 65%, var(--bg)) calc(var(--size) / 4), transparent 0),
    linear-gradient(207deg, color-mix(in srgb, var(--fg) 65%, var(--bg)) calc(var(--size) / 4), transparent 0),
    linear-gradient(90deg, color-mix(in srgb, var(--fg) 80%, var(--bg)) calc(var(--size) / 2), transparent 0),
    linear-gradient(color-mix(in srgb, var(--fg) 75%, var(--bg)) 25%, color-mix(in srgb, var(--fg) 85%, var(--bg)) 0 50%, transparent 0 75%, color-mix(in srgb, var(--fg) 60%, var(--bg)) 0);
  background-position: 0 calc(var(--size) / 4), calc(var(--size) / 2) 0, 0 calc(var(--size) / 2), calc(var(--size) / 2) calc(var(--size) / 4), 0 0, 0 0;
  background-size: var(--size) var(--size);
}
<div class="
  [--bg:#223b8c]
  [--fg:#222564]
  [--size:20px]
  [background-color:var(--fg)]
  [background-image:linear-gradient(27deg,_color-mix(in_srgb,_var(--fg)_90%,_var(--bg))_calc(var(--size)_/_4),_transparent_0),_linear-gradient(207deg,_color-mix(in_srgb,_var(--fg)_90%,_var(--bg))_calc(var(--size)_/_4),_transparent_0),_linear-gradient(27deg,_color-mix(in_srgb,_var(--fg)_65%,_var(--bg))_calc(var(--size)_/_4),_transparent_0),_linear-gradient(207deg,_color-mix(in_srgb,_var(--fg)_65%,_var(--bg))_calc(var(--size)_/_4),_transparent_0),_linear-gradient(90deg,_color-mix(in_srgb,_var(--fg)_80%,_var(--bg))_calc(var(--size)_/_2),_transparent_0),_linear-gradient(color-mix(in_srgb,_var(--fg)_75%,_var(--bg))_25%,_color-mix(in_srgb,_var(--fg)_85%,_var(--bg))_0_50%,_transparent_0_75%,_color-mix(in_srgb,_var(--fg)_60%,_var(--bg))_0)]
  [background-position:0_calc(var(--size)_/_4),_calc(var(--size)_/_2)_0,_0_calc(var(--size)_/_2),_calc(var(--size)_/_2)_calc(var(--size)_/_4),_0_0,_0_0]
  [background-size:var(--size)_var(--size)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Carbon Fiber — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-carbon-fiber {
      --bg: #223b8c;
      --fg: #222564;
      --size: 20px;
      background-color: var(--fg);
      background-image:
        linear-gradient(27deg, color-mix(in srgb, var(--fg) 90%, var(--bg)) calc(var(--size) / 4), transparent 0),
        linear-gradient(207deg, color-mix(in srgb, var(--fg) 90%, var(--bg)) calc(var(--size) / 4), transparent 0),
        linear-gradient(27deg, color-mix(in srgb, var(--fg) 65%, var(--bg)) calc(var(--size) / 4), transparent 0),
        linear-gradient(207deg, color-mix(in srgb, var(--fg) 65%, var(--bg)) calc(var(--size) / 4), transparent 0),
        linear-gradient(90deg, color-mix(in srgb, var(--fg) 80%, var(--bg)) calc(var(--size) / 2), transparent 0),
        linear-gradient(color-mix(in srgb, var(--fg) 75%, var(--bg)) 25%, color-mix(in srgb, var(--fg) 85%, var(--bg)) 0 50%, transparent 0 75%, color-mix(in srgb, var(--fg) 60%, var(--bg)) 0);
      background-position: 0 calc(var(--size) / 4), calc(var(--size) / 2) 0, 0 calc(var(--size) / 2), calc(var(--size) / 2) calc(var(--size) / 4), 0 0, 0 0;
      background-size: var(--size) var(--size);
    }
  </style>
</head>
<body class="bg-carbon-fiber"></body>
</html>

Save the pattern as an image, with your current colors and settings.

Carbon Fiber in other colors

Click a color to try it in the preview above, then copy the code.

Browse by color: Red · Orange · Yellow · Green · Teal · Blue · Purple · Pink

How the carbon fiber pattern works

The carbon weave is six gradient layers on one small tile, all in shades between --fg and --bg mixed with color-mix(). The darkest color, --fg, fills the background, and the lighter shades sit on top.

The bottom layer splits each tile into horizontal bands of slightly different shades, and a 90deg layer darkens the left half. Together they make the alternating blocks of a woven cloth.

The four top layers are thin angled slivers at 27deg and 207deg, a quarter tile thick, shifted by a quarter and a half tile. They cut across the blocks and form the diagonal twill lines that make carbon fiber look woven and glossy.

All the sizes are fractions of --size, so the weave scales cleanly. --fg sets the deep base and --bg the sheen, so two close shades of one color work best. Use it for automotive, sports and tech themes, dark headers and gaming pages. The Tailwind tab outputs the same layers for Tailwind v4.