pattern.css

CSS only library to fill your empty background with beautiful patterns.

Installation

1. pattern.css is available via npm

npm install pattern.css

2. Or you can use cdn unpkg

<link href="https://unpkg.com/pattern.css" rel="stylesheet">

3. Or Download and include in head

<link href="dist/pattern.min.css" rel="stylesheet">

Tailwind CSS Installation

Checkout the repository for tailwindcss plugin

npm install -D tailwindcss-pattern
@import "tailwindcss" 
@plugin "tailwindcss-pattern"

Usage

Examples in documentation are built using Tailwind css but this library works with most of the frameworks including bootstrap.

There are many possible designs that can be built with css to use as patterns but I have made only few styles that are commonly seen in many award winning website.

Any background pattern works with two or more colors. I made with library with considering two color patterns only.

Colors

pattern.css is built with two colors only transparent and currentColor.

currentColor is the current active text color inside a element. To change the color just change the text color property.

To change the another color just change the background color, and background color will be visible through transparent color

Example

With Tailwind css
<div class="pattern-checks-sm bg-blue-500 text-white">...</div>
With bootstrap framework
 <div class="pattern-checks-sm bg-primary text-white">...</div> 

Size

Each pattern is available in 4 sizes sm, md, lg, and xl

.pattern-diagonal-stripes-sm
.pattern-diagonal-stripes-md
.pattern-diagonal-stripes-lg
.pattern-diagonal-stripes-xl

Class

smallmediumlargeextra large
pattern-checks-smpattern-checks-mdpattern-checks-lgpattern-checks-xl
pattern-grid-smpattern-grid-mdpattern-grid-lgpattern-grid-xl
pattern-dots-smpattern-dots-mdpattern-dots-lgpattern-dots-xl
pattern-cross-dots-smpattern-cross-dots-mdpattern-cross-dots-lgpattern-cross-dots-xl
pattern-diagonal-lines-smpattern-diagonal-lines-mdpattern-diagonal-lines-lgpattern-diagonal-lines-xl
pattern-horizontal-lines-smpattern-horizontal-lines-mdpattern-horizontal-lines-lgpattern-horizontal-lines-xl
pattern-vertical-lines-smpattern-vertical-lines-mdpattern-vertical-lines-lgpattern-vertical-lines-xl
pattern-diagonal-stripes-smpattern-diagonal-stripes-mdpattern-diagonal-stripes-lgpattern-diagonal-stripes-xl
pattern-horizontal-stripes-smpattern-horizontal-stripes-mdpattern-horizontal-stripes-lgpattern-horizontal-stripes-xl
pattern-vertical-stripes-smpattern-vertical-stripes-mdpattern-vertical-stripes-lgpattern-vertical-stripes-xl
pattern-triangles-smpattern-triangles-mdpattern-triangles-lgpattern-triangles-xl
pattern-zigzag-smpattern-zigzag-mdpattern-zigzag-lgpattern-zigzag-xl

Browser Support

pattern.css library depend on four css properties linear-gradient, radial-gradient, repeating-linear-gradient and repeating-radial-gradient
which are supported by most browsers. You can check caniuse.com

Examples

Hero Section

Make Your Website
More Beautiful

by using these simple pattern

Separator

Use pattern class and set PatternSeparator height. Example; pattern .pattern-dots-sm, height .h-5 and color .slate

<div class="pattern-dots-sm text-slate-500 h-5"></div>

Text pattern

PLAY

Fill text with pattern

Use .text-pattern class with background patterns to set text color as pattern

<h3 class="pattern-checks-sm text-pattern bg-green-300 text-white">PLAY</h3>

NEXT BEST TEXT

Text container pattern

<div class="pattern-dots-md text-red-500 text-pattern max-w-20pc overflow-visible"> 
<h1 class="text-white">NEXT BEST TEXT</h1>
</div>

Image Container

Use with image

<div class="pattern-dots-md gray-400"> 
<img class="translate-x-8 translate-y-8" src="..."/>
</div>

Another pattern with image

<div class="pattern-diagonal-lines-sm gray-lighter">
<img style="transform:translate(30px, 30px);" src="..."/>
</div>

All Patterns

checks

.pattern-checks-sm
.pattern-checks-md
.pattern-checks-lg
.pattern-checks-xl

grid

.pattern-grid-sm
.pattern-grid-md
.pattern-grid-lg
.pattern-grid-xl

dots

.pattern-dots-sm
.pattern-dots-md
.pattern-dots-lg
.pattern-dots-xl

cross-dots

.pattern-cross-dots-sm
.pattern-cross-dots-md
.pattern-cross-dots-xl
.pattern-cross-dots-lg

diagonal-lines

.pattern-diagonal-lines-sm
.pattern-diagonal-lines-md
.pattern-diagonal-lines-lg
.pattern-diagonal-lines-xl

vertical-lines

.pattern-vertical-lines-sm
.pattern-vertical-lines-md
.pattern-vertical-lines-lg
.pattern-vertical-lines-xl

horizontal-lines

.pattern-horizontal-lines-sm
.pattern-horizontal-lines-md
.pattern-horizontal-lines-lg
.pattern-horizontal-lines-xl

diagonal-stripes

.pattern-diagonal-stripes-sm
.pattern-diagonal-stripes-md
.pattern-diagonal-stripes-lg
.pattern-diagonal-stripes-xl

vertical-stripes

.pattern-vertical-stripes-sm
.pattern-vertical-stripes-md
.pattern-vertical-stripes-lg
.pattern-vertical-stripes-xl

horizontal-stripes

.pattern-horizontal-stripes-sm
.pattern-horizontal-stripes-md
.pattern-horizontal-stripes-lg
.pattern-horizontal-stripes-xl

triangles

.pattern-triangles-sm
.pattern-triangles-md
.pattern-triangles-lg
.pattern-triangles-xl

zigzag

.pattern-zigzag-sm
.pattern-zigzag-md
.pattern-zigzag-lg
.pattern-zigzag-xl
© 2025, Jiten Bansal