css-prop-parser
v0.1.0
Published
A small library to parse CSS property strings. Can be useful to extract value from CSS properties without a full CSS parser.
Downloads
152
Readme
css-prop-parser
A small library to parse CSS property strings. Can be useful to extract value from CSS properties without a full CSS parser.
Installation
npm install css-prop-parserUsage
import {parseCommaList} from "css-prop-parser";
const ctx = {
input: "rgba(255, 0, 0, 0.5), #00ff00, blue",
lastIndex: 0,
};
parseCommaList(ctx, {
keyword: (_, value) => {
console.log("keyword:", value);
},
func: {
"rgba(": () => {
console.log("found rgba()");
parseCommaList(ctx, {
keyword: (_, value) => {
console.log(" arg:", value);
},
});
}
}
});Output:
found rgba()
arg: 255
arg: 0
arg: 0
arg: 0.5
keyword: #00ff00
keyword: blueAPI references
Check the .d.ts file for TypeScript type definitions.
Alternatives
Changelog
0.1.0 (Dec 7, 2025)
- First release
