PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] how Can I use css modules and global style together on React

 August 23, 2022     classname, css, module, reactjs, styles     No comments   

Issue

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 "./ProductHeader.module.css";
.
.
.
<div className="col-12" className={Header.title} ></div>

Solution

You can use it like

<div className={`col-12 ${Header.title}`}"></div>

This way you can string and variable together in any attribute

You can also use it conditionally

<div className={`col-12 ${someCondition ? Header.title : Header.subTitle}`}></div>


Answered By - Jahanzeb Sethi
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing