Container

Containers are used to constrain a content's width to the current breakpoint, while keeping it fluid.

By default, it sets the max-width of the content to 60 characters (60ch) but you can customize this by passing custom maxWidth values or changing the container size tokens defined in theme.sizes.container.

Import#

import { Container } from "@chakra-ui/react"

Usage#

To contain any piece of content, wrap it in the Container component.

There are many benefits to a joint design and development system. Not only does it bring benefits to the design team, but it also brings benefits to engineering teams. It makes sure that our experiences have a consistent look and feel, not just in our design specs, but in production
Editable Example

Centering the children#

In some cases, the width of the content can be smaller than the container's width, you can use the centerContent prop to center the content.

<Container maxW="xl" centerContent>
<Box padding="4" bg="gray.100" maxW="3xl">
There are many benefits to a joint design and development system. Not only
does it bring benefits to the design team.
</Box>
</Container>

Props#

Container composes Box so you can pass all Box related props in addition to this.

NameTypeDescriptionDefault
centerContentbooleanIf `true`, container will center its children regardless of their width.-
colorScheme"blue" | "cyan" | "gray" | "green" | "orange" | "pink" | "purple" | "red" | "teal" | "yellow" | "whiteAlpha" | "blackAlpha" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"Color Schemes for Container are not implemented in the default theme. You can extend the theme to implement them.-
sizestringSizes for Container are not implemented in the default theme. You can extend the theme to implement them.-
variantstringVariants for Container are not implemented in the default theme. You can extend the theme to implement them.-