DocsBlog
  • 1.3.0

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

Cerberus FactoryResponsive DesignCSS VariablesThemes & Color ModesColor Opacity ModifierConditional StylesVirtual ColorCascade Layers

Compositions

Animation StylesLayer StylesNewText Styles

Style Props

BackgroundBorderEffectsSpacingText GradientTransitionsZ-Index

Layer Styles

Learn how to use layer styles to define visual properties.

Overview

Layer styles allow you to define visual properties. The common properties are:

  • Color or text color
  • Background color
  • Border width and border color
  • Box shadow
  • Opacity

Defining layer styles

Layer styles are defined using the defineLayerStyles function.

import { defineLayerStyles } from '@chakra-ui/react'

  const layerStyles = defineLayerStyles({
    container: {
      description: 'container styles',
      value: {
        background: 'gray.50',
        border: '2px solid',
        borderColor: 'gray.500',
      },
    },
  })

Built-in layer styles

Chakra UI provides a set of built-in layer styles.

indicator.*

indicator.bottom
indicator.top
indicator.start
indicator.end

outline.*

outline.subtle
outline.solid

states:

disabled
none

Updating the theme

To use the layer styles, update the theme object with the layerStyles property.

After updating the theme, run the typegen command to generate the typings. See the CLI docs for how to run typegen in postinstall, CI, and monorepos.

Terminal
Copy
npm run prepare
Terminal
Copy
pnpm run prepare
Terminal
Copy
deno run npm:prepare
Terminal
Copy
bun run prepare

Using layer styles

Now you can use layerStyle property in your components.

<Box layerStyle="outline.subtle" />

To utilize in the css function:

css({ layerStyle: 'outline.subtle' })

On this page

Loading...

Loading...

Loading...

Loading...

On this page

  • Overview
  • Defining layer styles
  • Built-in layer styles
  • Updating the theme
  • Using layer styles
  • Edit this page on Github