mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 09:50:58 +08:00
4560adfdf8
* refactor(style): adjust component size to large/default/small * refactor(components): avatar size & use flex instead of block * refactor(components): adjust check button size * refactor(components): adjust tag size * refactor(components): adjust size doc * fix(components): datetime-picker demo style width * refactor(components): color-picker size & block to flex * refactor(components): adjust slider input size * refactor(components): adjust radio input size for demo * refactor(components): adjust select size & docs * refactor(components): adjust form radio size & docs * refactor(components): add windicss for docs * refactor(components): adjust skeleton avatar size to css var * refactor(components): simplify typography size demo * refactor(components): adjust dropdown size & demo * refactor(components): adjust descriptions size * fix(components): datetime-picker showcase class pollute global button * chore(ci): upgrade docs dependencies to fix ci * fix(ci): add highlight because vitepress not export it * fix(ci): disable line for no-console * fix(ci): remove mini to fix test * fix(style): code font size * fix(style): button span flex style * fix(style): button padding horizontal default 15px * refactor(components): adjust tag padding size & demo * refactor(components): adjust form line-height for input * refactor(components): adjust dropdown menu size & button padding * fix(style): picker separator block to flex center * fix: dropdown button span items-center * style: adjust input-with-icon & size demo & fix input vitepress load * chore: upgrade dependencies * chore: upgrade dependencies * ci: fix website build * ci: regenerate pnpm-lock.yaml * ci: use dev pnpm-lock * ci: update pnpm-lock.yaml
142 lines
5.2 KiB
Markdown
142 lines
5.2 KiB
Markdown
---
|
|
title: Space
|
|
lang: en-US
|
|
---
|
|
|
|
# Space
|
|
|
|
Even though we have [Divider](/en-US/component/divider), but sometimes we need more than one [Divider](/en-US/component/divider) to split the elements apart, so we stack each elements upon [Divider](/en-US/component/divider), but doing so not only makes our code ugly but also makes it difficult to maintain. **Space** is this kind of component provides us both productivity and elegance.
|
|
|
|
## Basic usage
|
|
|
|
The basic use case is using this component to provide unified space between each components
|
|
|
|
:::demo Using Space to provide space
|
|
|
|
space/basic
|
|
|
|
:::
|
|
|
|
## Vertical layout
|
|
|
|
Using `direction` attribute to control the layout, we use `flex-direction` to implement this.
|
|
|
|
:::demo We also provide vertical layout.
|
|
|
|
space/vertical-layout
|
|
|
|
:::
|
|
|
|
## Control the size of the space
|
|
|
|
Control the space size via `size` API.
|
|
|
|
You can set the size with built-in sizes `small`, `default`, `large`, these size coresponds to `4px`, `8px`, `12px`, `16px`. The default size is `small`, A.K.A. `8px`
|
|
|
|
You can also using customized size to override it. Refer to the next part.
|
|
|
|
:::demo
|
|
|
|
space/control-size
|
|
|
|
:::
|
|
|
|
## Customized Size
|
|
|
|
Sometimes built-in sizes could not meet the business needs, we can use custom size (number type) to control the space between items.
|
|
|
|
:::demo
|
|
|
|
space/customized-size
|
|
|
|
:::
|
|
|
|
:::tip
|
|
|
|
Do not use `ElSpace` with components that depend on ancestor width (height), e.g. `ElSlider`, in this case when you drag the trigger button the bar will grow which causes misplacement between cursor and trigger button.
|
|
|
|
:::
|
|
|
|
## Auto wrapping
|
|
|
|
When in **horizontal** mode, using `wrap` (**bool type**) to control auto wrapping behavior.
|
|
|
|
:::demo Using `wrap` to control line wrap
|
|
|
|
space/auto-wrapping
|
|
|
|
:::
|
|
|
|
## Spacer
|
|
|
|
Sometimes we want something more than blank space, so we have (spacer) to help us.
|
|
|
|
## Literal type spacer
|
|
|
|
:::demo
|
|
|
|
space/literal-type-spacer
|
|
|
|
:::
|
|
|
|
## Spacer can also be VNode
|
|
|
|
:::demo
|
|
|
|
space/vnode-type-spacer
|
|
|
|
:::
|
|
|
|
## Alignment
|
|
|
|
Setting this attribute can adjust the alignment of child nodes, the desirable value can be found at [align-items](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items).
|
|
|
|
:::demo Using `alignment`
|
|
|
|
space/alignment
|
|
|
|
:::
|
|
|
|
## Fill the container
|
|
|
|
Through the `fill` **(Boolean type)** parameter, you can control whether the child node automatically fills the container.
|
|
|
|
In the following example, when set to `fill`, the width of the child node will automatically adapt to the width of the container.
|
|
|
|
:::demo Use fill to automatically fill the container with child nodes
|
|
|
|
space/fill
|
|
|
|
:::
|
|
|
|
You can also use the `fillRatio` parameter to customize the filling ratio. The default value is `100`, which represents filling based on the width of the parent container at `100%`.
|
|
|
|
It should be noted that the expression of horizontal layout and vertical layout is slightly different, the specific effect can be viewed in the following example.
|
|
|
|
:::demo Use fillRatio to customize the fill ratio
|
|
|
|
space/fill-ratio
|
|
|
|
:::
|
|
|
|
## Space Attributes
|
|
|
|
| Attribute | Description | Type | Available value | Default |
|
|
| ---------- | ------------------------------- | ----------------------------------------- | --------------------------------------------------------------------------- | ---------- |
|
|
| alignment | Controls the alignment of items | string | [align-items](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) | 'center' |
|
|
| class | Classname | string / Array<Object \| String> / Object | - | - |
|
|
| direction | Placement direction | string | vertical/horizontal | horizontal |
|
|
| prefixCls | Prefix for space-items | string | el-space | - |
|
|
| style | Extra style rules | string / Array<Object \| String> / Object | - | - |
|
|
| spacer | Spacer | string / number / VNode | - | - |
|
|
| size | Spacing size | string / number / [number, number] | - | 'small' |
|
|
| wrap | Auto wrapping | boolean | true / false | false |
|
|
| fill | Whether to fill the container | boolean | true / false | false |
|
|
| fill-ratio | Ratio of fill | number | - | 100 |
|
|
|
|
## Space Slot
|
|
|
|
| name | description |
|
|
| ------- | ------------------ |
|
|
| default | Items to be spaced |
|