Skip to main content

All Questions

Tagged with
680 votes
40 answers
913k views

How to add multiple classes to a ReactJS Component?

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={...
Hector's user avatar
  • 6,895
646 votes
20 answers
1.1m views

React.js inline style best practices [closed]

I'm aware that you can specify styles within React classes, like this: const MyDiv = React.createClass({ render: function() { const style = { color: 'white', fontSize: 200 }; ...
eye_mew's user avatar
  • 9,035
490 votes
24 answers
620k views

Conditionally applying class attributes in React

I want to conditionally show and hide this button group depending on what is passed in from the parent component which looks like this: <TopicNav showBulkActions={this.__hasMultipleSelected} /&...
apexdodge's user avatar
  • 6,857
414 votes
12 answers
561k views

How to add fonts to create-react-app based projects?

I'm using create-react-app and prefer not to eject. It's not clear where fonts imported via @font-face and loaded locally should go. Namely, I'm loading @font-face { font-family: 'Myriad Pro ...
Maxim Veksler's user avatar
324 votes
28 answers
479k views

React native text going off my screen, refusing to wrap. What to do?

The following code can be found in this live example I've got the following react native element: 'use strict'; var React = require('react-native'); var { AppRegistry, StyleSheet, Text, ...
SudoPlz's user avatar
  • 22.5k
273 votes
18 answers
413k views

How to dynamically add a class to manual class names?

I need to add a dynamic class to a list of regular classes, but have no idea how (I'm using babel), something like this: <div className="wrapper searchDiv {this.state.something}"> ... </div&...
Mankind1023's user avatar
  • 7,554
177 votes
15 answers
184k views

using css modules how do I define more than one style name

I am trying to use multiple classes for an element using css modules. How do I do this? function Footer( props) { const { route } = props; return ( <div className={styles.footer}&...
Navela's user avatar
  • 1,933
167 votes
22 answers
231k views

Can I make dynamic styles in React Native?

Say I have a component with a render like this: <View style={jewelStyle}></View> Where jewelStyle = { borderRadius: 10, backgroundColor: '#FFEFCC', width: 20, height: ...
Pete Thorne's user avatar
  • 2,756
160 votes
13 answers
174k views

How to add multiple classes in Material UI using the classes props?

Using the css-in-js method to add classes to a react component, how do I add multiple components? Here is the classes variable: const styles = theme => ({ container: { display: 'flex', ...
Fatah's user avatar
  • 2,266
150 votes
14 answers
429k views

How do you Hover in ReactJS? - onMouseLeave not registered during fast hover over

How can you achieve either a hover event or active event in ReactJS when you do inline styling? I've found that the onMouseEnter, onMouseLeave approach is buggy, so hoping there is another way to do ...
HelpMeStackOverflowMyOnlyHope's user avatar
137 votes
10 answers
264k views

Make view 80% width of parent in React Native

I'm creating a form in React Native and would like to make my TextInputs 80% of the screen width. With HTML and ordinary CSS, this would be straightforward: input { display: block; width: 80%...
Mark Amery's user avatar
  • 150k
132 votes
8 answers
118k views

React - Prevent Event Trigger on Parent From Child

I have this scenario, where when parent element is clicked, it flips to show a child element with different colours. Unfortunately, when the user clicks on one of the colours, the 'click' event on ...
Kayote's user avatar
  • 15.3k
129 votes
7 answers
206k views

How to apply global styles with CSS modules in a react app?

I'm currently using CSS Modules with React for my styling. So each of my components is importing in it's component specific css file, like so: import React from 'react'; import styles from './App.css'...
dace's user avatar
  • 6,171
127 votes
7 answers
224k views

React inline style - style prop expects a mapping from style properties to values, not a string

I am trying to set inline styles in my React application. In this case, for a span: <span className="myClass" style={{float : 'left', paddingRight : '5px'}} > </span> React tells me: ...
George Welder's user avatar
124 votes
20 answers
323k views

React - Component Full Screen (with height 100%)

I'm stuck with displaying a React component named "home" that take 100% of the height of my screen. Whatever I use CSS or React inline style it doesn't work. In the example below, html, body and #app ...
Thibault Clement's user avatar

15 30 50 per page
1
2 3 4 5
1672