Last active
September 13, 2021 19:44
-
-
Save lcds90/6a75252ba55c5b9321410fd51935c197 to your computer and use it in GitHub Desktop.
Utilização do css modules no React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// importa em variavel | |
import style from './Login.module.css'; | |
// podemos desestruturar através { form, input }, mas isso é opcional | |
const Login = () => { | |
// utilizado dinamicamente atraves da prop da className, o legal é que podemos realizar condições para aplicar determinada classe | |
const isValidated = true; | |
return ( | |
<form className={ style.form }> | |
<input | |
type="text" | |
className={ style.input } | |
placeholder="Digite seu nome" | |
/> | |
<input | |
type="email" | |
placeholder="Digite seu e-mail" | |
className={ style.input } | |
/> | |
<button | |
className={isValidated ? style.buttonActive : style.buttonDisabled } | |
type="submit" | |
title="Clique aqui para jogar"> | |
Jogar | |
</button> | |
</form> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A classe será gerada como Login_[classe]_[id dinamico do react] evitando conflitos com qualquer outro componente */ | |
.form { | |
/* CSS de exemplos normal */ | |
} | |
.input { | |
} | |
.form > button { | |
/* Podemos utilizar pseudo classes a partir de alguma ja existente no app */ | |
} | |
.buttonActive, .buttonDisabled { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment