Skip to content

useTheme

Function
useTheme(useDefaultThemeboolean): IMThemeVariables

A React hook that provides the current theme as its value. If the theme is updated, the child component will be re-rendered accordingly.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
import { css } from 'jimu-core'
import { useTheme } from 'jimu-theme'

const MyComponent = () => {
  const theme = useTheme()

  return (
    <div css={css({ backgroundColor: theme.sys.color.surface.paper })}>
      Hello World
    </div>
  )
}
Parameters
ParameterTypeDefault
useDefaultThemebooleantrue
Returns 
IMThemeVariables

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.