CSS Offset Triangle Pattern

An offset triangle pattern in pure CSS: staggered rows of equilateral triangles from one repeating conic gradient on a hex grid. Set size and colors live.

#880088
#b560b5
48px
.bg-offset-triangles {
  --bg: #880088;
  --fg: #b560b5;
  --size: 48px;
  background-color: var(--bg);
  background-image: repeating-conic-gradient(from -30deg, var(--fg) 0 60deg, transparent 0 120deg);
  background-size: var(--size) calc(round(calc(var(--size) * 0.866), 1px) * 2);
}
<div class="
  [--bg:#880088]
  [--fg:#b560b5]
  [--size:48px]
  [background-color:var(--bg)]
  [background-image:repeating-conic-gradient(from_-30deg,_var(--fg)_0_60deg,_transparent_0_120deg)]
  [background-size:var(--size)_calc(round(calc(var(--size)_*_0.866),_1px)_*_2)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Offset Triangles — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-offset-triangles {
      --bg: #880088;
      --fg: #b560b5;
      --size: 48px;
      background-color: var(--bg);
      background-image: repeating-conic-gradient(from -30deg, var(--fg) 0 60deg, transparent 0 120deg);
      background-size: var(--size) calc(round(calc(var(--size) * 0.866), 1px) * 2);
    }
  </style>
</head>
<body class="bg-offset-triangles"></body>
</html>

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

Offset Triangles 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 offset triangles pattern works

This pattern uses the same grid as a honeycomb. Six equilateral triangles meet at every point, and around each point they alternate between --fg and --bg. Each row of triangles sits half a triangle over from the row above, so the triangles stagger like bricks instead of stacking in columns.

All of it comes from one repeating-conic-gradient() at the center of each tile. Starting from -30deg, it repeats --fg for 60 degrees, then transparent for 60 degrees, six wedges in all. The tile is one triangle wide and two triangles tall (2 × 0.866 × --size), and that ratio puts the wedge edges at 30° from vertical, so they run exactly into the tile corners. The top and bottom wedges are whole triangles. The side wedges are half triangles that join with the next tile’s halves.

--size sets the triangle width. round() snaps the height to whole pixels so rows don’t show seams.

Use it for bold hero sections, sports and gaming pages, quilt and craft themes, and festival posters.