2020-03-22 11:38:02 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
|
group: 布局
|
2020-03-22 11:38:02 +08:00
|
|
|
|
subtitle: 间距
|
|
|
|
|
title: Space
|
2022-11-30 20:14:41 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ZiJ3SbOH9SUAAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*37T2R6O9oi0AAAAAAAAAAAAADrJ8AQ/original
|
2020-03-22 11:38:02 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
设置组件之间的间距。
|
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
|
|
|
|
避免组件紧贴在一起,拉开统一的空间。
|
|
|
|
|
|
2020-08-03 13:56:58 +08:00
|
|
|
|
- 适合行内元素的水平间距。
|
|
|
|
|
- 可以设置各种水平对齐方式。
|
2022-11-27 01:58:55 +08:00
|
|
|
|
- 需要表单组件之间紧凑连接且合并边框时,使用 Space.Compact(自 `antd@4.24.0` 版本开始提供该组件)。
|
2020-08-03 13:56:58 +08:00
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## 代码演示
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/base.tsx">基本用法</code>
|
|
|
|
|
<code src="./demo/vertical.tsx">垂直间距</code>
|
|
|
|
|
<code src="./demo/size.tsx">间距大小</code>
|
|
|
|
|
<code src="./demo/align.tsx">对齐</code>
|
|
|
|
|
<code src="./demo/customize.tsx">自定义尺寸</code>
|
|
|
|
|
<code src="./demo/wrap.tsx">自动换行</code>
|
|
|
|
|
<code src="./demo/split.tsx">分隔符</code>
|
|
|
|
|
<code src="./demo/compact.tsx">紧凑布局组合</code>
|
|
|
|
|
<code src="./demo/compact-buttons.tsx">Button 紧凑布局</code>
|
|
|
|
|
<code src="./demo/compact-button-vertical.tsx">垂直方向紧凑布局</code>
|
|
|
|
|
<code src="./demo/compact-debug.tsx" debug>调试 Input 前置/后置标签</code>
|
|
|
|
|
<code src="./demo/compact-nested.tsx" debug>紧凑布局嵌套</code>
|
|
|
|
|
<code src="./demo/debug.tsx" debug>多样的 Child</code>
|
|
|
|
|
<code src="./demo/gap-in-line.tsx" debug>Flex gap 样式</code>
|
|
|
|
|
|
2020-03-22 11:38:02 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2022-10-18 16:23:10 +08:00
|
|
|
|
### Space
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| align | 对齐方式 | `start` \| `end` \|`center` \|`baseline` | - | 4.2.0 |
|
|
|
|
|
| direction | 间距方向 | `vertical` \| `horizontal` | `horizontal` | 4.1.0 |
|
2022-12-22 14:12:26 +08:00
|
|
|
|
| size | 间距大小 | [Size](#size) \| [Size\[\]](#size) | `small` | 4.1.0 \| Array: 4.9.0 |
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| split | 设置拆分 | ReactNode | - | 4.7.0 |
|
|
|
|
|
| wrap | 是否自动换行,仅在 `horizontal` 时有效 | boolean | false | 4.9.0 |
|
2020-11-27 13:40:40 +08:00
|
|
|
|
|
|
|
|
|
### Size
|
|
|
|
|
|
|
|
|
|
`'small' | 'middle' | 'large' | number`
|
2022-10-18 16:23:10 +08:00
|
|
|
|
|
|
|
|
|
### Space.Compact
|
|
|
|
|
|
|
|
|
|
> 自 antd@4.24.0 版本开始提供该组件。
|
|
|
|
|
|
|
|
|
|
需要表单组件之间紧凑连接且合并边框时,使用 Space.Compact。支持的组件有:
|
|
|
|
|
|
|
|
|
|
- Button
|
|
|
|
|
- AutoComplete
|
|
|
|
|
- Cascader
|
|
|
|
|
- DatePicker
|
|
|
|
|
- Input/Input.Search
|
|
|
|
|
- Select
|
|
|
|
|
- TimePicker
|
|
|
|
|
- TreeSelect
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| block | 将宽度调整为父元素宽度的选项 | boolean | false | 4.24.0 |
|
|
|
|
|
| direction | 指定排列方向 | `vertical` \| `horizontal` | `horizontal` | 4.24.0 |
|
|
|
|
|
| size | 子组件大小 | `large` \| `middle` \| `small` | `middle` | 4.24.0 |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Space"></ComponentTokenTable>
|