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

탭 패널 (Tab Panel)

원문 보기 위키 갱신

SlTabPanel은 탭 그룹(tab group) 안에서 탭 형식의 콘텐츠를 표시할 때 사용되는 요소예요. 아래 예시처럼 탭 그룹 안에 탭과 탭 패널을 함께 배치하면 됩니다.

출처: 문서

본문

<sl-tab-group>
  <sl-tab slot="nav" panel="general">General</sl-tab>
  <sl-tab slot="nav" panel="custom">Custom</sl-tab>
  <sl-tab slot="nav" panel="advanced">Advanced</sl-tab>
  <sl-tab slot="nav" panel="disabled" disabled>Disabled</sl-tab>
  <sl-tab-panel name="general">This is the general tab panel.</sl-tab-panel>
  <sl-tab-panel name="custom">This is the custom tab panel.</sl-tab-panel>
  <sl-tab-panel name="advanced">This is the advanced tab panel.</sl-tab-panel>
  <sl-tab-panel name="disabled">This is a disabled tab panel.</sl-tab-panel>
</sl-tab-group>

React에서는 이렇게 사용할 수 있어요.

import SlTab from '@shoelace-style/shoelace/dist/react/tab';
import SlTabGroup from '@shoelace-style/shoelace/dist/react/tab-group';
import SlTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';
const App = () => (
  <SlTabGroup>
    <SlTab slot="nav" panel="general">
      General
    </SlTab>
    <SlTab slot="nav" panel="custom">
      Custom
    </SlTab>
    <SlTab slot="nav" panel="advanced">
      Advanced
    </SlTab>
    <SlTab slot="nav" panel="disabled" disabled>
      Disabled
    </SlTab>
    <SlTabPanel name="general">This is the general tab panel.</SlTabPanel>
    <SlTabPanel name="custom">This is the custom tab panel.</SlTabPanel>
    <SlTabPanel name="advanced">This is the advanced tab panel.</SlTabPanel>
    <SlTabPanel name="disabled">This is a disabled tab panel.</SlTabPanel>
  </SlTabGroup>
);

더 다양한 데모는 탭 그룹 예시에서 확인할 수 있습니다.

불러오기 (Importing)

autoloader나 전통적인 loader를 사용 중이라면 이 부분은 무시해도 돼요. 그게 아니라면 아래 스니펫 중 원하는 방식으로 이 컴포넌트만 골라서 불러올 수 있어요.

Script 태그로 CDN에서 이 컴포넌트를 불러오려면:

<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.20.1/cdn/components/tab-panel/tab-panel.js"></script>

JavaScript import 구문으로 CDN에서 불러오려면:

import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.20.1/cdn/components/tab-panel/tab-panel.js';

번들러(bundler)를 사용해 불러오려면:

import '@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js';

React 컴포넌트로 불러오려면:

import SlTabPanel from '@shoelace-style/shoelace/dist/react/tab-panel';

슬롯 (Slots)

Name Description
(default) The tab panel’s content.

슬롯 사용법에 대해 더 알아보기.

속성 (Properties)

Name Description Reflects Type Default
name The tab panel’s name. string ''
active When true, the tab panel will be shown. boolean false
updateComplete A read-only promise that resolves when the component has finished updating.

속성(attribute)과 프로퍼티(property)에 대해 더 알아보기.

커스텀 프로퍼티 (Custom Properties)

Name Description Default
--padding The tab panel’s padding.

CSS 커스텀 프로퍼티 커스터마이징에 대해 더 알아보기.

파트 (Parts)

Name Description
base The component’s base wrapper.

CSS 파트 커스터마이징에 대해 더 알아보기.

더 알아보기 (Learn more)