All Questions
92 questions
2
votes
0
answers
32
views
React CSS multiple inline styles VS class performance-wise
Who wins from performance perspective (only)
INLINE STYLES
<div style={{backgroundColor:"#fff"}}>content</div>
<div style={{backgroundColor:"#fff"}}>content</...
0
votes
1
answer
230
views
In Chrome, style.fontFamily doesn't work for a barcode font, but className does
Consider the following html:
<style>
.barcode { font-family: 'BC C39 3 to 1 Medium'; }
</style>
<div><span id='spn'>1234567</span></div>
The following will set the ...
0
votes
1
answer
2k
views
Tailwindcss + Nextjs problems with class + variables
Good afternoon, I need help with a big problem I'm having with tailwindcss + nextjs...
So the problem is when it comes to setting the classes, I need to use a variable, the class is set in the css, ...
0
votes
1
answer
674
views
why css is not working in my react component?
I am importing css from main.css file to Main.js file, but css is not working completely?
//This is Main.js code--
This is Main.js screenschot
This is main.css screenshot
This is website screenshot
...
0
votes
1
answer
1k
views
How to add specific styles to className in Tailwind
I am passing a style to a checkbox when it is checked, but I do it in my tailwind.css file.
I am wondering if it is possible somehow to do it in className inline, because I do not want really to add ...
0
votes
0
answers
123
views
How to properly set the name of the BEM class for different card designs
Let's imagine that the task before us is to develop 50+ unique types of cards, headers, footers, etc.
It will be okay if I name the card types like this:
card-23, card-24
Or is there a better solution?...
0
votes
1
answer
31
views
How to use components in different ways (React)
I want to use simple components in different way and different ui rendering
For example a dropdown rendering a list may have several ui according to the page or context (=> padding, margins, font ...
0
votes
1
answer
496
views
Using map method, how to use multiple classname in React.js?
please check out my code first.
import styles from './calculator.module.css';
const BUTTONS = [
{
key: '+/-',
styled: 'symbol',
},
{
key: '0',
},
{
key: '.',
styled: '...
0
votes
1
answer
454
views
apply className to one tag in React
how to apply styles to a specific tag?
I started the state and on click I want the name to be applied to the class names, but it is applied to all at once.
import { Button, Form, Input } from 'antd'
...
2
votes
1
answer
2k
views
how Can I use css modules and global style together on React
i want to use normal class and module class together.
if i use two className it says "JSX elements cannot have multiple attributes with the same name."
import Header from "./...
0
votes
3
answers
2k
views
Slick.js set classes for all slides before and after the centered one
I'm using slick.js carousel, I need to set different styles to the all the slides that comes before and all the slides that comes after the centered one.
So I used these css style rules:
.slick-slide{...
1
vote
2
answers
2k
views
Multiple variable className in next js
How to apply multiple className in Next js, in which there are variable classsnames as well ?
I'm using component level css approach
Here's my code and what I want to do:
import styles from "./...
1
vote
1
answer
2k
views
Render a specific className when active with classNames and Tailwind
I'm using Tailwinds CSS and classNames package.
I'm rendering out 2 divs and I want to check if one of them has am active class, then set a specific background color className bg-[#000] to it.
I ...
2
votes
2
answers
1k
views
inline style vs className in Componet context
Hello I try to understand when it's necessary to use inline style instead className in this case. I take a long time to solve my problem of translation. At the beginning I want to translate component ...
2
votes
1
answer
546
views
ParcelJs optimizer & class names
I'm starting using parcelJs, and it's a killer.
In dev mode, I get no problem but in production nothing is working:
My framework is generating css classes names dynamically from typescript classes ...
-1
votes
1
answer
957
views
Is there another way to give id or class name when using CSS Module in React?
Whenever I import "style.module.css" then I have to give each component a class name like this: classname={styles.className}
Code Example:
import styles from './Header.module.scss'
...
1
vote
2
answers
72
views
Adding class to result element when submitting form [React.js]
created a simple BMI calculator using React.js. Now I am trying to make it so if the result is anything other than healthy BMI the result text will be colored red (I am using styled-components). I'm ...
0
votes
0
answers
231
views
Change global style className to hash className without using css module
I'm finding a solution that can change the following style
<div className='projects-main'>
<div className='basic-projects'>
// ...
</div>
</div>
to the ...
0
votes
1
answer
1k
views
what is difference between classnames vs classNames from classnames package
I see some project using classnames or classNames to apply multiple class into element. I am wondering what is difference between them and which I should use if I am under my typescript react project? ...
1
vote
1
answer
5k
views
Reactjs / Material-UI: className does not work on the ToggleButton component [duplicate]
Using React / Material UI, I am trying to apply styles to a group of ToggleButtons .
Currently I can only define the style prop for each ToggleButton to make it work.
I am trying to do className={...} ...
0
votes
1
answer
899
views
what do I put in className if I am using CSS module with .active property
Whenever my state in navbar changes, I would like to have the background of NavItems to be transparent when it's false, and add a gradient background when it's true.
I know that if it is normal CSS, I ...
0
votes
1
answer
208
views
How to select widgets by class name like in CSS in Kivy?
For example I want to put a background color to all the buttons in the application :
<Layout1>:
<BoxLayout>:
<Button>:
text: "btn 1"
<...
-1
votes
2
answers
1k
views
Selenium python, use css to select only two class
Suppose I have an HTML that looks like this:
<div class="first second">
Right!
</div>
<div class="first second third fourth">
Wrong!
</div>
<div ...
1
vote
0
answers
83
views
I used the word 'social' for an element classname and it chrome won't display it
I have a div that I was trying to assign a class name of "social-list" to and it wouldn't show up on the page.
I removed the class name from the div and it appeared. I shortened the name to ...
-1
votes
1
answer
665
views
React doesn't read css when the classname is string
I picked up a react project that uses className={css.someStyle} format to link css to components. The problem is that I installed a package and I cannot get any css from it because my app only takes ...
0
votes
0
answers
407
views
How can I change CSS className depending on length of array?
I have a Gatsby project with a blog and I am adding a "related articles" section to a blog post. If the article the reader is reading has related articles with the same tag I want to display ...
0
votes
2
answers
861
views
How do you apply a class's style with setAttribute inside a class that extends HTMLElement?
I have a class that I add an element with a class name that should make the text white which I have defined in my CSS's style, but it does not. The text remains black. How am I supposed to achieve ...
1
vote
1
answer
6k
views
How to conditionally render css with clsx?
I have a button component that's supposed to change colors based on its status (passed in by props). The colors are stored in a css file. I read that the clsx npm is a good one to use, but I don't ...
0
votes
3
answers
905
views
How to toggle css class in react with setState Hook
I tried different ways. But don't manage to toggle this css class. The bookmark should become blue when I click on it. I got so far, I can change to false with onClick, but then it doesn't toggle back....
0
votes
0
answers
32
views
Unregistered Class Toggling
So I've been working in assembly for awhile and just came back to websites after quite some time and one of the questions that are still bothering me today is, why can't I change a class from one ...
0
votes
1
answer
471
views
CSS class naming convention for media queries
What would be the best classname convention for the following example.
If I have different elements with the same grid layout.
<div class="item__1 -has-multipleColumns-XL">Text</div&...
0
votes
2
answers
1k
views
Update ClassNames on State change React js
Is there a way to update a classNames var (in this case 'btClasses') on State change?
...
state = {
active: true
};
btClasses = classNames({
'main-class': true,
'...
4
votes
2
answers
1k
views
When should I use 'className' over 'class' and vise versa in react?
I'm making my first react app and i've come across something interesting, I sometimes use className over class on react. I'm just wondering if they are interchangeable or is it like this for a reason? ...
0
votes
1
answer
1k
views
what does the random string classname using Scss in React app means?
whats the difference between using normal css ClassName in react and using node-sass in react?
which is better and how does a scss ClassName generates a random string in a browser like ...
-1
votes
1
answer
421
views
REACT JS - increment component className?
have just a question if it's possible to increment className in React JS???
to do something like that :
/* in first file */
const rowCount = 68;
class PhotosItem extends Component {
constructor() ...
0
votes
2
answers
1k
views
React className - element.module.css + state.conditional
I'm trying to make a mobile drop down for a React web app.
I'm interested in the correct syntax to use when adding multiple classes to a react element. I want to add styling via an imported module, ...
0
votes
2
answers
811
views
Adding a className if a condition is true
i have a form with multiple fields and a submit button. once i click the submit button it will come to this filterProperties function. i have a if condition inside that filterProperties function. so ...
0
votes
1
answer
215
views
React JS: how to change the bgcolor of a div in a group of divs based on another element's className bgcolor style
setup:
i have dynamically generated two independent groups of divs. First group of divs represents 4 different bgcolor styles [named ArticlePreview] and the second group represents 4 partial examples ...
1
vote
1
answer
557
views
Cannot use string literals for className in react CSS imports?
This is the style.css file:
.cake {
color: red;
}
This is index.js:
Fails:
import React from "react";
import ReactDOM from "react-dom";
import './style.css';
function App() {
return (
&...
5
votes
4
answers
13k
views
Centering text on mobile only
I'm pretty new to advanced CSS. I have a custom heading section which i want to make centered on mobile only. I have added a class name and the following code but nothings happened.
.mobile-text {
...
0
votes
1
answer
592
views
Custom css in material-ui version4.9.0
i have to update the material ui version in my project. The version i used was the 0.20 and now i've updated to v.4.9
I've changed all the imports from material-ui to @materia-ui/core and my app is ...
0
votes
1
answer
70
views
jquery switch not changing css (3 colors)
Do you see what I need to change in this code?
<style>
.bgColor1{background: red !important;}
.bgColor2{background: blue !important;}
.bgColor3{background: green !important;}
...
16
votes
3
answers
33k
views
styling react-select using classes
I am using react-select in my code. https://www.npmjs.com/package/react-select
I want to style my drop down using classNames, so that I referred https://react-select.com/styles. The DOM structure of ...
0
votes
2
answers
316
views
How to change CSS classes according to time received by API
I'm building a weather app in React and so far so good. The problem is now I want to have a "lightmode" and "darkmode" which should be CSS classes that change according to sunrise/sunset times ...
0
votes
1
answer
1k
views
How to get all classname from previous element's NodeList?
I want to add some event listener to every button which placed after some block of element. This button intended to return all element classes from previous block of element if clicked.
I found the ...
0
votes
1
answer
649
views
How to changeClass name of component from library in React?
I need to change one component style from library pure-react-carousel). in the documents said that it could be done by some class name styles of component like below. I know that i have to change this ...
1
vote
1
answer
289
views
How to conditionally call different classNames in ReactJs styling
I have a progressBar in my React component.The progressBar is as shown below in the image:
So, when I am in the second page, the style be as shown below:
And the next image is for the third page:
...
3
votes
3
answers
10k
views
React - Using ternary to apply CSS class in functional component
I'm relatively new to React and working on a John Conway - Game of Life app. I have built a Gameboard.js functional component for the board itself (which is a child of App.js) and a Square.js ...
2
votes
3
answers
21k
views
Can't apply css to React className
Can't apply css to React className...
import React from "react";
import "./index.css";
class CompanyInfo extends React.Component {
render() {
return (
<div className="CompanyInfo"&...