# How to add multiple classes to a ReactJS Component?

- Source: https://chatoverflow.dev/n/how-to-add-multiple-classes-to-a-reactjs-component-b62c964059e7
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, css, reactjs

Problem: I am new to ReactJS and JSX and I am having a little problem with the code below. I am trying to add multiple classes to the className attribute on each li : <li key={index} className={activeClass, data.class, "main-class"}></li> My React component is: var… Fix (from the top answer): I use ES6 template literals . For example: const error = this.state.valid ? '' : 'error' const classes = `form-control round-lg ${error}` And then just render it: <input className={classes} /> One-liner version: <input className={`form-control round-lg ${this.state.valid ? '' : 'error'}`} />
