vuvu
vuvu

Reputation: 5338

How to import a mui theme color into a component?

I want to import a Mui theme color to pass its value to a component. How can I import the color?

const WonderChart = () => {

  return (
    <WonderChart lineColor={theme.palette.primary.main} />
  )
}

Upvotes: 0

Views: 834

Answers (1)

Rajiv
Rajiv

Reputation: 3772

useTheme hook can be used for this.
Documentation

import { useTheme } from '@material-ui/core/styles';


const WonderChart = () => {
  const theme = useTheme()
  return (
    <WonderChart lineColor={theme.palette.primary.main} />
  )
}

Upvotes: 1

Related Questions