Back to Chakra Ui

Center

apps/www/content/docs/components/center.mdx

0.3.0-beta1.4 KB
Original Source
<ExampleTabs name="center-basic" />

Usage

jsx
import { Center, Circle, Square } from "@chakra-ui/react"
jsx
<Center bg="tomato" h="100px" color="white">
  This is the Center
</Center>

Examples

Icon

Center can be used to create frames around icons or numbers.

<ExampleTabs name="center-with-icons" />

Center with Inline

Use the inline prop to make Center behave like an inline element (display: inline-flex) instead of a block-level element (display: flex). This makes Center only take up as much width as its content needs, allowing it to fit inside links, buttons, or other inline contexts without breaking the layout.

<ExampleTabs name="center-with-inline" />

Square

Square centers its child within a fixed-size container of equal width and height. It accepts a size prop that sets both width and height to the same value.

<ExampleTabs name="center-with-square" />

Circle

Circle extends Square by adding borderRadius="9999px" to create a perfect circle. Like Square, it accepts a size prop that sets both width and height to the same value.

<ExampleTabs name="center-with-circle" />

Props

Center

<PropTable component="Center" part="Center" />

Square

<PropTable component="Square" part="Square" />

Circle

Circle extends Square and accepts all the same props. The only difference is that Circle applies borderRadius="9999px".

<PropTable component="Circle" part="Circle" />