--- name: tailwindcss-backgrounds description: "Background utilities Tailwind CSS v4.1. Colors (bg-{color}, palette OKLCH P3), Gradients (bg-linear-*, bg-radial-*, bg-conic-* NEW), Images (bg-cover, bg-contain, bg-repeat), Blend modes." user-invocable: false --- # Tailwind CSS Backgrounds Skill Complete reference for background utilities in Tailwind CSS v4.1, including colors, gradients, images, positioning, sizing, and blend modes. ## Background Colors Use `bg-{color}` utilities to set background colors with the modernized OKLCH color palette. ```html
``` ### Color Palette (OKLCH P3) The default Tailwind palette uses OKLCH color space for perceptually uniform colors across the wider P3 gamut: - **Neutrals**: slate, gray, zinc, neutral, stone - **Colors**: red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose Each color has 11 shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950 ## Linear Gradients Create linear gradients using `bg-linear-*` utilities with direction and color stops. ```html
``` ### Direction Utilities - `bg-linear-to-t` - to top - `bg-linear-to-tr` - to top right - `bg-linear-to-r` - to right - `bg-linear-to-br` - to bottom right - `bg-linear-to-b` - to bottom - `bg-linear-to-bl` - to bottom left - `bg-linear-to-l` - to left - `bg-linear-to-tl` - to top left - `bg-linear-` - custom angle (e.g., `bg-linear-45`) ## Radial Gradients Create radial gradients using `bg-radial-*` utilities. ```html
``` ## Conic Gradients (NEW in v4.1) Create conic gradients using `bg-conic-*` utilities, perfect for color wheels and circular patterns. ```html
``` ## Gradient Color Stops Control gradient color stops with `from-*`, `via-*`, and `to-*` utilities. ```html
``` ## Background Images Use `bg-[url(...)]` to apply custom background images. ```html
``` ## Background Size Control how background images are sized. ```html
``` ## Background Position Position the background image within its container. ```html
``` ## Background Repeat Control how background images repeat. ```html
``` ## Background Blend Modes Combine background colors with images using blend modes. ```html
``` ## Complete Examples ### Color Background with Opacity ```html
Content with translucent background
``` ### Gradient Overlay on Image ```html

Hero Title

``` ### Gradient with Multiple Stops ```html
``` ### Conic Gradient (Color Wheel) ```html
``` ### Image with Blend Mode ```html
``` ## Customization Extend background utilities in your Tailwind config: ```javascript /** @type {import('tailwindcss').Config} */ export default { theme: { extend: { colors: { brand: { 50: 'oklch(0.971 0.013 17.38)', 500: 'oklch(0.637 0.237 25.331)', 950: 'oklch(0.258 0.092 26.042)', }, }, backgroundImage: { gradient: 'url(\'/img/gradient.png\')', }, }, }, } ``` ## Performance Tips 1. **Use color utilities** instead of hex values for better optimization 2. **Combine with `bg-no-repeat`** and sizing to prevent unwanted repetition 3. **Layer gradients** using multiple background utilities for complex effects 4. **Use opacity modifiers** (`/50`) instead of rgba for better tree-shaking 5. **Prefer conic/radial gradients** over images when possible for smaller file sizes