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

ion-checkbox

원문 보기 위키 갱신

체크박스는 여러 옵션 중 다중 선택을 가능하게 해 주는 컴포넌트예요. 활성화되면 체크(✓) 표시가 나타나고, 클릭하면 checked 프로퍼티가 토글됩니다. checked 프로퍼티를 설정해 프로그래밍 방식으로도 체크 상태를 바꿀 수 있어요.

출처: 문서

본문

체크박스는 옵션 집합에서 여러 항목을 선택할 수 있게 해 줍니다. 활성화되면 체크된(✓) 상태로 표시되고, 체크박스를 클릭하면 checked 프로퍼티가 토글돼요. checked 프로퍼티를 직접 설정해 프로그래밍 방식으로도 체크할 수 있습니다.

기본 사용법 (Basic Usage)

JavaScript

<ion-checkbox>I agree to the terms and conditions</ion-checkbox>

Angular

src/app/example.component.html

<ion-checkbox>I agree to the terms and conditions</ion-checkbox>

src/app/example.component.ts

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

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

React

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

function Example() {
  return <IonCheckbox>I agree to the terms and conditions</IonCheckbox>;
}
export default Example;

Vue

<template>
  <ion-checkbox>I agree to the terms and conditions</ion-checkbox>
</template>

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

라벨 배치 (Label Placement)

개발자는 labelPlacement 프로퍼티를 사용해 라벨이 컨트롤에 대해 어디에 배치될지 조절할 수 있어요. 이 프로퍼티는 flexbox의 flex-direction 프로퍼티를 그대로 반영합니다.

JavaScript

<ion-checkbox label-placement="start">Label at the Start</ion-checkbox>

<br />

<ion-checkbox label-placement="end">Label at the End</ion-checkbox>

<br />

<ion-checkbox label-placement="fixed">Fixed Width Label</ion-checkbox>

<br />

<ion-checkbox label-placement="stacked">Stacked Label</ion-checkbox>

Angular

src/app/example.component.html

<ion-checkbox labelPlacement="start">Label at the Start</ion-checkbox>

<br />

<ion-checkbox labelPlacement="end">Label at the End</ion-checkbox>

<br />

<ion-checkbox labelPlacement="fixed">Fixed Width Label</ion-checkbox>

<br />

<ion-checkbox labelPlacement="stacked">Stacked Label</ion-checkbox>

src/app/example.component.ts

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

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

React

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

function Example() {
  return (
    <>
      <IonCheckbox labelPlacement="start">Label at the Start</IonCheckbox>

      <br />

      <IonCheckbox labelPlacement="end">Label at the End</IonCheckbox>

      <br />

      <IonCheckbox labelPlacement="fixed">Fixed Width Label</IonCheckbox>

      <br />

      <IonCheckbox labelPlacement="stacked">Stacked Label</IonCheckbox>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-checkbox label-placement="start">Label at the Start</ion-checkbox>

  <br />

  <ion-checkbox label-placement="end">Label at the End</ion-checkbox>

  <br />

  <ion-checkbox label-placement="fixed">Fixed Width Label</ion-checkbox>

  <br />

  <ion-checkbox label-placement="stacked">Stacked Label</ion-checkbox>
</template>

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

정렬 (Alignment)

개발자는 alignment 프로퍼티를 사용해 라벨과 컨트롤이 크로스 축(cross axis)에서 어떻게 정렬될지 조절할 수 있어요. 이 프로퍼티는 flexbox의 align-items 프로퍼티를 그대로 반영합니다.

참고 (Note)

스택된(stacked) 체크박스는 alignment 프로퍼티로 정렬할 수 있어요. 이는 라벨과 컨트롤을 가로 방향으로 중앙 정렬해야 할 때 유용합니다.

JavaScript

<ion-list>
  <ion-item>
    <ion-checkbox label-placement="stacked" alignment="start">Aligned to the Start</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox label-placement="stacked" alignment="center">Aligned to the Center</ion-checkbox>
  </ion-item>
</ion-list>

Angular

src/app/example.component.html

<ion-list>
  <ion-item>
    <ion-checkbox label-placement="stacked" alignment="start">Aligned to the Start</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox label-placement="stacked" alignment="center">Aligned to the Center</ion-checkbox>
  </ion-item>
</ion-list>

src/app/example.component.ts

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

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

React

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

function Example() {
  return (
    <>
      <IonList>
        <IonItem>
          <IonCheckbox labelPlacement="stacked" alignment="start">
            Aligned to the Start
          </IonCheckbox>
        </IonItem>

        <IonItem>
          <IonCheckbox labelPlacement="stacked" alignment="center">
            Aligned to the Center
          </IonCheckbox>
        </IonItem>
      </IonList>
    </>
  );
}
export default Example;

Vue

<template>
  <ion-list>
    <ion-item>
      <ion-checkbox label-placement="stacked" alignment="start">Aligned to the Start</ion-checkbox>
    </ion-item>

    <ion-item>
      <ion-checkbox label-placement="stacked" alignment="center">Aligned to the Center</ion-checkbox>
    </ion-item>
  </ion-list>
</template>

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

배치 (Justification)

개발자는 justify 프로퍼티를 사용해 라벨과 컨트롤이 한 줄에서 어떻게 배치될지 조절할 수 있어요. 이 프로퍼티는 flexbox의 justify-content 프로퍼티를 그대로 반영합니다.

JavaScript

<ion-list>
  <ion-item>
    <ion-checkbox justify="start">Packed at the Start of Line</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox justify="end">Packed at the End of Line</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox justify="space-between">Space Between Label and Control</ion-checkbox>
  </ion-item>
</ion-list>

Angular

src/app/example.component.html

<ion-list>
  <ion-item>
    <ion-checkbox justify="start">Packed at the Start of Line</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox justify="end">Packed at the End of Line</ion-checkbox>
  </ion-item>

  <ion-item>
    <ion-checkbox justify="space-between">Space Between Label and Control</ion-checkbox>
  </ion-item>
</ion-list>

src/app/example.component.ts

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

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

React

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

function Example() {
  return (
    <IonList>
      <IonItem>
        <IonCheckbox justify="start">Packed at the Start of Line</IonCheckbox>
      </IonItem>

      <IonItem>
        <IonCheckbox justify="end">Packed at the End of Line</IonCheckbox>
      </IonItem>

      <IonItem>
        <IonCheckbox justify="space-between">Space Between Label and Control</IonCheckbox>
      </IonItem>
    </IonList>
  );
}
export default Example;

Vue

<template>
  <ion-list>
    <ion-item>
      <ion-checkbox justify="start">Packed at the Start of Line</ion-checkbox>
    </ion-item>

    <ion-item>
      <ion-checkbox justify="end">Packed at the End of Line</ion-checkbox>
    </ion-item>

    <ion-item>
      <ion-checkbox justify="space-between">Space Between Label and Control</ion-checkbox>
    </ion-item>
  </ion-list>
</template>

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

참고 (Note)

ion-item은 데모에서 justify가 어떻게 동작하는지 강조하기 위해 사용된 것뿐입니다. justify가 올바르게 동작하는 데 꼭 필요한 것은 아니에요.

비결정(indeterminate) 체크박스

JavaScript

<ion-checkbox indeterminate="true">Indeterminate checkbox</ion-checkbox>

Angular

src/app/example.component.html

<ion-checkbox [indeterminate]="true">Indeterminate checkbox</ion-checkbox>

src/app/example.component.ts

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

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

React

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

function Example() {
  return <IonCheckbox indeterminate={true}>Indeterminate checkbox</IonCheckbox>;
}
export default Example;

Vue

<template>
  <ion-checkbox :indeterminate="true">Indeterminate checkbox</ion-checkbox>
</template>

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

체크박스 라벨에는 가끔 링크가 함께 붙기도 해요. 이 링크들은 체크박스와 관련된 추가 정보를 제공할 수 있습니다. 하지만 링크를 클릭해도 체크박스가 선택되면 안 되겠죠. 이를 위해 stopPropagation을 사용해 클릭 이벤트가 버블링되는 것을 막을 수 있어요. 이 방식을 사용하면 라벨의 나머지 부분은 여전히 클릭 가능합니다.

JavaScript

<ion-checkbox>I agree to the <a href="#" onclick="event.stopPropagation()">terms and conditions</a></ion-checkbox>

Angular

src/app/example.component.html

<ion-checkbox>I agree to the <a href="#" (click)="$event.stopPropagation()">terms and conditions</a></ion-checkbox>

src/app/example.component.ts

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

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

React

import React, { useEffect, useRef } from 'react';
import { IonCheckbox } from '@ionic/react';

function Example() {
  const ref = useRef<HTMLAnchorElement>(null);

  /**
   * IonCheckbox will be listening for the native click event here so we need
   * to call stopPropagation when the native click event instead of when the
   * synthetic click event fires.
   */
  useEffect(() => {
    ref.current?.addEventListener('click', (event) => {
      event.stopPropagation();
    });
  }, [ref]);

  return (
    <IonCheckbox>
      I agree to the{' '}
      <a href="#" ref={ref}>
        terms and conditions
      </a>
    </IonCheckbox>
  );
}
export default Example;

Vue

<template>
  <ion-checkbox>I agree to the <a href="#" @click="$event.stopPropagation()">terms and conditions</a></ion-checkbox>
</template>

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

도움말 및 오류 텍스트 (Helper & Error Text)

도움말과 오류 텍스트는 helperText와 errorText 프로퍼티로 체크박스 안에 사용할 수 있어요. 오류 텍스트는 ion-invalid와 ion-touched 클래스가 ion-checkbox에 추가되지 않는 한 표시되지 않습니다. 이는 사용자가 데이터를 입력할 기회를 갖기 전에 오류가 표시되지 않도록 보장해 줍니다.

Angular에서는 폼 검증을 통해 이 작업이 자동으로 이루어집니다. JavaScript, React, Vue에서는 자신의 검증 로직에 따라 클래스를 수동으로 추가해야 해요.

JavaScript

<form id="my-form">
  <ion-checkbox helper-text="Agree to the terms before continuing" error-text="You must agree to the terms to continue">
    I agree to the terms and conditions
  </ion-checkbox>

  <br />

  <ion-button type="submit" size="small">Submit</ion-button>
</form>

<script>
  const form = document.getElementById('my-form');
  const agree = form.querySelector('ion-checkbox');

  form.addEventListener('submit', (event) => submit(event));
  agree.addEventListener('ionChange', (event) => validateCheckbox(event));

  const validateCheckbox = (event) => {
    agree.classList.add('ion-touched');

    if (!event.detail.checked) {
      agree.classList.add('ion-invalid');
      agree.classList.remove('ion-valid');
    } else {
      agree.classList.remove('ion-invalid');
      agree.classList.add('ion-valid');
    }
  };

  const submit = (event) => {
    event.preventDefault();

    validateCheckbox({ detail: { checked: agree.checked } });
  };
</script>

Angular

src/app/example.component.html

<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
  <ion-checkbox
    formControlName="agree"
    helperText="Agree to the terms before continuing"
    errorText="You must agree to the terms to continue"
  >
    I agree to the terms and conditions
  </ion-checkbox>

  <br />

  <ion-button type="submit" size="small">Submit</ion-button>
</form>

src/app/example.component.ts

import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
import { IonCheckbox, IonButton } from '@ionic/angular';

@Component({
  selector: 'app-example',
  imports: [IonCheckbox, IonButton, ReactiveFormsModule],
  templateUrl: './example.component.html',
  styleUrl: './example.component.css',
})
export class ExampleComponent {
  myForm: FormGroup;

  constructor(private fb: FormBuilder) {
    this.myForm = this.fb.group({
      agree: [false, Validators.requiredTrue],
    });
  }

  onSubmit() {
    // Mark the control as touched to trigger the error message.
    // This is needed if the user submits the form without interacting
    // with the checkbox.
    this.myForm.get('agree')!.markAsTouched();
  }
}

React

import React, { useRef, useState } from 'react';
import { IonCheckbox, IonButton, CheckboxCustomEvent } from '@ionic/react';

function Example() {
  const [isTouched, setIsTouched] = useState<boolean>(false);
  const [isValid, setIsValid] = useState<boolean | undefined>();

  const agreeRef = useRef<HTMLIonCheckboxElement>(null);

  const validateCheckbox = (event: CheckboxCustomEvent<{ checked: boolean }>) => {
    setIsTouched(true);
    setIsValid(event.detail.checked);
  };

  const submit = (event: React.FormEvent<HTMLFormElement>) => {
    event.preventDefault();

    if (agreeRef.current) {
      validateCheckbox({ detail: { checked: agreeRef.current.checked } } as CheckboxCustomEvent<{
        checked: boolean;
      }>);
    }
  };

  return (
    <>
      <form onSubmit={submit}>
        <IonCheckbox
          ref={agreeRef}
          className={`${isValid ? 'ion-valid' : ''} ${isValid === false ? 'ion-invalid' : ''} ${
            isTouched ? 'ion-touched' : ''
          }`}
          helperText="Agree to the terms before continuing"
          errorText="You must agree to the terms to continue"
          onIonChange={(event) => validateCheckbox(event)}
        >
          I agree to the terms and conditions
        </IonCheckbox>

        <br />

        <IonButton type="submit" size="small">
          Submit
        </IonButton>
      </form>
    </>
  );
}

export default Example;

Vue

<template>
  <form @submit.prevent="submit">
    <ion-checkbox
      v-model="agree"
      helper-text="Agree to the terms before continuing"
      error-text="You must agree to the terms to continue"
      @ionChange="validateCheckbox"
      :class="{ 'ion-valid': isValid, 'ion-invalid': isValid === false, 'ion-touched': isTouched }"
    >
      I agree to the terms and conditions
    </ion-checkbox>

    <br />

    <ion-button type="submit" size="small">Submit</ion-button>
  </form>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import { IonCheckbox, IonButton, CheckboxCustomEvent } from '@ionic/vue';

  const agree = ref(false);
  const isTouched = ref(false);
  const isValid = ref<boolean | undefined>();

  const validateCheckbox = (event: CheckboxCustomEvent<{ checked: boolean }>) => {
    isTouched.value = true;
    isValid.value = event.detail.checked;
  };

  const submit = () => {
    validateCheckbox({ detail: { checked: agree.value } } as CheckboxCustomEvent<{ checked: boolean }>);
  };
</script>

테마 적용 (Theming)

CSS Custom Properties

JavaScript

<ion-checkbox>Themed checkbox</ion-checkbox>

<style>
  ion-checkbox {
    --size: 32px;
    --checkbox-background-checked: #6815ec;
  }

  ion-checkbox::part(container) {
    border-radius: 6px;
    border: 2px solid #6815ec;
  }
</style>

Angular

src/app/example.component.html

<ion-checkbox>Themed checkbox</ion-checkbox>

src/app/example.component.css

ion-checkbox {
  --size: 32px;
  --checkbox-background-checked: #6815ec;
}

ion-checkbox::part(container) {
  border-radius: 6px;
  border: 2px solid #6815ec;
}

src/app/example.component.ts

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

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

React

src/main.tsx

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

import './main.css';

function Example() {
  return <IonCheckbox>Themed checkbox</IonCheckbox>;
}
export default Example;

src/main.css

ion-checkbox {
  --size: 32px;
  --checkbox-background-checked: #6815ec;
}

ion-checkbox::part(container) {
  border-radius: 6px;
  border: 2px solid #6815ec;
}

Vue

<template>
  <ion-checkbox>Themed checkbox</ion-checkbox>
</template>

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

<style>
  ion-checkbox {
    --size: 32px;
    --checkbox-background-checked: #6815ec;
  }

  ion-checkbox::part(container) {
    border-radius: 6px;
    border: 2px solid #6815ec;
  }
</style>

인터페이스 (Interfaces)

CheckboxChangeEventDetail

interface CheckboxChangeEventDetail<T = any> {
  value: T;
  checked: boolean;
}

CheckboxCustomEvent

이 인터페이스는 필수는 아니지만, 이 컴포넌트에서 발생하는 Ionic 이벤트를 더 강력한 타입으로 다루기 위해 CustomEvent 인터페이스 대신 사용할 수 있어요.

interface CheckboxCustomEvent<T = any> extends CustomEvent {
  detail: CheckboxChangeEventDetail<T>;
  target: HTMLIonCheckboxElement;
}

Properties

alignment

설명: 체크박스와 라벨이 크로스 축에서 어떻게 정렬될지 제어합니다. "start": 라벨과 컨트롤이 LTR에서는 크로스 축의 왼쪽에, RTL에서는 오른쪽에 나타납니다. "center": 라벨과 컨트롤이 LTR과 RTL 모두에서 크로스 축의 중앙에 나타납니다. 이 프로퍼티를 설정하면 체크박스의 display가 block으로 바뀝니다.

속성(Attribute): alignment

타입(Type): "center" | "start" | undefined

기본값(Default): undefined

checked

설명: true로 설정하면 체크박스가 선택된 상태가 됩니다.

속성(Attribute): checked

타입(Type): boolean

기본값(Default): false

color

설명: 애플리케이션의 색상 팔레트에서 사용할 색상을 지정합니다. 기본 옵션은 "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

disabled

설명: true로 설정하면 사용자가 체크박스와 상호작용할 수 없습니다.

속성(Attribute): disabled

타입(Type): boolean

기본값(Default): false

errorText

설명: 체크박스 라벨 아래에 배치되며, 오류가 감지되었을 때 표시되는 텍스트입니다.

속성(Attribute): error-text

타입(Type): string | undefined

기본값(Default): undefined

helperText

설명: 체크박스 라벨 아래에 배치되며, 오류가 감지되지 않았을 때 표시되는 텍스트입니다.

속성(Attribute): helper-text

타입(Type): string | undefined

기본값(Default): undefined

indeterminate

설명: true로 설정하면 체크박스가 비결정(indeterminate) 상태로 시각적으로 표시됩니다.

속성(Attribute): indeterminate

타입(Type): boolean

기본값(Default): false

justify

설명: 라벨과 체크박스를 한 줄 안에서 어떻게 배치할지 제어합니다. "start": 라벨과 체크박스가 LTR에서는 왼쪽에, RTL에서는 오른쪽에 나타납니다. "end": 라벨과 체크박스가 LTR에서는 오른쪽에, RTL에서는 왼쪽에 나타납니다. "space-between": 라벨과 체크박스가 줄의 양끝에 나타나고 두 요소 사이에 공간이 생깁니다. 이 프로퍼티를 설정하면 체크박스의 display가 block으로 바뀝니다.

속성(Attribute): justify

타입(Type): "end" | "space-between" | "start" | undefined

기본값(Default): undefined

labelPlacement

설명: 체크박스에 대한 라벨의 위치를 지정합니다. "start": 라벨이 LTR에서는 체크박스 왼쪽에, RTL에서는 오른쪽에 나타납니다. "end": 라벨이 LTR에서는 체크박스 오른쪽에, RTL에서는 왼쪽에 나타납니다. "fixed": 라벨은 "start"와 동일하게 동작하지만 고정된 너비를 가집니다. 긴 텍스트는 줄임표("...")로 잘립니다. "stacked": 방향과 무관하게 라벨이 체크박스 위에 나타납니다. 라벨의 정렬은 alignment 프로퍼티로 제어할 수 있습니다.

속성(Attribute): label-placement

타입(Type): "end" | "fixed" | "stacked" | "start"

기본값(Default): 'start'

mode

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

속성(Attribute): mode

타입(Type): "ios" | "md"

기본값(Default): undefined

name

설명: 폼 데이터와 함께 제출되는 컨트롤의 이름입니다.

속성(Attribute): name

타입(Type): string

기본값(Default): this.inputId

required

설명: true로 설정하면 화면 판독기가 필수 필드로 안내합니다. 이 프로퍼티는 접근성 목적으로만 동작하며, 값이 유효하지 않아도 폼 제출을 막지는 않습니다.

속성(Attribute): required

타입(Type): boolean

기본값(Default): false

value

설명: 체크박스의 value는 체크 여부를 의미하지 않습니다. 그 용도로는 checked 프로퍼티를 사용하세요. 체크박스의 value는 <input type="checkbox">의 value와 유사하며, 체크박스가 네이티브 <form>에 참여할 때만 사용됩니다.

속성(Attribute): value

타입(Type): any

기본값(Default): 'on'

Events

이름(Name) 설명(Description) 버블링(Bubbles)
ionBlur 체크박스가 포커스를 잃었을 때 발생합니다. true
ionChange 사용자 동작(예: 클릭)의 결과로 checked 프로퍼티가 변경되었을 때 발생합니다. checked 프로퍼티를 프로그래밍 방식으로 설정할 때는 이 이벤트가 발생하지 않습니다. true
ionFocus 체크박스에 포커스가 있을 때 발생합니다. true

Methods

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

CSS Shadow Parts

이름(Name) 설명(Description)
container 체크박스 마크의 컨테이너입니다.
error-text 체크박스가 유효하지 않고 touched 상태일 때 체크박스 라벨 아래 표시되는 보조 텍스트입니다.
helper-text 체크박스가 유효할 때 체크박스 라벨 아래 표시되는 보조 텍스트입니다.
label 체크박스를 설명하는 라벨 텍스트입니다.
mark 체크 상태를 나타내는 체크 표시입니다.
supporting-text 체크박스 라벨 아래 표시되는 보조 텍스트입니다.

CSS Custom Properties

iOS

이름(Name) 설명(Description)
--border-color 체크박스 아이콘의 테두리 색상
--border-color-checked 체크된 상태의 체크박스 아이콘 테두리 색상
--border-radius 체크박스 아이콘의 테두리 모서리 반경
--border-style 체크박스 아이콘의 테두리 스타일
--border-width 체크박스 아이콘의 테두리 두께
--checkbox-background 체크박스 아이콘의 배경
--checkbox-background-checked 체크된 상태의 체크박스 아이콘 배경
--checkmark-color 체크된 상태의 체크박스 체크 표시 색상
--checkmark-width 체크박스 체크 표시의 선(stroke) 두께
--size 체크박스 아이콘의 크기
--transition 체크박스 아이콘의 전환 효과

MD

이름(Name) 설명(Description)
--border-color 체크박스 아이콘의 테두리 색상
--border-color-checked 체크된 상태의 체크박스 아이콘 테두리 색상
--border-radius 체크박스 아이콘의 테두리 모서리 반경
--border-style 체크박스 아이콘의 테두리 스타일
--border-width 체크박스 아이콘의 테두리 두께
--checkbox-background 체크박스 아이콘의 배경
--checkbox-background-checked 체크된 상태의 체크박스 아이콘 배경
--checkmark-color 체크된 상태의 체크박스 체크 표시 색상
--checkmark-width 체크박스 체크 표시의 선(stroke) 두께
--size 체크박스 아이콘의 크기
--transition 체크박스 아이콘의 전환 효과

Slots

이름(Name) 설명(Description)
체크박스와 연결할 라벨 텍스트입니다. "labelPlacement" 프로퍼티를 사용해 라벨이 체크박스에 대해 어디에 배치될지 제어하세요.

더 알아보기 (Learn more)

ion-checkbox는 다중 선택을 처리하는 핵심 입력 컴포넌트예요. labelPlacement, justify, alignment 같은 프로퍼티로 라벨 배치를 자유롭게 조절할 수 있고, helperText/errorText로 폼 상태를 사용자에게 알려줄 수 있습니다. 폼과 함께 쓸 땐 ion-item 안에 넣어 리스트와 자연스럽게 어울리게 하는 방법도 많이 사용해요.