コンテンツへスキップ

コンポーネント

チェックボックス

二者択一の選択肢で、不確定状態にも対応します。

使い方

基本

HTML
<bs:bsui-checkbox label="Email me about new releases" defaultChecked="true" />

チェックボックスリスト

各ボックスはそれぞれのname属性で送信され、そのうち1つはオフにできません。

HTML
<bs:bsui-stack direction="column" gap="3">
  <bs:bsui-checkbox name="deploys" label="A deploy finishes" defaultChecked="true" />
  <bs:bsui-checkbox name="failures" label="A build fails" defaultChecked="true" />
  <bs:bsui-checkbox name="mentions" label="Someone mentions me" />
  <bs:bsui-checkbox name="receipts" label="Billing receipts" defaultChecked="true" disabled="true" />
</bs:bsui-stack>

不確定状態

子項目のすべての範囲が選択されるまで、親ボックスは一部選択の状態を示します。

HTML
<bs:bsui-stack direction="column" gap="3">
  <bs:bsui-checkbox label="All repository scopes" indeterminate="true" />
  <bs:bsui-checkbox name="read" label="Read code and issues" defaultChecked="true" />
  <bs:bsui-checkbox name="write" label="Push commits" />
</bs:bsui-stack>

無効な状態

チェックボックスも、ほかのコントロールと同じようにフィールドからエラーメッセージを受け取れます。

Accept the terms to continue.
HTML
<bs:bsui-field invalid="true">
  <bs:bsui-checkbox name="terms" label="I agree to the terms of service" />
  <bs:bsui-field-error text="Accept the terms to continue." />
</bs:bsui-field>

属性

属性タイプデフォルト
defaultChecked toggle false
indeterminate toggle false
disabled toggle false
name text —
value text on
label richtext —
bindText text —
nameAlt text —
onChange text —
checked text —