Every palette starts life somewhere informal: a design file, a brand document, or a message that says the blue is 2563EB and the background is a warm off-white. Turning that list into CSS variables by hand means typing each name, prefix and value yourself. The work is just repetitive enough that one typo slips through and ships as a broken color.

The CSS Variable Palette Builder on Ovatly does the typing for you. You paste the palette as a list of named colors. It hands back a :root block of CSS custom properties, plus Tailwind snippets that reference the same names. This guide walks through the workflow in order. It covers the input shapes the builder accepts and the normalization it applies, so the output comes out tidy the first time.

Contents

  • Quick answer
  • What the builder takes in, and what it hands back
  • The four input shapes
  • The normalization safety net
  • How to create CSS variables, step by step
  • Worked example: two lines in, one block out
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Write each palette color on its own line with a name. Paste the list into the CSS Variable Palette Builder, and copy the :root block it returns into your stylesheet. The builder normalizes names to lowercase kebab-case and applies the color prefix by default. It expands 3-digit hex values to 6 digits and suffixes duplicate names instead of overwriting them. It also reports any line it cannot use instead of dropping it quietly. If the project uses Tailwind, take the matching Tailwind snippet as well, because it references the same variable names.

What the builder takes in, and what it hands back

The input is deliberately plain: a pasted list of colors, one per line. There is nothing to configure before the paste and no format to learn beyond the line shapes covered in the next section.

The output has two parts. The first is a :root block of CSS custom properties, one variable per color, ready to sit at the top of a stylesheet. The second is a Tailwind snippet in two forms: a v4 @theme form and a v3 config form. Both reference the same variable names rather than restating the values. That detail matters later. Because the snippets point at the variables, referencing the variables from your rules keeps one source of truth for the palette, dark-mode overrides included. The alternative is two copies that can drift apart.

The four input shapes

Each line of the paste follows one of four shapes:

  • name: #HEX, the name, a colon, and the value.
  • name #HEX, the name and the value separated by a space.
  • --name: #HEX, the name written with its leading dashes, with an optional semicolon at the end.
  • A bare #HEX on its own line, with no name at all.

The first three suit palettes you have already named, which is most real palettes: brand colors, surface colors, text colors. The bare shape is there for quick pastes, when you have values copied from somewhere else and want them converted first and named later. Pick whichever shape matches the list you already have; the builder reads all four, so there is no reformatting pass before you start.

The normalization safety net

Hand-written variables drift because every author types names slightly differently. The builder removes that whole class of error by normalizing every line the same way:

  • Names become lowercase kebab-case. Whatever casing you type, the name that reaches the output is lowercase and hyphenated. So the stylesheet never ends up with two spellings of the same color.
  • The prefix defaults to color. A line named primary comes out as --color-primary. That keeps palette variables visibly grouped and apart from variables that hold spacing, fonts or anything else.
  • 3-digit hex values expand to 6 digits. A short value is written out in its full form, so every value in the block has the same shape.
  • Duplicate names get a numeric suffix. If two lines carry the same name, the later one is suffixed rather than written over the first. Both colors survive, and the suffix is your signal to rename one of them deliberately.
  • Invalid lines are reported, not dropped. A line without a valid hex is excluded from the output and reported with its line number. So you know exactly which line to fix.

None of this changes your colors. It changes the odds that the block you paste is the block you meant.

How to create CSS variables, step by step

  1. Assemble your palette as a list, one color per line, using any of the four input shapes. Name the lines whose names you care about.
  2. Paste the list into the CSS Variable Palette Builder.
  3. Read the report before you copy anything. If a line was excluded, its line number is shown; fix that line in your list and paste again if the color matters.
  4. Copy the :root block and paste it where your stylesheet expects it, typically at the top of the global stylesheet. If the project uses Tailwind, copy the v4 @theme snippet or the v3 config snippet as well.
  5. Reference the variables in your rules, writing var(--color-primary) where the raw hex used to go. From this point the block is the single place the palette values live.

Worked example: two lines in, one block out

Say the palette, as it arrived from the design file, is two colors: a primary blue and a paper background. Written in the first input shape, the paste is:

primary: #2563EB
paper: #FAFAF7

The builder returns this :root block:

:root { --color-primary: #2563EB; --color-paper: #FAFAF7; }

Read it against the safety net. Both names came out lowercase, both carry the default color prefix, and both values were already 6-digit hex, so they pass through unchanged. No line was reported, which tells you both lines parsed. The Tailwind snippets produced alongside reference --color-primary and --color-paper by name. So a utility built from the snippet and a rule written by hand are reading the same two values.

Limitations and honest tradeoffs

The builder converts the list you give it; it does not choose colors, and it does not judge whether two colors work well together. Picking the palette, and checking combinations such as text on a background, is still your job before and after the conversion.

The output is also just a block of text. The builder does not reach into your project, so placing the block in the stylesheet and referencing the names in your rules remains manual work. And the line-number report only protects you if you read it. An excluded line means a color you expected is not in the block. The report is the difference between knowing that now and discovering it in a design review.

Common mistakes

  • Ignoring the line-number report. A color missing from the block is almost always a line that was reported and excluded. Check the report before assuming the conversion lost it.
  • Assuming a duplicate name overwrote the first color. It did not: the later line carries a numeric suffix. Look for the suffixed name, then rename one of the pair on purpose.
  • Expecting a 3-digit hex to survive as typed. Values are normalized to 6 digits. It is the same color written in full, not a different color.
  • Editing values in the generated block but not in your source list. Keep the pasted list as the record of the palette, so the next conversion starts from the current values rather than last month's.

FAQs

What input formats does the builder accept? One color per line, in any of these shapes: name: #HEX, name #HEX, --name: #HEX (semicolon optional), or a bare #HEX on its own line.

What will my variable names look like? Names are normalized to lowercase kebab-case and the prefix defaults to color, so a line named primary becomes --color-primary in the output.

What happens if I use the same name twice? The later occurrence gets a numeric suffix instead of overwriting the first, so both colors survive in the output and nothing is silently lost.

What happens to a line with a typo or an invalid hex? The line is reported with its line number and excluded from the output. The rest of the palette still converts, so you can fix that one line and run the builder again.

Does the builder produce Tailwind output as well? Yes. Alongside the :root block it produces a Tailwind snippet in a v4 @theme form and a v3 config form, both referencing the same variable names.

Conclusion

Creating CSS variables for a palette is transcription work, and transcription is where quiet errors breed. Writing one named color per line turns the job into a paste-and-check one instead. The CSS Variable Palette Builder normalizes the names, applies the prefix and flags the bad lines. You may still be weighing whether variables earn their keep on your project. Our comparison of CSS variables vs hardcoded HEX values runs the same palette both ways and shows where the difference shows up. For more guides in this series, see our Color and Design Tools guides.