Extract colors (named, hex, rgb, rgba, hsl, and hsla) from CSS.
Yields:
red
#ab560f
blue
rgba(0, 128, 255, 0.5)
This module looks at the following CSS properties for colors:
color
background
background-color
background-image
border
border-top
border-right
border-bottom
border-left
border-color
border-top-color
border-right-color
border-bottom-color
border-left-color
outline
outline-color
text-shadow
box-shadow
Installation
npm install -g css-color-extractor-cli
Usage
Extract colors as a list to stdout:
css-color-extractor input.css
Extract colors from stdin:
cat input.css | css-color-extractor
Use the --without-grey
or --without-monochrome
flag(s):
css-color-extractor input.css --without-grey
Use the --color-format
option to transform color output format (hexString
, rgbString
, percentString
, hslString
, hwbString
, or keyword
):
css-color-extractor input.css --color-format=hslString
Extract colors to file:
css-color-extractor input.css output.txt
Extract colors to CSS format (includes original CSS selectors):
css-color-extractor input.css output.css
# or to stdout
css-color-extractor input.css --format=css
Yields:
Extract colors to JSON format:
css-color-extractor input.css output.json
# or to stdout
css-color-extractor input.css --format=json
Yields:
"red""#ab560f""blue""rgba(0, 128, 255, 0.5)"
Extract colors to HTML format (page of color swatches):
css-color-extractor input.css output.html
# or to stdout
css-color-extractor input.css --format=html
Yields:
Colors yellow #ab560f rgba(0, 128, 255, 0.5) blue
License
Copyright (c) 2015 Rob Sanchez
Licensed under the MIT License.