Checkbox

チェックボックスを使用すると、ユーザーはセットから 1 つ以上の項目を選択できます。オプションのオン/オフを切り替えるために使用できます。

いつ使用するか

  • 複数のオプションから複数の値を選択するために使用します。
  • 1つのチェックボックスのみを使用する場合、Switchを使用して2つの状態を切り替えるのと同じです。違いは、Switchが状態の変化を直接トリガーするのに対し、Checkboxは状態が変更されたとマークするだけであり、これを送信する必要があることです。

使用例

チェックボックスの基本的な使用法。

無効

無効なチェックボックス。

状態

チェックボックスには、エラー状態と無効状態があります。

スロットを使用したカスタム ラベルとエラー

スロットを使用して、リンクなどの HTML 要素でラベルとエラー メッセージをカスタマイズできます。

プロパティ
説明
タイプ
デフォルト

id

Unique identifier for the input element. An auto-generated string is used if not provided. string auto-generated

label

The label text to display next to the checkbox. string

variant

Controls the visual variant of the checkbox. When the 'error' prop/slot is used, this defaults to 'error'. 'default' | 'error' 'default'

checked

Determines if the checkbox is checked by default. boolean false

class

Additional CSS classes to apply to the root element. string ''

error

Indicates an error state or displays an error message string | boolean

success

Indicates a success state or displays a success message string | boolean

disabled

Disables the component boolean false