Style Hooks

createElement(type, props, children)

createElement() is a jsx factory function which does three things:

  1. Turns the css prop generated by useStyles() into a class name with attached CSS styles
  2. Allows you to define an as prop on your component to override the default component type defined in the first argument of the function
  3. Create and return a new React element of the given type by calling React.createElement(type, props, children)


  • type <string|React.Component> required

    This is the default type you want to render into the element tree. It can be overridden elsewhere by defining an as prop on your component. Can be either a tag name string (such as 'div' or 'span'), a React component type (a class or a function), or a React fragment type.

    import {createElement} from '@style-hooks/core'
    const MyComponent = props => {
    props = useMyComponent(props)
    return createElement('div', props)
    // Creates a <div/>
    // Creates a <span/>
    <MyComponent as='span'/>
    // Creates a <OtherComponent/>
    <MyComponent as={OtherComponent}/>

  • props <object> required

    The element's props

  • children <React.Children>

    The element's children (if not defined in props)

Continue to <ThemeProvider>
NPM icon
MIT License ©2019
Jared Lunde