Skip to content

CLI

Usage

Terminal window
npx okcolor input.css -o output.css

Commands

transform

Transform a single CSS file (default command):

Terminal window
npx okcolor transform input.css -o output.css

audit

Scan a CSS file and report how many legacy colors it contains:

Terminal window
npx okcolor audit input.css

Output:

Found 42 legacy colors:
- 12 hex values
- 8 rgb() declarations
- 15 hsl() declarations
- 7 named colors

Options

FlagDescriptionDefault
-o, --output <path>Output file pathstdout
--no-gradientsSkip gradient conversiongradients enabled
--preserve-commentsAdd /* was: ... */ commentsfalse

Programmatic API

import { transformCss, auditCss } from 'okcolor/core'
const result = transformCss(`
.btn { color: #ff0000; }
`)
console.log(result.css)
// .btn { color: oklch(62.8% 0.25768 29.23); }
const audit = auditCss(source)
console.log(audit.count) // number of legacy colors found