1class App extends Component {
2 constructor() {
3 super()
4 this.state = { isRed: true }
5 }
6
7 render() {
8 const isRed = this.state.isRed
9
10 return <p style={{ color: isRed ? 'red' : 'blue' }}>Example Text</p>
11 }
12}
1Not in the traditional sense, but you can use classes for this, if you have access to the HTML. Consider this:
2
3<p class="normal">Text</p>
4
5<p class="active">Text</p>
6and in your CSS file:
7
8p.normal {
9 background-position : 150px 8px;
10}
11p.active {
12 background-position : 4px 8px;
13}
14That's the CSS way to do it.