Grid 격자
Grid는 콘텐츠를 균등한 너비의 블록으로 나눠 페이지 내비게이션을 구성할 때 쓰는 컴포넌트예요.
출처: 문서
설치
Grid와 함께 GridItem도 앱에 등록해야 블록을 구성할 수 있어요.
import { createApp } from 'vue'
import { Grid, GridItem } from '@nutui/nutui'
const app = createApp()
app.use(Grid)
app.use(GridItem)
사용 예시
기본 사용법
demo: grid basic
컬럼 수
demo: grid column
정사각형
demo: grid square
간격(gutter)
demo: grid gutter
뒤집기
demo: grid reverse
가로 배치
demo: grid horizontal
콘텐츠 커스터마이즈
demo: grid content
API
Grid Props
| Attribute | Description | Type | 默认值 |
|---|---|---|---|
| column-num | Column Num | number | string | 4 |
| border | Whether to show border | boolean | true |
| gutter | Gutter,The default unit is px |
number | string | 0 |
| center | Whether to center content | boolean | true |
| square | Whether to be square shape | boolean | false |
| reverse | Whether to reverse the position of icon and text | boolean | false |
| direction | Content arrangement direction, can be set to horizontal |
string | vertical |
| clickable | Whether to show click feedback when clicked | boolean | false |
GridItem Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| text | text | string | - |
GridItem Slots
| Name | Description |
|---|---|
| default | Custom content |
| text | Custom text |
GridItem Events
| Event | Description | Arguments |
|---|---|---|
| click | Emitted when component is clicked | event: Event |
Types v4.3.6
이 컴포넌트는 아래 타입 정의를 함께 내보내요.
import type {
GridDirection,
GridProps,
GridInstance
} from '@nutui/nutui';
Theming
CSS Variables
스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.
| Name | Default Value |
|---|---|
| --nut-grid-border-color | #f5f6f7 |
| --nut-grid-item-content-padding | 16px 8px |
| --nut-grid-item-content-bg-color | var(--nut-white) |
| --nut-grid-item-text-margin | 8px |
| --nut-grid-item-text-color | var(--nut-title-color2) |
| --nut-grid-item-text-font-size | var(--nut-font-size-1) |
더 알아보기 (Learn more)
- 원문 문서: NutUI Grid 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.