@intrnl/styleprops
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

styleprops

Helper function that takes in an object of properties that should be treated as a CSS custom property and concatenates them into a string.

Installation

  • Install it with your package manager of choice
    • npm: npm i @intrnl/styleprops
    • pnpm: pnpm i @intrnl/styleprops
    • yarn: yarn add @intrnl/styleprops

Usage

Pass in an object of properties to the styleprops function, camelcase properties will be converted into kebabcase by default, and falsy values are ignored.

import { styleprops } from '@intrnl/styleprops';

let vars = {
  titleColor: 'red',
  titleBackground: 'blue',
};

styleprops(vars);
// -> '--title-color: red; --title-background: blue;'

styleprops(vars, { kebabcase: false });
// -> '--titleColor: red; --titleBackground: blue;'

Readme

Keywords

none

Package Sidebar

Install

npm i @intrnl/styleprops

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

3.76 kB

Total Files

6

Last publish

Collaborators

  • intrnl