TSS
HomeGitHubPlayground
v3
v3
  • ๐Ÿš€Why TSS
  • ๐Ÿ”งSetup
  • ๐Ÿ”API References
    • makeStyles -> useStyles
    • withStyles
    • <GlobalStyles />
    • keyframes
    • useMergedClasses
  • ๐Ÿ’ฝCache
  • ๐Ÿ’ซNested selectors (ex $ syntax)
  • โšกSSR
    • Gatsby
    • Next.js
    • Other backends
  • ๐ŸฆฑYour own classes prop
  • ๐ŸญMUI Theme styleOverrides
  • ๐ŸงนDetecting unused classes
  • ๐Ÿ“ฆPublish a module that uses TSS
  • ๐Ÿ”ฉsingle-spa
  • ๐Ÿ“ฒReact Native
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

Cache

How to integrate emotion cache with TSS

PrevioususeMergedClassesNextNested selectors (ex $ syntax)

Last updated 2 years ago

Was this helpful?

By default, tss-react uses an emotion cache that you can access with

import { getTssDefaultEmotionCache } from "tss-react"

If you want tss-react to use a specific you can provide it using

import { TssCacheProvider } from "tss-react"

If you are using tss-react with mui, be aware that mui and TSS can't share the same cache.

Also the caches used by mui should have be instantiated with "prepend": true.

import createCache from "@emotion/cache";
import { TssCacheProvider } from "tss-react";
import { CacheProvider } from "@emotion/react";

const muiCache = createCache({
    "key": "my-custom-prefix-for-mui",
    "prepend": true
});

const tssCache = createCache({
    "key": "my-custom-prefix-for-tss"
});

<CacheProvider value={muiCache}>
    <TssCacheProvider value={tssCache}>
        {/* ... */}
    </TssCacheProvider>
</CacheProvider>;

Using custom emotion caches impact how you .

๐Ÿ’ฝ
emotion cache
setup SSR