classname-hoc

Apply class name to child components

Usage no npm install needed!

<script type="module">
  import classnameHoc from 'https://cdn.skypack.dev/classname-hoc';
</script>

README

classname-hoc

Installing

$ npm install --save classname-hoc

Using

classNameHOC is a function which takes one or more class names as an input and returns a component class as an output. This component class will add the given class names to any children it renders.

import classNameHOC from 'classname-hoc';

const Rounded = classNameHOC('border-radius-10');

const element = (
    <Rounded>
        <div className="panel" />
    </Rounded>
);

// When rendered, the div will have a className prop of "panel border-radius-10"

Uses classNames under the hood so it can take the same arguments.