Skip to content

Is there a recommended way to set up theming with Griffel? #111

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

You must be logged in to vote

Hey,

We decided to not build anything into Griffel itself for styling to avoid restrictions and limitations. I think that the best approach for styling nowadays is CSS variables (and it's what we picked for Fluent UI React v9 aka @fluentui/react-components) and it's what I can recommend for moving forward.

I made an example on CodeSandbox that could be useful (https://codesandbox.io/s/xenodochial-star-ob7oxt?file=/src/App.tsx). There are three pieces:

  • define themes (lightTheme, darkTheme)
  • a Proxy for tokens: you can enumerate tokens manually, but it's will be really boring process
    const tokens = {
      foreground: 'var(--foreground)',
      background: 'var(--background)',
      // etc.
    }
  • insertio…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@AkimaLunar
Comment options

@layershifter
Comment options

Answer selected by AkimaLunar
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