Style Hooks

<ThemeConsumer>

A React component that provides access to the theme object defined in your ThemeProvider.

Props

  • name <string>

    An optional prop for consuming only the key in the theme that matches this string

    import {ThemeConsumer} from '@style-hooks/core'
    // Using a global theme
    const Component = () => (
    <ThemeConsumer>
    {theme => {/*do stuff*/}}
    </ThemeConsumer>
    )
    // Using a specific theme, in this example the theme for <Text>
    const Component = () => (
    <ThemeConsumer name='text'>
    {textTheme => {
    // This will only provide the theme defined
    // for theme[name]
    }}
    </ThemeConsumer>
    )

CodeSandbox example

Below is a complete ThemeConsumer example

Continue to useTheme()
NPM icon
MIT License ©2019
Jared Lunde