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

이온 라벨 (ion-label)

원문 보기 위키 갱신

ion-label은 주로 Item 컴포넌트에 텍스트 콘텐츠를 추가하기 위해 사용하는 요소예요. 또한 Input이나 Radio 같은 폼 컨트롤 컴포넌트에서 보이는 라벨을 지정할 때도 쓸 수 있지만, 반드시 필요한 것은 아니에요. 아이템 안에서 라벨의 위치는 inline, fixed, stacked, floating 중 하나가 될 수 있어요.

출처: 문서

본문

Encapsulation: scoped

Label은 주로 Item 컴포넌트에 텍스트 콘텐츠를 추가하기 위해 사용하는 요소입니다. 또한 보이는 라벨을 지정할 때 Input이나 Radio 같은 폼 컨트롤 컴포넌트 내부에서도 사용할 수 있지만, 반드시 필요한 것은 아닙니다.

아이템 안에서 라벨의 위치는 inline, fixed, stacked, floating 중 하나가 될 수 있습니다.

기본 사용법 (Basic Usage)

JavaScript

<ion-label>Label</ion-label>

Angular

src/app/example.component.html

<ion-label>Label</ion-label>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonLabel } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonLabel],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonLabel } from '@ionic/react';

function Example() {
  return (
    <>
      <IonLabel>Label</IonLabel>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-label>Label</ion-label>
</template>

<script setup lang="ts">
  import { IonLabel } from '@ionic/vue';
</script>

Item Labels (아이템 라벨)

JavaScript

<ion-item>
  <ion-label>Default Label</ion-label>
</ion-item>

<ion-item>
  <ion-label>
    Multi-line text that should ellipsis when it is too long to fit on one line. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit.
  </ion-label>
</ion-item>

<ion-item>
  <ion-label class="ion-text-wrap">
    Multi-line text that should wrap when it is too long to fit on one line. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit.
  </ion-label>
</ion-item>

<ion-item>
  <ion-label>
    <h1>Heading</h1>
    <p>Paragraph</p>
  </ion-label>
</ion-item>

Angular

src/app/example.component.html

<ion-item>
  <ion-label>Default Label</ion-label>
</ion-item>

<ion-item>
  <ion-label>
    Multi-line text that should ellipsis when it is too long to fit on one line. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit.
  </ion-label>
</ion-item>

<ion-item>
  <ion-label class="ion-text-wrap">
    Multi-line text that should wrap when it is too long to fit on one line. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit.
  </ion-label>
</ion-item>

<ion-item>
  <ion-label>
    <h1>Heading</h1>
    <p>Paragraph</p>
  </ion-label>
</ion-item>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonItem, IonLabel } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonItem, IonLabel],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonItem, IonLabel } from '@ionic/react';

function Example() {
  return (
    <>
      <IonItem>
        <IonLabel>Default Label</IonLabel>
      </IonItem>

      <IonItem>
        <IonLabel>
          Multi-line text that should ellipsis when it is too long to fit on one line. Lorem ipsum dolor sit amet,
          consectetur adipiscing elit.
        </IonLabel>
      </IonItem>

      <IonItem>
        <IonLabel class="ion-text-wrap">
          Multi-line text that should wrap when it is too long to fit on one line. Lorem ipsum dolor sit amet,
          consectetur adipiscing elit.
        </IonLabel>
      </IonItem>

      <IonItem>
        <IonLabel>
          <h1>Heading</h1>
          <p>Paragraph</p>
        </IonLabel>
      </IonItem>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-item>
    <ion-label>Default Label</ion-label>
  </ion-item>

  <ion-item>
    <ion-label>
      Multi-line text that should ellipsis when it is too long to fit on one line. Lorem ipsum dolor sit amet,
      consectetur adipiscing elit.
    </ion-label>
  </ion-item>

  <ion-item>
    <ion-label class="ion-text-wrap">
      Multi-line text that should wrap when it is too long to fit on one line. Lorem ipsum dolor sit amet, consectetur
      adipiscing elit.
    </ion-label>
  </ion-item>

  <ion-item>
    <ion-label>
      <h1>Heading</h1>
      <p>Paragraph</p>
    </ion-label>
  </ion-item>
</template>

<script setup lang="ts">
  import { IonItem, IonLabel } from '@ionic/vue';
</script>

Theming (테마 적용)

Colors (색상)

JavaScript

<ion-label>Default</ion-label>
<ion-label color="primary">Primary</ion-label>
<ion-label color="secondary">Secondary</ion-label>
<ion-label color="tertiary">Tertiary</ion-label>
<ion-label color="success">Success</ion-label>
<ion-label color="warning">Warning</ion-label>
<ion-label color="danger">Danger</ion-label>
<ion-label color="light">Light</ion-label>
<ion-label color="medium">Medium</ion-label>
<ion-label color="dark">Dark</ion-label>

Angular

src/app/example.component.html

<ion-label>Default</ion-label>
<ion-label color="primary">Primary</ion-label>
<ion-label color="secondary">Secondary</ion-label>
<ion-label color="tertiary">Tertiary</ion-label>
<ion-label color="success">Success</ion-label>
<ion-label color="warning">Warning</ion-label>
<ion-label color="danger">Danger</ion-label>
<ion-label color="light">Light</ion-label>
<ion-label color="medium">Medium</ion-label>
<ion-label color="dark">Dark</ion-label>

src/app/example.component.ts

import { Component } from '@angular/core';
import { IonLabel } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonLabel],
})
export class ExampleComponent {}

React

import React from 'react';
import { IonLabel } from '@ionic/react';

function Example() {
  return (
    <>
      <IonLabel>Default</IonLabel>
      <IonLabel color="primary">Primary</IonLabel>
      <IonLabel color="secondary">Secondary</IonLabel>
      <IonLabel color="tertiary">Tertiary</IonLabel>
      <IonLabel color="success">Success</IonLabel>
      <IonLabel color="warning">Warning</IonLabel>
      <IonLabel color="danger">Danger</IonLabel>
      <IonLabel color="light">Light</IonLabel>
      <IonLabel color="medium">Medium</IonLabel>
      <IonLabel color="dark">Dark</IonLabel>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-label>Default</ion-label>
  <ion-label color="primary">Primary</ion-label>
  <ion-label color="secondary">Secondary</ion-label>
  <ion-label color="tertiary">Tertiary</ion-label>
  <ion-label color="success">Success</ion-label>
  <ion-label color="warning">Warning</ion-label>
  <ion-label color="danger">Danger</ion-label>
  <ion-label color="light">Light</ion-label>
  <ion-label color="medium">Medium</ion-label>
  <ion-label color="dark">Dark</ion-label>
</template>

<script setup lang="ts">
  import { IonLabel } from '@ionic/vue';
</script>

Properties (속성)

color

설명 (Description): 애플리케이션의 색상 팔레트에서 사용할 색상입니다. 기본 옵션은 "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", "dark"입니다. 색상에 대한 더 자세한 내용은 theming을 참고하세요.

Attribute: color

Type: "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined

Default: undefined

mode

설명 (Description): mode는 어떤 플랫폼 스타일을 사용할지 결정합니다. 이는 초기화 중에 한 번 설정되며, 초기 렌더링 이후 값을 변경해도 업데이트되지 않는 virtual property입니다.

Attribute: mode

Type: "ios" | "md"

Default: undefined

position

설명 (Description): position은 아이템 안에서 라벨이 어디에, 어떻게 배치되는지를 결정합니다.

Attribute: position

Type: "fixed" | "floating" | "stacked" | undefined

Default: undefined

Events (이벤트)

이 컴포넌트에서 사용할 수 있는 이벤트는 없습니다.

Methods (메서드)

이 컴포넌트에서 사용할 수 있는 public 메서드는 없습니다.

CSS Shadow Parts

이 컴포넌트에서 사용할 수 있는 CSS shadow part는 없습니다.

CSS Custom Properties (CSS 사용자 정의 속성)

iOS

Name Description
--color 라벨의 색상입니다. 이 속성은 ion-label을 ion-item 안에서 사용할 때만 사용할 수 있습니다.

MD

Name Description
--color 라벨의 색상입니다. 이 속성은 ion-label을 ion-item 안에서 사용할 때만 사용할 수 있습니다.

Slots (슬롯)

Name Description
기본 슬롯(default slot)입니다

더 알아보기 (Learn more)

ion-label은 아이템의 텍스트와 폼 요소의 보이는 라벨을 담당하는 기초 컴포넌트예요. position 속성으로 inline·floating·stacked 등 다양한 라벨 배치를 구현할 수 있으니, item 문서와 함께 살펴보면 실제 렌더링 감각을 잡기 좋아요.