Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

38 Commits

Repository files navigation

react-classmap

Build Status

This hook lets you reconcile third-party React components with your CSS framework of choice by defining a mapping of additional class names to apply to children DOM components that have a given class name.

Usage

importReact,{PropTypes}from'react';import{ClassMapMixin}from'react-classmap';constGenericButton=React.createClass({render(){return(<buttonclassName="generic-button"/>);},});constMyButton=React.createClass({mixins: [ClassMapMixin({// Children DOM components with the `generic-button` className will also// have the `fa fa-cog` classNames applied to them.'generic-button': 'fa fa-cog',}),],render(){return<GenericButton/>;},});React.renderToString(<MyButton/>);// => <button class="generic-button fa fa-cog"></button>

If you're using ES6 classes instead of React.createClass, there's a higher-order component.

import{classMap}from'react-classmap';classMap(MyButton,{'generic-button': 'fa fa-cog'});

With ES7 decorators:

@classMap({'generic-button': 'fa fa-cog'})classMyButton{// ...}

Installing

npm install react-classmap

Building

npm run build

Running tests

npm test

About

No description, website, or topics provided.

Resources

Stars

27 stars

Watchers

18 watching

Forks

Releases

Packages

Used by

Contributors

Languages