Skip to content
fandhe-frontendcore v0.4.3
GitHub

Checkbox Group

fandhe-frontend-pre-styled-ui の checkbox_group mod が提供するスタイル済み Checkbox Group 部品です。

複数選択の選択肢グループです。Radio Group と対称の構造を持ちますが、状態機械には「0 個以上の項目が同時選択される」複数選択状態機械を使い、ネイティブ <input type="checkbox"> は Checkbox の hidden-input をそのまま再利用します。

関連 API: fandhe-frontend-pre-styled-ui API / fandhe-frontend-headless-ui API

Demo

複数選択の選択肢グループ。ネイティブ input[type="checkbox"](fandhe_frontend_pre_styled_ui::checkbox::hidden_input の再利用)による同時選択・キーボード操作を data-scope="checkbox-group" の anatomy へ重ねます。

Colors
Colors (horizontal)
Colors (invalid)
Size
xs
sm
md
lg
xl

Features

  • size/colorPalette variant クラスを root へ付与し、headless-ui の checkbox_group::root へ委譲する。
  • radio_group と対称の構造だが、複数選択状態機械(MultiSelect)を埋め込み、dispatch は select/deselect/toggle の 3 語彙を受理する。
  • ネイティブ <input type="checkbox"> は自前パーツを持たず、checkbox::hidden_input を item 配下へ入れ子で再利用する(hidden-input の視覚的非表示化は checkbox の recipe が担う)。
  • aria-checked/role="checkbox" は item-control へ重複付与しない(二重読み上げ防止)。グループ全体の関連付けは root の aria-labelledby で行う。
  • data-orientation="horizontal" では折り返し(flex-wrap: wrap)付きの横並びへ切り替わる。
  • root の data-invalid は custom property 経由で item-control の border-color へ伝播する(headless 層が CheckboxGroupProps 経由で出力する、イシュー #1603。attrs 経由の直接付与も引き続き有効)。root の data-disabled は CSS のみでは各 item のネイティブ入力を実際に無効化できない(タブ順序を変更できない)ため伝播しない。グループ全体を無効化する場合は、各 item・checkbox::hidden_input の disabled を利用者が一貫して付与する。
  • size は control 寸法・root/item 余白・font-size を custom property 経由で連動させ、label(グループ見出し)は medium ウェイト、item-text(項目)は通常ウェイトの 2 段階の型階層を持つ。

Anatomy

root
  label
  item
    item-control
      item-indicator
    item-text

API Reference

Arguments

NameTypeDefaultDescription
sizeSizeSize::Mdサイズ variant。
paletteColorPaletteColorPalette::AccentcolorPalette 軸。
disabledboolfalseグループ全体の無効化状態。
orientationOption<Orientation>Noneキーボード操作方向のヒント(aria-orientation)。
labelled_byOption<&str>NoneSome のとき aria-labelledby を付与する。
attrsVec<(&str, &str)>—root パーツへ合成する追加属性。
childrenVec<Node>—root 配下の子ノード。

Data Attributes

PartAttributeObserved Values
itemdata-disabled(値なし)
itemdata-statechecked, unchecked
itemdata-valueblue, green, red
item-controldata-disabled(値なし)
item-controldata-statechecked, unchecked
item-indicatordata-disabled(値なし)
item-indicatordata-statechecked, unchecked
item-textdata-disabled(値なし)
item-textdata-statechecked, unchecked
rootdata-invalid(値なし)
rootdata-orientationhorizontal, vertical

CSS Variables

VariableDefault
--fandhe-checkbox-group-check-height0.5rem
--fandhe-checkbox-group-check-width0.25rem
--fandhe-checkbox-group-control-border-colorvar(--fandhe-color-border)
--fandhe-checkbox-group-control-size1rem
--fandhe-checkbox-group-font-sizevar(--fandhe-font-font-size-sm)
--fandhe-checkbox-group-gapvar(--fandhe-space-1)
--fandhe-checkbox-group-item-gapvar(--fandhe-space-2)
--fandhe-checkbox-group-label-basisauto

Accessibility

Keyboard Interactions

KeyDescription
Spaceネイティブ <input type="checkbox">(checkbox::hidden_input の再利用)のブラウザ既定動作としてチェック状態をトグルする(ブラウザ実装依存、本フレームワークの JS 出力によらない)。

WAI-ARIA

AttributeDescription
aria-labelledbylabelled_by が Some のときのみ root へ付与する。
aria-orientationorientation が Some のとき root へ data-orientation と対で付与する。