Skip to Content
文档

容器

用于将内容宽度限制在当前断点,同时保持其流畅。

SourceStorybookRecipe
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.

用法

¥Usage

默认 maxWidth8xl,它映射到 90rem (1440px)

¥The default maxWidth is 8xl which maps to 90rem (1440px).

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

示例

¥Examples

尺寸

¥Sizes

使用 maxWidth 属性更改容器的大小。

¥Use the maxWidth prop to change the size of the container.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.

流体

¥Fluid

使用 fluid 属性使容器拉伸以填充其父级的宽度。

¥Use the fluid prop to make the container stretch to fill the width of its parent.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur, tortor in lacinia eleifend, dui nisl tristique nunc.

属性

¥Props

PropDefaultType
colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'

The color palette of the component

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
centerContent
'true' | 'false'

The centerContent of the component

fluid
'true' | 'false'

The fluid of the component

Previous

居中

Next

弹性