Sass Striped Backgrounds

in code

Jina asked twitter for Sass advice the other day. She was working on a bit of code to create a rainbow-striped background gradient using any set of arbitrary colors. This is my solution, in the form of a Sass function. This requires Sass 3.2 (currently in alpha) in order to run.

Stripes Function

Start by setting a variable to the colors you want:

$rainbow: red orange yellow green blue indigo violet;

You could set individual variables for each color as well. You would still pass them all as a single argument, or join them into a single variable before passing, as you see fit.

Here’s the function:

// Returns a striped gradient for use anywhere gradients are accepted.
// - $position: the starting position or angle of the gradient.
// - $colors: a list of all the colors to be used.
@function stripes($position, $colors) {
$colors: if(type-of($colors) != 'list', compact($colors), $colors);
$gradient: compact();
$width: 100% / length($colors);

@for $i from 1 through length($colors) {
$pop: nth($colors,$i);
$new: $pop ($width * ($i - 1)), $pop ($width * $i);
$gradient: join($gradient, $new, comma);

@return linear-gradient($position, $gradient);

And how to use it:

.rainbow {
@include background-image(stripes(left, $rainbow));

Jina has posted a demo and explanation on CodePen.

(The real lesson here is that all the colors of the rainbow are acceptable CSS color keywords. Go forth and queer the web.)

code’ orgs


accessible web software with human-centered design

CSS Tricks

blog for people who make websites

90 ‘code’ episodes


Dynamic CSS @ Smashing Conf NY

| New York, NY

with grids & custom properties

Advanced CSS Workshop @

| Hong Kong

with practical use-cases, tooling, and pitfalls

Dynamic CSS @

| Hong Kong

with grids & custom properties


Dynamic CSS @ Develop Denver

| Denver, CO

with grids & custom properties

Agile Design Systems @ Agile Alliance

| Washington, DC

with meaningful code and automation

Design Systems & CSS @ Views on Vue

We start by talking about design systems and design tooling – how they differ, and the problems they solve.

CSS Custom Properties @ Smashing Magazine

Pushing past the “variable” metaphor, CSS Custom Properties can provide new ways to balance context and isolation in our patterns and components.

User Unfriendly @ Design 4 Drupal [keynote]

| Boston, MA

designing software for humans, with other humans

User Unfriendly @ Open Source Conference

| Denver, CO

designing software for humans, with other humans

Advanced CSS Workshop @ Generate New York

| San Francisco, CA

with practical use-cases, tooling, and pitfalls

Dynamic CSS @ Generate New York

| San Francisco, CA

with grids & custom properties

Has CSS finally come of age? @ Creative Bloq

Steve Jenkins interviews me about the state of CSS, and what’s coming next for the language – from Intrinsic Design to Dynamic CSS.

Advanced CSS Workshop @ Smashing Conf

| San Francisco, CA

with practical use-cases, tooling, and pitfalls

Dynamic CSS @ Smashing Conf

| San Francisco, CA

with grids & custom properties

Dynamic CSS @ VueConf US

| Tampa, FL

with grids & custom properties

Dynamic CSS Interview @ Thunder Nerds

Thunder Nerds interview me before her talk at VueConf US 2019.

User Unfriendly @ Agile Denver

| Denver, CO

designing software for humans, with other humans


Fonts & more @ Views on Vue

The panel and the guest talk about grid systems, fonts, and more!

Dynamic CSS @ Front Range Front-End

| Denver, CO

with grids & custom properties

Dynamic CSS @ Full Stack Fest

| Barcelona, Spain

with grids & custom properties

Ethics, ES6 in Practice, and Dynamic CSS @ TalkScript

On Episode 18, the TalkScript team continues the live-ish at JSConfUS podcast series with guests Myles Borins, Tim Doherty, and Miriam Suzanne. Listen in!

Dynamic CSS @ JSConf US

| Carlsbad, CA

with grids & custom properties

Dynamic CSS @ CSSConf Argentina

| Buenos Aires, Argentina

with grids & custom properties

User UnfriendlyAIGA Colorado

| Denver, CO

designing software for humans, with other humans

User Unfriendly @ Creative Connections

| Denver, CO

designing software for humans, with other humans

Agile Design Systems @ Front-End Front Range

| Denver, CO

with meaningful code and automation

User Unfriendly @ Metro State Mobile Prototyping

| Denver, CO

designing software for humans, with other humans


Fun with Viewport UnitsCSS Tricks

Viewport units have been around for several years now, with near-perfect support in the major browsers, but I keep finding new and exciting ways to use them. I thought it would be fun to review the basics, and then round-up some of my favorite use-cases.

Getting Started with CSS GridCSS Tricks

It feels like CSS Grid has been coming for a long time now, but it just now seems to be reaching a point where folks are talking more and more about it and that it’s becoming something we should learning.


Some Kind of Resistance Tour

It’s been a month since our country pseudo-elected a bigoted blow-hard for president. I’m heading to DC to protest his inauguration in January, visit friends, and go on a mixed-media resistance tour…

Loops in CSS PreprocessorsCSS Tricks

No matter what acronym drives your selectors (BEM, OOCSS, SMACSS, ETC), loops can help keep your patterns more readable and maintainable, baking them directly into your code. We’ll take a look at what loops can do, and how to use them in the major CSS preprocessors.

*Beyond Pixels Profile @ Net Magazine

Miriam Suzanne creates experimental experiences with her band and her fellow developers.

An Interview with Miriam SuzanneCSS Tricks

Chris Coyier interviews Miriam when she joins the CSS Tricks team as a Staff Writer. We talk about gettting started in the industry, name confusion, fouding OddBird, building Susy, and more.

Versioning Show, Episode 8 @ SitePoint

In this episode of the Versioning Show, Tim and David are joined by Miriam Suzanne, best known for Susy, a responsive layout toolkit for Sass. They discuss going from being a lurker to finding your voice, the importance of writing about what you’re learning, stumbling into fame, approaching new projects, and unit testing in Sass.

Jump Start Sass @ SitePoint

Using Sass, you can write your stylesheets in a more concise, dynamic, and readable way, and cut down many of the repetitive tasks that come with writing vanilla CSS. This book provides a thorough introduction to Sass for the beginner.


Herman: design docs @ OddBird

Design systems streamline development, communication, and consistency – but often rely on dedicated teams and extended budgets. We wanted a tool that helps create and maintain living style guides & pattern libraries in an agile process, and on a budget. Herman helps you keep your development process simple – and your UX consistent – as you iterate on patterns and scale over time.

User Unfriendly @ SassConf 2015

| Austin, TX

designing software for humans, with other humans

Sassy Toolkits @ Frontend Zurich

| Zurich, Switzerland

a case-study in building and sharing open-source Sass

Sassy Toolkits @ WordCamp Denver

| Denver, CO

a case-study in building and sharing open-source Sass


Link: Book – Learning Susy @ Zell Liew

Popular CSS layout framework used by Virgin America, The Smithsonian, and others

Accoutrement: design utils @ OddBird

Design systems must be meaningful to both humans and machines Accoutrement provides Sass design-token management that improves readability and consistency, while encouraging automation. These tools integrate with Herman, the OddBird pattern-library generator.


True: unit-testing @ OddBird

True is a full-featured unit-testing library for Sass. The core functionality is written in pure SassScript, so it can be used anywhere Sass is compiled. Advanced features are available with our test-runner integration and Mocha.


Sass Striped Backgrounds

Into the Green Green Mud @

A novel about new love, moving apart, and what comes next. A love story, and an after-love story – told wiith poetry and pictures.


Susy: layout toolkit @ OddBird

Susy is a lightweight grid-layout engine for Sass, designed to simplify and clarify responsive grid layouts without ever getting in your way. Originally released in 2009, Susy has become one of the most popular layout frameworks on the web.