Skip to main content
Introducing packages.sweber.dev
Documentation menuCLI

CLI

All options of the gradient command.

npx @sweberdev/gradient <color> [name=color ...] [options]
npx @sweberdev/gradient check <foreground> <background> [--target <ratio>]
npx @sweberdev/gradient audit <file.css> [...] [--json]
npx @sweberdev/gradient series <color> [--count <n>] [--format css|json|table]
npx @sweberdev/gradient build [--config <file>] [--verify] [--json] [--markdown]
npx @sweberdev/gradient init <color> [name=color ...] [--format <format>] [--out <file>]
npx @sweberdev/gradient blend <color> <color> [...] [--steps <n>] [--angle <deg>] [--format css|json|table]

Colors can be hex (#e30613, #f00), rgb(), hsl() or oklch(). Quote them in the shell. The first color is named brand unless you pass --name or name=color.

OptionDefault
--name <name>brandName of the first color
--format <format>csscss, tailwind (v4), tailwind3, scss, ts, shadcn, tokens, json, table
--dark <mode>bothboth, media, class, light-dark, none
--dark-selector <sel>.darkClass or attribute that turns dark mode on
--hexcss and shadcn: hex values instead of oklch()
--prefix <prefix>colorcss and scss: variable prefix (scss has none by default)
--statusAdd success, warning, danger and info scales
--no-neutralDo not add the tinted grey neutral
--neutral-chroma <n>autoChroma of the neutral, 0 for pure grey
--saturation <n>1Multiply the chroma of all steps
--hue-shift <deg>0Turn the hue from the lightest to the darkest step
--pinPut the exact input color on its closest step
--out <file>stdoutWrite to a file
--checkPrint failed contrast checks; exit code 1 if one fails. Also notes colors that look alike with a color vision deficiency
--target <ratio>4.5check: contrast the pair needs
--steps <n>9blend: number of stops, 2 to 64
--angle <deg>90blend: gradient angle
--config <file>gradient.config.jsonbuild, init: config file
--verifyoffbuild: write nothing, exit code 1 if a file is out of date
--markdownoffbuild, audit: Markdown report
--count <n>6series: number of chart colors, 2 to 8

Check two colors

gradient check measures any pair, also colors that are not in a palette. It exits with 1 when the pair is below --target (default 4.5) and suggests the closest color that passes. See Check any two colors.

npx @sweberdev/gradient check "#ff5a5f" "#ffffff"

Audit a stylesheet

gradient audit app/globals.css checks the color steps of an existing stylesheet against the promises and suggests colors that pass. --json prints the result. See Audit an existing stylesheet.

Chart colors

gradient series prints colors for charts that stay apart under color vision deficiencies. --count <n> sets the number (2 to 8, default 6). See Chart colors.

In CI

Keep the generated file in the repository and check it in CI when you pin your brand color:

npx @sweberdev/gradient "#e30613" --pin --check --format tailwind --out app/gradient.css
git diff --exit-code app/gradient.css

gradient blend prints a gradient between two or more colors, blended in OKLCH. --format is css (default), json or table. See Gradients.

gradient build generates all files of a gradient.config.json, gradient init writes a starter one. See Config file and build and GitHub Action.