perfect-classnames

0.1.1 • Public • Published

Perfect Classnames Build Status Coverage Status

React classnames made Perfect

What is it?

A utility for generating class names in React. This library is made to be Perfect for me. As my css proclivities change this library will evolve with them in hopes of truly living up to it's name.

Usage

perfect-classnames generates BEM style class names from props.

import { createFromProps } from 'perfect-classnames';

const fromProps = createFromProps(
  'FlexComponent', 
  {
    direction: {
      prepend: true,
      values: ['row', 'column'],
    },
    size: ['small', 'medium', 'large'],
    wrap: true,
  }
);

const FlexComponent = (props) => {
  let classes = fromProps(props);
  ...
};


<FlexComponent direction="row" size="small" wrap />
// ['FlexComponent', 'FlexComponent--directionRow', 'FlexComponent--medium', 'FlexComponent--wrap']

Readme

Keywords

Package Sidebar

Install

npm i perfect-classnames

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

5 kB

Total Files

4

Last publish

Collaborators

  • spencersteers