Home > Web Front-end > Front-end Q&A > What is the usage of react classnames

What is the usage of react classnames

藏色散人
Release: 2022-12-28 10:22:33
Original
2493 people have browsed it

Usage of react classnames: 1. Install classnames through "install i classnames --save"; 2. Use "import classnames from 'classnames';" to reference classnames; 3. Pass "className={classnames( Styles.xxxxx)}" method can be used by using the classnames library.

What is the usage of react classnames

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What is the usage of react classnames?

Usage of react classnames

When you want to use multiple classNames in react, you will use the classnames library

Installation

install i classnames --save
Copy after login
yarn add classnames --save
Copy after login

vs code styles prompt tool can install css modules clinyong.vscode-css-modules

Quote

import classnames from 'classnames';
Copy after login

Use

The first way

import Styles from './pagin-cover.less';
<Pagination
className={classnames(Styles[&#39;scf-pagination&#39;],
{[Styles[&#39;xxxx&#39;]] : status === 1}
)}
/>
//或者
<Pagination
className={classnames(Styles.xxxxx)}
/>
Copy after login

The second way

import  &#39;./pagin-cover.less&#39;;
<Pagination
className={classnames({&#39;scf-pagination&#39;:true,&#39;xxxx&#39;: status === 1})}
/>
Copy after login

The third way

import  &#39;./pagin-cover.less&#39;;
<Pagination
className={classnames(&#39;scf-pagination&#39;,&#39;xxxxx&#39;)}
/>
Copy after login

Recommended learning: "react video tutorial"

The above is the detailed content of What is the usage of react classnames. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template