Skip to content

SPFX Web Part theme support #211

Answered by layershifter
PetrKotal21 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @PetrKotal21,

The goal of Griffel is to be able to do ahead of time compilation and there are things that we should limit. For example, the snippet below will not work:

// 🚨 Not real code, will *not* work
function App() {
  const theme = useTheme()
  const styles = makeStyles({
    root: {
      color: theme.semanticColors.bodyText
    }
  })
}

However, if theme is just values it will work:

const theme ={
  semanticColors: {
    bodyText: 'red'
  }
}

const useStyles = makeStyles({
    root: {
      color: theme.semanticColors.bodyText
    }
  })

// ✅ this will work
function App() {
  const classes = useStyles()
 // ...
}

Fair not: there is no much value in this as then theme switchi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by layershifter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants