Material UI customize property behind classes

36 Views Asked by At

I am trying to make an application. And I want to customize the value that comes after classes.something. The something I want to be a value that comes out of my API.

I made 2 custom CSS classes:

new: {
    color: '#0099FF',
  },
improvement: {
    color: '#01C86B',
  }, 

And I get the words new, improvement out of my API. I want to add them in the first Is this even possible? something like classes.entry.entry_tag

Because all the tags that are available are in the value entry.entry_tag


  const showContent = whatsNewDoc.entries.map(entry => {
    return (
      <React.Fragment>
        <Typography variant="h6" className={classes.tagTitle}>
          <span className={classes.tagBackground}>{entry.entry_tag}</span>
        </Typography>
        <PrismicContents>{entry.entry_title}</PrismicContents>

        <PrismicContents>{entry.entry_body}</PrismicContents>
        <Divider className={classes.dividerSpace} />
      </React.Fragment>
    )
  })
1

There are 1 best solutions below

0
On

I'm not sure if this is what you want.

variable_name = getResponseFromApi()

You can just write classes[variable_name] since classes is just an object