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

ion-tab-button

원문 보기 위키 갱신

tab bar 안에 배치되는 UI 컴포넌트인 ion-tab-button이에요. 아이콘과 라벨의 배치를 지정하고 tab view에 연결할 수 있어요. 탭 구성에 대한 자세한 내용은 tabs documentation을 참고해 주세요.

출처: 문서

본문

Encapsulation: shadow

Tab button은 tab bar 안에 배치되는 UI 컴포넌트예요. tab button은 아이콘과 라벨의 배치를 지정할 수 있고 tab view에 연결할 수 있어요.

탭 구성에 대한 자세한 내용은 tabs documentation을 참고해 주세요.

Usage

Angular

<ion-tabs>
  <!-- Tab bar -->
  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="schedule">
      <ion-icon name="calendar" aria-hidden="true"></ion-icon>
      <ion-label>Schedule</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="speakers">
      <ion-icon name="person-circle" aria-hidden="true"></ion-icon>
      <ion-label>Speakers</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="map">
      <ion-icon name="map" aria-hidden="true"></ion-icon>
      <ion-label>Map</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="about">
      <ion-icon name="information-circle" aria-hidden="true"></ion-icon>
      <ion-label>About</ion-label>
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

Javascript

<ion-tabs>
  <!-- Tab views -->
  <ion-tab tab="schedule">
    <ion-router-outlet name="schedule"></ion-router-outlet>
  </ion-tab>

  <ion-tab tab="speakers">
    <ion-router-outlet name="speakers"></ion-router-outlet>
  </ion-tab>

  <ion-tab tab="map">
    <ion-router-outlet name="map"></ion-router-outlet>
  </ion-tab>

  <ion-tab tab="about">
    <ion-router-outlet name="about"></ion-router-outlet>
  </ion-tab>

  <!-- Tab bar -->
  <ion-tab-bar slot="bottom">
    <ion-tab-button tab="schedule" href="/app/tabs/(schedule:schedule)">
      <ion-icon name="calendar" aria-hidden="true"></ion-icon>
      <ion-label>Schedule</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="speakers" href="/app/tabs/(speakers:speakers)">
      <ion-icon name="person-circle" aria-hidden="true"></ion-icon>
      <ion-label>Speakers</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="map" href="/app/tabs/(map:map)">
      <ion-icon name="map" aria-hidden="true"></ion-icon>
      <ion-label>Map</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="about" href="/app/tabs/(about:about)">
      <ion-icon name="information-circle" aria-hidden="true"></ion-icon>
      <ion-label>About</ion-label>
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

React

import React from 'react';
import { IonTabs, IonTabBar, IonTabButton, IonIcon, IonLabel, IonContent } from '@ionic/react';
import { calendar, personCircle, map, informationCircle } from 'ionicons/icons';

export const TabButtonExample: React.FC = () => (
  <IonContent>
    <IonTabs>
      {/*-- Tab bar --*/}
      <IonTabBar slot="bottom">
        <IonTabButton tab="schedule">
          <IonIcon icon={calendar} aria-hidden="true" />
          <IonLabel>Schedule</IonLabel>
        </IonTabButton>

        <IonTabButton tab="speakers">
          <IonIcon icon={personCircle} aria-hidden="true" />
          <IonLabel>Speakers</IonLabel>
        </IonTabButton>

        <IonTabButton tab="map">
          <IonIcon icon={map} aria-hidden="true" />
          <IonLabel>Map</IonLabel>
        </IonTabButton>

        <IonTabButton tab="about">
          <IonIcon icon={informationCircle} aria-hidden="true" />
          <IonLabel>About</IonLabel>
        </IonTabButton>
      </IonTabBar>
    </IonTabs>
  </IonContent>
);

Vue

<template>
  <ion-tabs>
    <!-- Tab bar -->
    <ion-tab-bar slot="bottom">
      <ion-tab-button tab="schedule" href="/tabs/schedule">
        <ion-icon :icon="calendar" aria-hidden="true"></ion-icon>
        <ion-label>Schedule</ion-label>
      </ion-tab-button>

      <ion-tab-button tab="speakers" href="/tabs/speakers">
        <ion-icon :icon="personCircle" aria-hidden="true"></ion-icon>
        <ion-label>Speakers</ion-label>
      </ion-tab-button>

      <ion-tab-button tab="map" href="/tabs/map">
        <ion-icon :icon="map" aria-hidden="true"></ion-icon>
        <ion-label>Map</ion-label>
      </ion-tab-button>

      <ion-tab-button tab="about" href="/tabs/about">
        <ion-icon :icon="informationCircle" aria-hidden="true"></ion-icon>
        <ion-label>About</ion-label>
      </ion-tab-button>
    </ion-tab-bar>
  </ion-tabs>
</template>

<script setup lang="ts">
  import { IonIcon, IonLabel, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
  import { calendar, informationCircle, map, personCircle } from 'ionicons/icons';
</script>

Properties

disabled

Description: true로 설정하면 사용자가 tab button과 상호작용할 수 없어요.

Attribute: disabled

Type: boolean

Default: false

download

Description: 이 속성은 브라우저가 URL로 이동하는 대신 다운로드하도록 지시해서, 사용자가 로컬 파일로 저장하라는 메시지를 받게 해요. 속성에 값이 있으면 저장 메시지에서 미리 채워진 파일 이름으로 사용돼요(사용자가 원하면 파일 이름을 바꿀 수 있어요).

Attribute: download

Type: string | undefined

Default: undefined

href

Description: 하이퍼링크가 가리키는 URL 또는 URL 프래그먼트예요. 이 프로퍼티를 설정하면 앵커 태그가 렌더링돼요.

Attribute: href

Type: string | undefined

Default: undefined

layout

Description: tab bar 안의 텍스트와 아이콘의 배치를 설정해요. 기본값은 "icon-top"이에요.

Attribute: layout

Type: "icon-bottom" | "icon-end" | "icon-hide" | "icon-start" | "icon-top" | "label-hide" | undefined

Default: undefined

mode

Description: mode는 어떤 플랫폼 스타일을 사용할지 결정해요. 이 값은 초기화할 때 한 번 설정되는 virtual property라서, 첫 렌더링 이후에 값을 바꿔도 업데이트되지 않아요.

Attribute: mode

Type: "ios" | "md"

Default: undefined

rel

Description: 대상 객체와 링크 객체 사이의 관계를 지정해요. 값은 link types의 공백으로 구분된 목록이에요.

Attribute: rel

Type: string | undefined

Default: undefined

selected

Description: 선택된 탭 컴포넌트예요.

Attribute: selected

Type: boolean

Default: false

tab

Description: 각 ion-tab에는 탭 id를 제공해야 해요. 이 id는 선택된 탭을 참조하거나 라우터가 탭 사이를 전환하는 데 내부적으로 사용돼요.

Attribute: tab

Type: string | undefined

Default: undefined

target

Description: 링크된 URL을 어디에 표시할지 지정해요. href가 제공될 때만 적용돼요. 특별 키워드: "_blank", "_self", "_parent", "_top".

Attribute: target

Type: string | undefined

Default: undefined

Events

이 컴포넌트에는 사용할 수 있는 이벤트가 없어요.

Methods

이 컴포넌트에는 공개된 메서드가 없어요.

CSS Shadow Parts

Name Description
native 모든 자식 요소를 감싸는 기본 HTML anchor 요소예요.

CSS Custom Properties

iOS

Name Description
--background tab button의 배경색
--background-focused Tab 키로 포커스됐을 때 tab button의 배경색
--background-focused-opacity Tab 키로 포커스됐을 때 tab button 배경의 불투명도
--color tab button의 색상
--color-focused Tab 키로 포커스됐을 때 tab button의 색상
--color-selected 선택된 tab button의 색상
--padding-bottom tab button의 아래쪽 안쪽 여백
--padding-end 왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 안쪽 여백
--padding-start 왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 안쪽 여백
--padding-top tab button의 위쪽 안쪽 여백
--ripple-color 버튼 리플(ripple) 효과의 색상

MD

Name Description
--background tab button의 배경색
--background-focused Tab 키로 포커스됐을 때 tab button의 배경색
--background-focused-opacity Tab 키로 포커스됐을 때 tab button 배경의 불투명도
--color tab button의 색상
--color-focused Tab 키로 포커스됐을 때 tab button의 색상
--color-selected 선택된 tab button의 색상
--padding-bottom tab button의 아래쪽 안쪽 여백
--padding-end 왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 안쪽 여백
--padding-start 왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 안쪽 여백
--padding-top tab button의 위쪽 안쪽 여백
--ripple-color 버튼 리플(ripple) 효과의 색상

Slots

Name Description
기본 슬롯이에요.

더 알아보기 (Learn more)

tab button은 각 탭을 사용자가 누르는 진입점이에요. tab 프로퍼티로 tab view와 연결하고, layout과 색상 프로퍼티로 모양을 다듬을 수 있어요. 탭을 완전히 이해하려면 tabs 문서를 함께 보는 걸 추천해요.