본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Tabs

원문 보기 위키 갱신

Tabs (탭)

레벨 영역 안에서 큰 덩어리의 콘텐츠를 나눠 담고 보여 주는 데 자주 쓰이는 컴포넌트예요. 태그를 중첩하는 형태와 데이터를 루프로 렌더링하는 형태를 모두 지원해요.

출처: 문서

본문

소개 (Intro)

레벨 영역에 큰 덩어리의 콘텐츠를 저장하고 표시하는 데 자주 사용되고, 태그 중첩 형태와 루프 데이터 렌더링을 지원해요.

설치 (Install)

import { createApp } from 'vue'
import { Tabs, TabPane } from '@nutui/nutui'

const app = createApp()
app.use(Tabs)
app.use(TabPane)

데모 (Demos)

아래 항목들은 원문 문서의 대화형 데모로 제공돼요.

  • 기본 사용법 (Basic Usage) — demo: tabs basic
  • 스마일 타입 (Smile Type) — demo: tabs smile
  • 애니메이션 없이 (Without Animation) — demo: tabs animated-time
  • 제목 왼쪽 정렬 (Title Align to Left) v4.2.7 — demo: tabs left-align
  • 자동 높이 (Auto Height) — demo: tabs auto-height
  • 스와이프 (Swipeable) — demo: tabs swipeable
  • 제목 스크롤 (가로, Title Scroll horizontal) — demo: tabs scroll
  • 제목 스크롤 (세로, Title Scroll vertical) — demo: tabs vertical
  • 세로 + 스마일 타입 (vertical + Smile Type) — demo: tabs vertical-smile
  • 폰트 크기 (FontSize) — demo: tabs size
  • 커스텀 탭 (Custom Tab) — demo: tabs custom

애니메이션 없이 (Without Animation)

Tabs는 기본적으로 Transform 레이아웃으로 전환 애니메이션을 구현해요. 그런데 내부에 Popup이나 Menu처럼 Fixed 포지셔닝을 쓰는 다른 컴포넌트가 들어가면 스타일이 서로 간섭할 수 있어요.

이럴 땐 animated-time을 0으로 설정하세요. 그러면 전환 애니메이션이 사라지고 패널 전환이 더 매끄러워져요.

API

Tabs Props

Attribute Description Type Default
v-model Index of active tab number | string 0
color Label selection color string #1a1a1a
background Tab bar background color string #f5f5f5
direction Use landscape orientation optional value horizontal、vertical string horizontal
type Check the bottom display style optional value line、smile string line
swipeable4.0.3 Whether to enable gestures to slide left and right boolean false
title-scroll Is the tab bar scrollable boolean false
ellipsis Whether to omit too long title text boolean true
animated-time Switch animation duration, unit ms 0 means no animation and pane-key is required number | string 300
title-gutter Label gap number | string 0
size Tab bar font size optional value large normal small string normal
auto-height Automatic height. When set to true, nut-tabs and nut-tabs__content will change with the height of the current nut-tab-pane. boolean false
sticky Whether to use sticky mode boolean false
top Sticky offset top number 0
align v4.2.7 Title alignment in the horizontal axis direction, optional values left center string center

Tabs Slots

Name Description
titles Custom Titles Area
default Custom Default Content

TabPane Props

Attribute Description Type Default
title title string
pane-key Tag Key , the matching identifier string 默认索引 0,1,2...
disabled whether to disable tabs boolean false

TabPane Slots

Name Description
default Custom Default Content

Tabs Events

Event Description Arguments
click Triggered when the label is clicked {title,paneKey,disabled}
change Fired when the currently active tab changes {title,paneKey,disabled}

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

Name Default Value
--nut-tabs-tab-smile-color var(--nut-primary-color)
--nut-tabs-titles-border-radius 0
--nut-tabs-titles-item-large-font-size var(--nut-font-size-3)
--nut-tabs-titles-item-font-size var(--nut-font-size-2)
--nut-tabs-titles-item-small-font-size var(--nut-font-size-1)
--nut-tabs-titles-item-color var(--nut-title-color)
--nut-tabs-titles-item-active-color var(--nut-title-color)
--nut-tabs-titles-background-color var(--nut-help-color)
--nut-tabs-horizontal-tab-line-color linear-gradient(90deg,var(--nut-primary-color) 0%,rgba(#fa2c19, 0.15) 100%)
--nut-tabs-horizontal-titles-height 46px
--nut-tabs-horizontal-titles-item-min-width 50px
--nut-tabs-horizontal-titles-item-active-line-width 40px
--nut-tabs-vertical-tab-line-color linear-gradient(180deg,var(--nut-primary-color) 0%,rgba(#fa2c19, 0.15) 100%)
--nut-tabs-vertical-titles-item-height 40px
--nut-tabs-vertical-titles-item-active-line-height 14px
--nut-tabs-vertical-titles-width 100px
--nut-tabs-titles-item-line-border-radius 0
--nut-tabs-titles-item-line-opacity 1

더 알아보기 (Learn more)