Skip to content

SimonFinney/parse-css-custom-property

Repository files navigation

parse-css-custom-property

Licensed under the ISC License Travis CI

Parse CSS custom property strings.

Installation

npm i -S parse-css-custom-property

Usage

import ParseCSSCustomProperty, {
  getDeclaration,
  getFallback,
} from 'parse-css-custom-property';

const cssCustomProperty = 'var(--foo, bar)';

// { declaration: '--foo', fallback: 'bar' }
ParseCSSCustomProperty(cssCustomProperty);

// '--foo'
getDeclaration(cssCustomProperty);

// 'bar'
getFallback(cssCustomProperty);