Inspired by CSS Background Patterns by MagicPattern and used by RelayForms
Demo
See a live demo of all background patterns here.
Installation
Add the tailwindcss-bg-patterns plugin to your project:
- Install using npm:
npm install --save-dev tailwindcss-bg-patterns
- Install using yarn:
yarn add -D tailwindcss-bg-patterns
- Install using pnpm:
pnpm add -D tailwindcss-bg-patterns
Usage
Once installed, configure it in your tailwind.config.js
as follows:
module.exports = {
theme: {
patterns: {
opacities: {
100: 1,
80: 0.80,
60: 0.60,
40: 0.40,
20: 0.20,
10: 0.10,
5: 0.05,
},
sizes: {
1: '0.25rem',
2: '0.5rem',
4: '1rem',
6: '1.5rem',
8: '2rem',
16: '4rem',
20: '5rem',
24: '6rem',
32: '8rem',
},
},
},
plugins: [
require('tailwindcss-bg-patterns'),
],
};
Think of your configuration as setting a magnificent landscape where a painter prepares various brushes and techniques to create beautiful patterns. Just as the painter selects colors and sizes for their strokes, you define the opacities and sizes for the background patterns in your project.
Background Patterns
The plugin includes a plethora of patterns:
- Lines (pattern-lines)
- Vertical Lines (pattern-vertical-lines)
- Diagonal Lines (pattern-diagonal-lines)
- Rectangles (pattern-rectangles)
- Rhombus (pattern-rhombus)
- Dots (pattern-dots)
- Boxes (pattern-boxes)
- Cross (pattern-cross)
- Zigzag (pattern-zigzag)
- Zigzag 3D (pattern-zigzag-3d)
- Isometric (pattern-isometric)
- Wavy (pattern-wavy)
- Triangles (pattern-triangles)
- Moon (pattern-moon)
- Paper (pattern-paper)
Utilities
The plugin provides utility classes for controlling foreground and background colors, opacity, and size:
- Opacity:
pattern-opacity-80
applies an opacity of 0.8. Available options includepattern-opacity-100
,pattern-opacity-80
,pattern-opacity-60
,pattern-opacity-40
,pattern-opacity-20
,pattern-opacity-10
,pattern-opacity-5
. - Size:
pattern-size-8
applies a size of 2rem. Available options includepattern-size-1
,pattern-size-2
,pattern-size-4
,pattern-size-6
,pattern-size-8
,pattern-size-16
,pattern-size-20
,pattern-size-24
,pattern-size-32
. - Color: Use
pattern-indigo-600
for foreground andpattern-bg-white
for background. Colors will be extracted from your theme.
Example
To apply an isometric background pattern to a div, use the following code:
<div class="w-56 h-56 pattern-isometric pattern-indigo-600 pattern-bg-transparent pattern-opacity-60 pattern-size-8">
</div>
Which results in:

Troubleshooting
If you encounter issues with the installation or setup, consider the following troubleshooting tips:
- Ensure you have TailwindCSS installed and configured properly before adding the plugin.
- Check for typos in your
tailwind.config.js
file; even the smallest mistake can lead to problems. - Clear your browser’s cache after making changes to see the updates reflected on your webpage.
- If styling elements are not appearing as expected, make sure you are using the correct utility classes.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions.
Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.