css-safe-classname
v0.1.5
Published
Utility methods for creating and validating safe CSS classnames from string input
Downloads
841
Maintainers
Readme
css-safe-classname
This library is a lightweight solution containing utility methods for creating and validating safe CSS classnames from string input.
This project is published on npm as css-safe-classname.
Installation
yarn add css-safe-classname
# or npm install css-safe-classname
Usage
ES Modules
import { createSafeCssClassname, isValidCssClassname } from 'css-safe-classname'
const originalInputString = 'your#css.classname>here'
console.log(isValidCssClassname(originalInputString))
// outputs: false
const safeCssClassname = createSafeCssClassname(originalInputString)
console.log(safeCssClassname)
// outputs: yourcssclassnamehere
CommonJS Modules
var cssSafeClassname = require('css-safe-classname')
var originalInputString = 'your#css.classname>here'
console.log(cssSafeClassname.isValidCssClassname(originalInputString))
// outputs: false
var safeCssClassname = cssSafeClassname.createSafeCssClassname(
originalInputString
)
console.log(safeCssClassname)
// outputs: yourcssclassnamehere
Contributing
Please see the Contributing Guidelines.
Code of Conduct
The Code of Conduct can be found here.