A CSS stripes generator example creates a repeating two-color background with one period equal to the stripe width plus the gap width.
Use the CSS Stripes Generator when you need a deterministic diagonal, horizontal, or vertical pattern and want one copy-ready declaration. Set the CSS angle, choose two colors, and assign separate pixel widths to the stripe and gap. The live preview uses the exact repeating-linear-gradient value placed on the clipboard, keeping the displayed pattern and copied declaration aligned.
This guide follows the complete workflow from settings to a real component, including the accessibility and rendering checks the generator cannot perform for you. Everything runs in the current tab without uploads, storage, login, or an added dependency.

What the generated pattern contains
The output is a standard CSS gradient rather than a raster image. It needs no downloaded asset, remains sharp on high-density screens, and can cover a large surface without changing the geometry of the pattern.
| Setting | Supported value | Result |
|---|---|---|
| Direction | CSS angle from 0 to 360 degrees | 0 points upward along the gradient line, 90 points right, and intermediate values create diagonals. |
| Palette | Two complete six-digit hexadecimal colors | Produces two hard color boundaries without transparent alpha or intermediate colors. |
| Band sizes | Stripe and gap widths from 1px to 200px each | The two widths are added to calculate one deterministic pattern period. |
| Output | One background-image declaration with four explicit stops | The preview and clipboard use the same gradient value. |
| CSS scope | background-image rather than the background shorthand | Does not reset separate background color, size, or position values. |
The repeated color stops are intentional. Each color appears twice in the stop list, so the stripe and gap meet at the same position without a blended transition. Equal stop positions switch directly from one color to the other, creating a crisp boundary.
That behavior follows the CSS gradient model described in MDN’s repeating-linear-gradient reference. The final color-stop interval repeats in both directions along the gradient line, continuing the pattern beyond its first calculated period.
Generate the declaration
- Set the stripe direction. Enter a CSS angle from 0 through 360 degrees. Zero points upward along the gradient line, 90 points right, and intermediate values produce diagonal directions. Preview the result in an area similar to the component where it will be used.
- Choose the stripe and gap colors. Select a complete six-digit hexadecimal value for each color. The generator uses these as the only two colors in the pattern, so both values must be valid before the pattern can be defined.
- Adjust both band widths. Set the stripe and gap independently, with each value between 1px and 200px. The generator adds the two widths to calculate one pattern period. Inspect the preview for the expected rhythm and make sure the bands remain visually meaningful. Empty or non-finite numeric inputs are errors, preventing an accidental zero-length period.
- Copy and test the result. Copy the single background-image declaration, paste it into the real component, and inspect text and control contrast. Test the component at its representative size and under browser zoom before treating the preview as final.
Worked example: Choose a 45-degree angle, #2563eb for the stripe, #f8fafc for the gap, a 10px stripe width, and a 5px gap width. The pattern period is 10px + 5px = 15px.
background-image: repeating-linear-gradient(45deg, #2563eb 0px, #2563eb 10px, #f8fafc 10px, #f8fafc 15px);
In this declaration, the blue color extends from 0px to the 10px stripe boundary, while the light color extends from 10px to the end of the 15px period. Blue appears at both 0px and 10px, and the light color appears at both 10px and 15px. Those duplicate positions make the boundary hard, and the repeating gradient continues that same 15px sequence along the gradient line.
Put the declaration into the component
Add the copied declaration to the component’s background-image property, then add a solid background-color fallback. For text-heavy areas, a contained child with its own solid background can provide a stable reading surface without removing the stripe pattern from the surrounding component.
Using background-image rather than the background shorthand matters in established styles. The longhand property leaves separate background color, size, and position declarations intact instead of resetting them. If the component already contains multiple background layers, place the stripe layer in the intended stack order, preserve the comma separation, and inspect the final result rather than relying on the generator preview alone.
Test the pattern inside the actual container rather than applying it globally without inspection. The component’s width, height, padding, overflow, and neighboring content can all affect the final visual result. After the declaration works in the real component, replace literal colors or dimensions with established design tokens where appropriate, then repeat the visual checks.
Why diagonal widths change on screen
Stripe and gap widths are measured along the gradient line, not along the horizontal and vertical edges of the screen. Consequently, the 10px stripe in the worked example is not guaranteed to occupy 10 horizontal pixels when the gradient is diagonal. Its projection changes with the selected angle.
The angle also affects the visible spacing between diagonal bands. A pattern can therefore look wider or narrower across a screen axis while keeping the same deterministic period along its gradient line. This distinction is especially important when comparing a preview with a narrow card, a full-width banner, or a responsive container.
Use the preview at a representative element size and inspect the final container at several responsive sizes. Do not treat a numeric band width as a screen-axis measurement. Pixel lengths keep the generated geometry deterministic, but they do not guarantee that every size will produce the same perceived density.
Keep the pattern readable
The generator does not calculate text contrast over the pattern. Contrast changes across the two bands, and rapid stripes can create visual stress. A pattern can also interfere with the readability of text and controls even when each individual color looks acceptable in isolation.
- Check text and control labels over both colors and around the boundary between them.
- Place long text on a solid overlay or a contained reading surface.
- Do not use stripe direction or color as the only way to communicate status.
- Test forced-colors behavior, dark themes, zoom, print output, screenshots, and motion contexts.
The generated pattern is static because animation is outside the tool’s supported output. If movement is added separately in CSS, respect reduced-motion preferences and measure paint behavior. For decorative backgrounds, a static pattern is usually safer and clearer than an animated one.
Know the generator’s deliberate limits
The generator intentionally omits transparent alpha, multiple intermediate colors, conic patterns, radial patterns, background positioning, and animation. This narrow scope keeps the output auditable, but it also means the tool is not an all-purpose pattern editor. Use separate CSS for richer effects only after testing how those additions interact with the generated layer.
Very small bands can produce moire, shimmer while scrolling, or an unstable appearance under browser zoom and screenshots. Very large bands may stop reading as a repeating pattern at all. Pixel measurements make the output repeatable, but visual stability still depends on scale, angle, surrounding content, and the display environment.
For a deeper look, see Convert Text to HTML Paragraphs: A Worked Example.
For a deeper look, see Box Shadow Generator: Create One CSS Shadow.