Skip to content
fandhe-frontend
GitHub

Checkbox Group

fandhe-frontend-pre-styled-uicheckbox_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

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` で行う。

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>None`Some` のとき `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-orientationvertical

CSS Variables

VariableDefault
--fandhe-checkbox-group-check-height0.5rem
--fandhe-checkbox-group-check-width0.25rem
--fandhe-checkbox-group-control-size1rem
--fandhe-checkbox-group-font-sizevar(--fandhe-font-font-size-sm)

Accessibility

Keyboard Interactions

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

WAI-ARIA

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