Space 간격
Space는 요소 사이의 간격을 잡아주는 컴포넌트예요. NutUI 4.2.0 이상에서 쓸 수 있어요.
출처: 문서
본문
설치
@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.
import { createApp } from 'vue'
import { Space } from '@nutui/nutui'
const app = createApp()
app.use(Space)
사용 예시
기본 사용법
Space 컴포넌트는 하위 컴포넌트 사이에 일정 간격을 만들어 줘요. 기본 간격은 8px예요.
demo: space basic
:::
방향 커스터마이즈
direction 속성을 vertical로 설정하면 세로 방향 간격을 잡을 수 있어요.
demo: space direction
간격(gutter) 커스터마이즈
gutter 값으로 간격 크기를 조절해요. 숫자를 넘기면 기본 단위로 px를 쓰고, 문자열로 2rem이나 5vw처럼 단위가 붙은 값도 넘길 수 있어요.
CSS 변수 -nut-space-gap으로도 설정할 수 있는데, 우선순위는 속성 > CSS 변수 > 기본 스타일 순이에요.
demo: space gutter
줄바꿈
가로 모드에서는 wrap 속성이 하위 요소를 자동으로 줄바꿈할지 결정해요.
demo: space wrap
API
Props
| Property | Description | Type | Default |
|---|---|---|---|
| direction | Spacing direction, vertical horizontal |
string | horizontal |
| align | Cross axis alignment, start end center baseline |
string | - |
| justify | Spindle alignment, start end center between around evenly stretch |
string | - |
| wrap | Whether to wrap lines automatically. This parameter is valid only when horizontal | boolean | false |
| fill | Whether to make Space a block-level element and fill the entire parent element | boolean | false |
| gutter | Spacing size, such as 20px 2em, the default unit is px, and supports array form to set horizontal and vertical spacing respectively | number | string | number[] | string[] | - |
Slots
| Name | Description |
|---|---|
| default | Default slot |
Theming
CSS Variables
스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.
| Name | Default | Description |
|---|---|---|
| --nut-space-gap | 8px |
Spacing size |
더 알아보기 (Learn more)
- 원문 문서: NutUI Space 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.