Material-UI next - Styling text inside ListItemText

Julien Tanay picture Julien Tanay · May 15, 2017 · Viewed 36.6k times · Source

i'm trying to apply style to the text inside a ListItemText (Material-UI @next):

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).

Answer

Sundaram Ravi picture Sundaram Ravi · Jun 19, 2017

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.