Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

How to support a custom className

Xavier Via edited this page Aug 13, 2016 · 1 revision

A custom className to be added to the component is the simplest way of adding styles to a component. To support this feature:

  1. Add a className prop to your component:
YourComponent.propTypes = {
  className: PropTypes.string
}
  1. Get it from the props in the render:
function YourComponents (props) {
  const { className } = props
  1. When setting up the classes of the outermost component, add the className as the last:
return (
  <div className={classNames('yourcomponent', 'big', className)}>
   {/* ... */}
  </div>
)