Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

577
Visualizações
MUI - Styling text inside ListItemText

I'm trying to apply style to the text inside a ListItemText (MUI):

const text = {
  color: 'red'
}

<ListItem button><ListItemText style={text} primary="MyText" /></ListItem>

But the rendered Typograhy element inside is not styled at all ("MyText" is not red).

Looking at the generated code, it seems that the default CSS rules for Typography > subheading is overriding my CSS.

Thanks for your help

Edit: In the first version of the question, there was a misake ("className" instead of "style" prop on ListItemText, sorry about that).

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I beleive the only way to achieve this right now is to use the 'disableTypography' prop of the ListItemText element.

 <ListItemText
        disableTypography
        primary={<Typography type="body2" style={{ color: '#FFFFFF' }}>MyTitle</Typography>}
      />

This lets you embed your own text element with whatever styling you want on it.

over 4 years ago · Santiago Trujillo Relatório

0

this is good one, you can implement without disabling typography

<ListItemText 
   classes={{ primary: this.props.classes.whiteColor }}
   primary="MyTitle"
/>
over 4 years ago · Santiago Trujillo Relatório

0

Per the documentation, the <ListItemText /> component exposes the prop primaryTypographyProps, which we can use to accomplish what you're attempting in your question:

const text = {
    color: "red"
};

<ListItem button>
    <ListItemText primaryTypographyProps={{ style: text }} primary="MyText" />
</ListItem>

Hope that helps!

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda