react-classnamed
Utility React component for using great classnames package.
Installation
npm
npm install react-classnamed --save
yarn
yarn add react-classnamed
Examples
import ClassNamed from 'react-classnamed'; const element = <ClassNamed => mergedClassName <div =>Foo Bar</div> </ClassNamed>;
This produces:
Foo Bar
Useful when creating core components which alow custom styles.
If we create PrimaryButton component
import * as React from 'react';import ClassNamed IClassNamed from 'react-classnamed'; interface IProps extends IClassNamed onClick?: void; const PrimaryButton: React.SFC<IProps> = className onClick children <ClassNamed => mergedClassName <button = => children </button> </ClassNamed>; ;
We can use it like this:
<PrimaryButton => Hello world</PrimaryButton>
Which results in this HTML:
Hello world