3.1.3 • Published 3 months ago

@chakra-ui/gatsby-plugin v3.1.3

Weekly downloads
1,835
License
MIT
Repository
github
Last release
3 months ago

@chakra-ui/gatsby-plugin

Gatsby plugin for adding Chakra UI

Installation

⚡ To use Chakra UI in your Gatsby site, you need to install the plugin and its peer dependencies.

npm i @chakra-ui/gatsby-plugin @chakra-ui/react @emotion/react @emotion/styled framer-motion

# or

yarn add @chakra-ui/gatsby-plugin @chakra-ui/react @emotion/react @emotion/styled framer-motion

Usage

  1. Add @chakra-ui/gatsby-plugin as a plugin in your Gatsby config.
// gatsby-config.js
module.exports = {
  plugins: ["@chakra-ui/gatsby-plugin"],
}
  1. Use Chakra ⚡
// src/pages/index.js
import React from "react"
import { Box, Text } from "@chakra-ui/react"

function IndexPage() {
  return (
    <Box p={8}>
      <Text fontSize="xl">Hello World</Text>
    </Box>
  )
}

export default IndexPage

Plugin options

By default, this plugin adds the main context provider to make all components work correctly.

<ChakraProvider
  theme={theme}
  resetCSS={resetCSS}
  portalZIndex={portalZIndex}
>
  {element}
</ChakraProvider>

You can disable either of these with Gatsby options:

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: "@chakra-ui/gatsby-plugin",
      options: {
        /**
         * @property {boolean} [resetCSS=true]
         * if `false`, this plugin will not use `<CSSReset />
         */
        resetCSS: true,
        /**
         * @property {number} [portalZIndex=40]
         * The z-index to apply to all portal nodes. This is useful
         * if your app uses a lot z-index to position elements.
         */
        portalZIndex: 40,
      },
    },
  ],
}

Customizing the theme

To use customize the theme in your Gatsby site, you can shadow the plugin's src/@chakra-ui/gatsby-plugin/theme.js file with your own theme:

// src/@chakra-ui/gatsby-plugin/theme.js
import { extendTheme } from "@chakra-ui/react"
const theme = {
  colors: {
    primary: "rebeccapurple"
  }
}

export default extendTheme(theme)

You can learn more about custom theme at Chakra UI's documentation.

By default, Chakra provides a sensible default theme inspired by Tailwind CSS.

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.7

1 year ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0-next.3

2 years ago

3.0.0

2 years ago

3.0.0-next.2

2 years ago

3.0.0-next.1

2 years ago

3.0.0-next.0

2 years ago

2.0.3

2 years ago

2.0.4

2 years ago

2.0.2

2 years ago

2.0.2-next.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago