DEV Community

Stefan Judis
Stefan Judis

Posted on • Originally published at stefanjudis.com

5 2

TIL: CSS defines functions to repeat gradients

Today I learned a nifty and quick fact about CSS gradients. It surprised me that I didn't come across it before. CSS includes functions to define gradients as background images:

The linear, radial and conic gradients are not the only gradient functions, though. There are three very similar CSS functions that enable you to repeat a pattern in CSS.

.repeating-linear {
  background: repeating-linear-gradient(
    var(--primary) 0 1em,
    var(--secondary) 1em 2em
  );
}

.repeating-radial {
  background: repeating-radial-gradient(
    var(--primary) 0 1em,
    var(--secondary) 1em 2em
  );
}

.repeating-conic {
  background: repeating-conic-gradient(
    var(--primary) 0 36deg,
    var(--secondary) 36deg 72deg
  );
}
Enter fullscreen mode Exit fullscreen mode

You can read more about these functions on MDN:

Have a look at the devsheet below to see the difference between all these CSS functions.

Devsheet showing normal and repeating CSS gradients

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay