Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
¿Cómo hacer diferentes estilos usando makeStyles en React JS Material-UI?

Soy principiante en React JS y Material UI.

Estoy tratando de hacer diferentes estilos de botones. Por ejemplo, si el nombre del atributo del botón = enviar, aceptar, cancelar, confirmar, alertar, los estilos de cada botón deben ser diferentes entre sí.

Aplicación.JS

 import CssButton from './controls/Buttons/Button' function App() { return ( <div className="App"> <CssButton name="btnSubmit"/> //button style to be changed based on 'name' </div> ); }

Botón.JS

 const useStyles = makeStyles({ btnSubmit: { background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)', border: 0, borderRadius: 3, boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', color: 'white', height: 48, padding: '0 30px', }, ok:{ background: 'blue', border: 0, borderRadius: 3, boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', color: 'white', height: 48, padding: '0 30px', } }); function CssButton(props) { const classes = useStyles(props); return<Button className={classes.btnSubmit}>{props.name}</Button>; //return <button className={`classes.${ props.name }`}> --is it possible pass the props value something like this? // {props.name} //</button> }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usted debe hacer esto:

 const useStyles = makeStyles({ btnSubmit: { background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)', border: 0, borderRadius: 3, boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', color: 'white', height: 48, padding: '0 30px', }, ok:{ background: 'blue', border: 0, borderRadius: 3, boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', color: 'white', height: 48, padding: '0 30px', } }); function CssButton(props) { const classes = useStyles(props); return( <Button className={classes[props.name]}> {props.name} </Button> ); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!