All Questions
963
questions
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} /&...
28
votes
2
answers
26k
views
How to use template literals in tailwindcss to change classes dynamically?
I tried to change it with this line of code it but it doesn't work
const [click, setClick] = useState(false);
const closeNav = () => {
setClick(!click);
};
const openNav = () => {
setClick(...
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
};
...
124
votes
6
answers
135k
views
How to make React CSS import component-scoped?
I have several components which have the following CSS/component structure
About/style.css
.AboutContainer {
# Some style
}
p > code {
# Some style
}
And I import the CSS in the ...
48
votes
8
answers
28k
views
Scrollable div to stick to bottom, when outer div changes in size
Here is an example chat app ->
The idea here is to have the .messages-container take up as much of the screen as it can. Within .messages-container, .scroll holds the list of messages, and in case ...
70
votes
14
answers
205k
views
Next.js Global CSS cannot be imported from files other than your Custom <App>
My React App was working fine, using global CSS also.
I ran npm i next-images, added an image, edited the next.config.js file, ran npm run dev, and now I'm getting this message:
Global CSS cannot be ...
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&...
118
votes
8
answers
217k
views
CSS pseudo elements in React
I'm building React components. I have added CSS inline in the components as suggested in this brilliant presentation by one of the people behind React. I've been trying all night to find a way to add ...
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={...
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 ...
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,
...
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 ...
4
votes
7
answers
200k
views
javascript change background color on click [closed]
Can you show me Javascript that allows you to change the background color of the page to another color. For example, I have a blue background color and I want to change it to green. The color must be ...
10
votes
4
answers
34k
views
Change outline for OutlinedInput with React material-ui
Quick note: this is not a duplicate of How to change outline color of Material UI React input component?
With material-ui (React) I am unable to delete the outline on hover or focus. The reason I am ...
1
vote
1
answer
5k
views
Images not loading when relative path is used in React
I was importing the images previously like this in React:
import person from '../images/image1.png'
And then using them like this:
<img src={person} alt="" />
Now I want to specify ...