Container
简介
Container 组件是一个基础的布局容器,用于限制内容宽度并居中显示。它提供了多种尺寸和内边距选项,适用于各种布局需求。
案例
这是一个基础的容器,内容被限制在合理宽度内。
Props
aspectRatio
宽高比(宽/高),设置后容器会保持这个比例,如 16/9、4/3、1 等。
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatio16x9
* @description Container 组件 16:9 比例示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container aspectRatio={16 / 9} background="primary/10" border rounded="md">
<p>16:9 比例的内容区域</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatio4x3
* @description Container 组件 4:3 比例示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container aspectRatio={4 / 3} background="secondary/10" border rounded="lg">
<p>4:3 比例的内容区域</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatio1x1
* @description Container 组件正方形比例示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
aspectRatio={1}
width="sm"
background="accent/10"
border
rounded="md">
<p>正方形内容</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatio3x2
* @description Container 组件 3:2 比例示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container aspectRatio={3 / 2} background="neutral/10" border rounded="xl">
<p>3:2 比例的内容区域</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatioWithHeight
* @description Container 组件 aspectRatio + height 示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
aspectRatio={1 / 2}
height="6xl"
background="info/10"
rounded="md"
class="not-prose">
<p>
<code>height="6xl"</code>
<code>aspectRatio="1/2"</code>
</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatioWithWidth
* @description Container 组件 aspectRatio + width 示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
aspectRatio={1 / 2}
width="xs"
background="success/10"
rounded="md"
class="not-prose">
<p>
<code>width="xs"</code> 和 <code>aspectRatio={1 / 2}</code> 共同作用。
</p>
</Container>
16:9 比例的内容区域
4:3 比例的内容区域
正方形内容
3:2 比例的内容区域
height="6xl"
aspectRatio="1/2"
width="xs"
和 aspectRatio=0.5
共同作用。
- 不能同时设置 aspectRatio、width 与 height。可两两组合,但不能同时设置3个。
---
/**
* @component ContainerAspectRatioConflict
* @description Container 组件 aspectRatio/width/height 冲突演示
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
aspectRatio={16 / 9}
width="md"
height="lg"
background="warning/10"
rounded="md"
class="not-prose"
/>
background
背景色类型,支持背景色和透明度变体,如:base-100、primary、secondary、accent、neutral、info、success、warning、error、primary/10、secondary/20 等。
基础背景色 base-100
主要背景色 primary
强调背景色 accent
透明度背景色 primary/10
成功背景色 success
---
import { Container } from '@coffic/cosy-ui';
---
<Container background="base-100" padding="md" border rounded="md">
<p>基础背景色 base-100</p>
</Container>
基础背景色 base-100
主要背景色 primary
强调背景色 accent
透明度背景色 primary/10
成功背景色 success
---
import { Container } from '@coffic/cosy-ui';
---
<Container background="primary" padding="md" border rounded="md">
<p>主要背景色 primary</p>
</Container>
基础背景色 base-100
主要背景色 primary
强调背景色 accent
透明度背景色 primary/10
成功背景色 success
---
import { Container } from '@coffic/cosy-ui';
---
<Container background="accent" padding="md" border rounded="md">
<p>强调背景色 accent</p>
</Container>
基础背景色 base-100
主要背景色 primary
强调背景色 accent
透明度背景色 primary/10
成功背景色 success
---
import { Container } from '@coffic/cosy-ui';
---
<Container background="primary/10" padding="md" border rounded="md">
<p>透明度背景色 primary/10</p>
</Container>
基础背景色 base-100
主要背景色 primary
强调背景色 accent
透明度背景色 primary/10
成功背景色 success
---
import { Container } from '@coffic/cosy-ui';
---
<Container background="success" padding="md" border rounded="md">
<p>成功背景色 success</p>
</Container>
border
是否显示边框,启用后会在容器周围添加边框。
带边框的容器 (border=true)
无边框的容器 (border=)
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" border background="primary/10" rounded="md">
<p style="text-align: center;">带边框的容器 (border={true})</p>
</Container>
带边框的容器 (border=true)
无边框的容器 (border=)
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" background="secondary/10" border={false}>
<p style="text-align: center;">无边框的容器 (border={false})</p>
</Container>
centered
是否居中显示,设置为 false 时容器将靠左对齐。
居中显示的容器 (centered=true)
左对齐的容器 (centered=)
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" border background="primary/10" centered rounded="md">
<p style="text-align: center;">居中显示的容器 (centered={true})</p>
</Container>
居中显示的容器 (centered=true)
左对齐的容器 (centered=)
---
import { Container } from '@coffic/cosy-ui';
---
<Container
width="md"
border
background="secondary/10"
centered={false}
rounded="md">
<p style="text-align: left;">左对齐的容器 (centered={false})</p>
</Container>
class
自定义 CSS 类名,用于添加额外的样式。
基础容器,使用 class="custom-basic"
高级容器,使用多个 class
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" class="custom-basic">
<p>基础容器,使用 class="custom-basic"</p>
</Container>
<style>
.custom-basic {
background-color: #3b82f6;
color: white;
border: 2px dashed #3b82f6;
}
</style>
基础容器,使用 class="custom-basic"
高级容器,使用多个 class
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" class="custom-advanced custom-theme">
<p>高级容器,使用多个 class</p>
</Container>
<style>
.custom-advanced {
background-color: #3b82f6;
color: white;
border: 2px dashed #3b82f6;
}
.custom-theme {
background-color: #1e40af;
color: white;
border: 2px dashed #1e40af;
}
</style>
contentBorder
仅在 fit
为 contain
或 cover
时生效。
是否给比例内容区域(fit 模式下的内部比例盒)添加边框。
比例内容区域带边框
比例内容区域无边框
---
/**
* @component ContainerContentBorderTrue
* @description Container 组件 contentBorder=true 示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
fit="contain"
aspectRatio={3 / 4}
height="lg"
background="accent/10"
contentBorder>
<p>比例内容区域带边框</p>
</Container>
比例内容区域带边框
比例内容区域无边框
---
/**
* @component ContainerContentBorderFalse
* @description Container 组件 contentBorder=false 示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container
fit="contain"
aspectRatio={3 / 4}
height="lg"
background="accent/10"
contentBorder={false}>
<p>比例内容区域无边框</p>
</Container>
fit
内容适配模式。可选值:none
(默认)、contain
(保持比例,尽量占满且不溢出)、cover
(保持比例,铺满并可能裁剪)。需要与 aspectRatio
一起使用,且建议父容器具有明确高度(如 height="lg"
)。
按比例自适应(contain)
内容保持 1:2 比例,尽可能占满父容器且不会溢出。
父容器高度由 height 控制,宽度受 width 或页面布局限制。
按比例铺满(cover)
内容保持 4:3 比例,铺满可用区域,可能会被裁剪。
---
/**
* @component ContainerFitContain
* @description Container 组件 fit="contain" 示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Container
fit="contain"
aspectRatio={1 / 2}
height="2xl"
background="primary/10"
contentBorder
rounded="md">
<Heading level={4}>按比例自适应(contain)</Heading>
<p>内容保持 1:2 比例,尽可能占满父容器且不会溢出。</p>
<p>父容器高度由 height 控制,宽度受 width 或页面布局限制。</p>
</Container>
按比例自适应(contain)
内容保持 1:2 比例,尽可能占满父容器且不会溢出。
父容器高度由 height 控制,宽度受 width 或页面布局限制。
按比例铺满(cover)
内容保持 4:3 比例,铺满可用区域,可能会被裁剪。
---
/**
* @component ContainerFitCover
* @description Container 组件 fit="cover" 示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Container
fit="cover"
aspectRatio={4 / 3}
height="lg"
background="secondary/10"
contentBorder
rounded="md">
<Heading level={4}>按比例铺满(cover)</Heading>
<p>内容保持 4:3 比例,铺满可用区域,可能会被裁剪。</p>
</Container>
flex
flex 布局方向,可选值:row、col、row-reverse、col-reverse,不设置则不启用 flex 布局。
---
/**
* @component ContainerFlexRow
* @description Container 组件行布局示例
*/
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
flex="row"
gap="md"
class="cosy:bg-base-200"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary" class="cosy:p-2"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent" class="cosy:p-2"> 项目 3 </PlaceHolder>
</Container>
---
/**
* @component ContainerFlexCol
* @description Container 组件列布局示例
*/
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container flex="col" gap="md" background="accent/40" border rounded="md">
<PlaceHolder background="primary" class="cosy:p-2"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent" class="cosy:p-2"> 项目 3 </PlaceHolder>
</Container>
---
/**
* @component ContainerFlexCenter
* @description Container 组件居中对齐示例
*/
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
flex="row"
gap="md"
items="center"
justify="center"
rounded="md"
border
background="accent/40"
class="not-prose">
<PlaceHolder background="primary" class="cosy:p-2"> 居中 </PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2"> 对齐 </PlaceHolder>
</Container>
---
/**
* @component ContainerFlexBetween
* @description Container 组件两端对齐示例
*/
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
flex="row"
gap="md"
justify="between"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary" class="cosy:p-2"> 左侧 </PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2"> 右侧 </PlaceHolder>
</Container>
gap
flex 项目间距,可选值:none、xs、sm、md、lg、xl,仅在启用 flex 布局时生效。
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
flex="row"
gap="none"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary" class="cosy:p-2"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent" class="cosy:p-2"> 项目 3 </PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
flex="row"
gap="sm"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent"> 项目 3 </PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
flex="row"
gap="md"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent"> 项目 3 </PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
flex="row"
gap="lg"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent"> 项目 3 </PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
flex="row"
gap="xl"
border
rounded="md"
background="accent/30">
<PlaceHolder background="primary"> 项目 1 </PlaceHolder>
<PlaceHolder background="secondary"> 项目 2 </PlaceHolder>
<PlaceHolder background="accent"> 项目 3 </PlaceHolder>
</Container>
height
容器高度,可选值:none、xs、sm、md、lg、xl、2xl、3xl、4xl、5xl、6xl、screen、auto,none 表示不设置高度。
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="xs" border background="primary/10" height="xs" rounded="md">
<p>小高度容器</p>
</Container>
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="sm" border background="secondary/10" height="md" rounded="md">
<p>中等高度容器</p>
</Container>
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="sm" border background="accent/10" height="lg" rounded="md">
<p>大高度容器</p>
</Container>
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="sm" border background="info/10" height="2xl" rounded="md">
<p>超大高度容器</p>
</Container>
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container
width="sm"
border
background="warning/10"
height="screen"
rounded="md">
<p>屏幕高度容器</p>
</Container>
小高度容器
中等高度容器
大高度容器
超大高度容器
屏幕高度容器
自动高度容器
内容决定高度
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="sm" border background="success/10" rounded="md">
<p>自动高度容器</p>
<p>内容决定高度</p>
</Container>
items
flex 项目水平对齐方式,可选值:start、end、center、baseline、stretch,仅在启用 flex 布局时生效。
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
items="start"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">顶部对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">顶部对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
items="center"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">居中对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">居中对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
items="end"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">底部对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">底部对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
items="stretch"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">拉伸对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">拉伸对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
items="baseline"
border
rounded="md"
background="accent/40">
<PlaceHolder background="primary" class="cosy:p-2">基线对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">基线对齐</PlaceHolder>
</Container>
justify
flex 项目垂直对齐方式,可选值:start、end、center、between、around、evenly,仅在启用 flex 布局时生效。
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="start"
border
rounded="md"
background="accent/40">
<PlaceHolder background="primary" class="cosy:p-2">左对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">左对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="center"
border
rounded="md"
background="accent/40">
<PlaceHolder background="primary" class="cosy:p-2">居中对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">居中对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="end"
border
rounded="md"
background="accent/40">
<PlaceHolder background="primary" class="cosy:p-2">右对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">右对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="between"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">两端对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">两端对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="around"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">环绕对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">环绕对齐</PlaceHolder>
</Container>
---
import { Container, PlaceHolder } from '@coffic/cosy-ui';
---
<Container
width="md"
height="xl"
flex="row"
justify="evenly"
background="accent/40"
border
rounded="md">
<PlaceHolder background="primary" class="cosy:p-2">均匀对齐</PlaceHolder>
<PlaceHolder background="secondary" class="cosy:p-2">均匀对齐</PlaceHolder>
</Container>
margin
外边距大小,可选值:none、xs、sm、md、lg、xl、2xl、3xl、4xl、5xl、6xl。
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginNone
* @description Container 组件无外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="none" background="accent/40">
<p class="cosy:text-center">无外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginXs
* @description Container 组件xs外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="xs" background="accent/40">
<p class="cosy:text-center">xs外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginSm
* @description Container 组件sm外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="sm" background="accent/40">
<p class="cosy:text-center">sm外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginMd
* @description Container 组件中等外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="md" background="accent/40">
<p class="cosy:text-center">中等外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginLg
* @description Container 组件lg外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="lg" background="accent/40">
<p class="cosy:text-center">lg外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMarginXl
* @description Container 组件xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="xl" background="accent/40">
<p class="cosy:text-center">xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMargin2xl
* @description Container 组件2xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="2xl" background="accent/40">
<p class="cosy:text-center">2xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMargin3xl
* @description Container 组件3xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="3xl" background="accent/40">
<p class="cosy:text-center">3xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMargin4xl
* @description Container 组件4xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="4xl" background="accent/40">
<p class="cosy:text-center">4xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMargin5xl
* @description Container 组件5xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="5xl" background="accent/40">
<p class="cosy:text-center">5xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
上方内容区域
无外边距的容器
下方内容区域
上方内容区域
xs外边距的容器
下方内容区域
上方内容区域
sm外边距的容器
下方内容区域
上方内容区域
中等外边距的容器
下方内容区域
上方内容区域
lg外边距的容器
下方内容区域
上方内容区域
xl外边距的容器
下方内容区域
上方内容区域
2xl外边距的容器
下方内容区域
上方内容区域
3xl外边距的容器
下方内容区域
上方内容区域
4xl外边距的容器
下方内容区域
上方内容区域
5xl外边距的容器
下方内容区域
上方内容区域
6xl外边距的容器
下方内容区域
---
/**
* @component ContainerMargin6xl
* @description Container 组件6xl外边距示例
*/
import { Container, Heading } from '@coffic/cosy-ui';
---
<Heading level={3} margin="none" background="info" padding="sm"
>上方内容区域</Heading
>
<Container margin="6xl" background="accent/40">
<p class="cosy:text-center">6xl外边距的容器</p>
</Container>
<Heading level={3} margin="none" background="info" padding="sm"
>下方内容区域</Heading
>
padding
内边距大小,可选值:none、sm、md、lg、xl。
无内边距
小内边距
中等内边距
大内边距
超大内边距
---
/**
* @component ContainerPaddingNone
* @description Container 组件无内边距示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container padding="none" background="accent/40" border rounded="md">
<p>无内边距</p>
</Container>
无内边距
小内边距
中等内边距
大内边距
超大内边距
---
/**
* @component ContainerPaddingSm
* @description Container 组件小内边距示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container padding="sm" background="accent/40" border rounded="md">
<p>小内边距</p>
</Container>
无内边距
小内边距
中等内边距
大内边距
超大内边距
---
/**
* @component ContainerPaddingMd
* @description Container 组件中等内边距示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container padding="md" background="accent/40" border rounded="md">
<p>中等内边距</p>
</Container>
无内边距
小内边距
中等内边距
大内边距
超大内边距
---
/**
* @component ContainerPaddingLg
* @description Container 组件大内边距示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container padding="lg" background="accent/40" border rounded="md">
<p>大内边距</p>
</Container>
无内边距
小内边距
中等内边距
大内边距
超大内边距
---
/**
* @component ContainerPaddingXl
* @description Container 组件超大内边距示例
*/
import { Container } from '@coffic/cosy-ui';
---
<Container padding="xl" background="accent/40" border rounded="md">
<p>超大内边距</p>
</Container>
rounded
圆角大小,可选值:none、sm、md、lg、xl、full。
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="none" border background="accent/10">
<p>无圆角</p>
</Container>
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="sm" border background="accent/10">
<p>小圆角</p>
</Container>
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="md" border background="accent/10">
<p>中等圆角</p>
</Container>
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="lg" border background="accent/10">
<p>大圆角</p>
</Container>
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="xl" border background="accent/10">
<p>超大圆角</p>
</Container>
无圆角
小圆角
中等圆角
大圆角
超大圆角
完全圆角
---
import { Container } from '@coffic/cosy-ui';
---
<Container rounded="full" border background="accent/10">
<p>完全圆角</p>
</Container>
width
容器宽度,可选值:xs、sm、md、lg、xl、full,控制容器的最大宽度。
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="xs" border background="accent/10" rounded="md">
<p>超小宽度容器</p>
</Container>
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="sm" border background="accent/10" rounded="md">
<p>小宽度容器</p>
</Container>
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="md" border background="accent/10" rounded="md">
<p>中等宽度容器</p>
</Container>
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="lg" border background="accent/10" rounded="md">
<p>大宽度容器</p>
</Container>
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="xl" border background="accent/10" rounded="md">
<p>超大宽度容器</p>
</Container>
超小宽度容器
小宽度容器
中等宽度容器
大宽度容器
超大宽度容器
全宽容器
---
import { Container } from '@coffic/cosy-ui';
---
<Container width="full" border background="accent/10" rounded="md">
<p>全宽容器</p>
</Container>