Skip to content
fandhe-frontend
GitHub

Select

fandhe-frontend-pre-styled-uiselect mod が提供するスタイル済み Select 部品です。

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

Demo

headless-ui の Select(role="listbox")に pre-styled-ui の recipe CSS を適用した静的掲示です。1 項目が選択済み(data-state="open")の listbox が開いた状態を固定表示しています。positioner はフロー内配置へ中和しています。

fandhe-frontend
Other framework

Features

  • headless-ui の `select::root` へ委譲し、`size` variant クラスを付与する。
  • `trigger` パーツが `aria-haspopup="listbox"` を固定付与し、`content`/`label` との関連付けを `aria-controls`/`aria-labelledby` で行う。
  • `content` パーツの `aria-activedescendant` は選択中アイテムの `id` を参照する(select-only combobox パターン)。

Anatomy

root
  label
  control
    trigger
      value-text
      indicator
  positioner
    content
      item
        item-text
        item-indicator

API Reference

Arguments

NameTypeDefaultDescription
sizeSizeSize::Mdサイズ variant。
stateOpenStateOpenState::Closed開閉状態。
attrsVec<(&str, &str)>root パーツへ合成する追加属性。
childrenVec<Node>root 配下の子ノード(通常 trigger/content を含む)。

Data Attributes

PartAttributeObserved Values
contentdata-stateopen
controldata-stateopen
indicatordata-stateopen
itemdata-stateclosed, open
itemdata-valuefandhe-frontend, other
item-indicatordata-stateclosed, open
positionerdata-stateopen
rootdata-stateopen
triggerdata-stateopen
value-textdata-bind-textselect-value-text

CSS Variables

VariableDefault
--fandhe-select-content-paddingvar(--fandhe-space-2)
--fandhe-select-item-paddingvar(--fandhe-space-2) var(--fandhe-space-3)
--fandhe-select-trigger-paddingvar(--fandhe-space-2) var(--fandhe-space-3)

Accessibility

WAI-ARIA

AttributeDescription
aria-haspopup`trigger` パーツへ `"listbox"` を固定付与する。
aria-expanded開閉状態に応じて `trigger` パーツへ `"true"`/`"false"` を付与する。
aria-controls`controls` が `Some` のとき `trigger` パーツから `content` パーツへ関連付ける。
aria-activedescendant`content` パーツへ、フォーカス対象アイテムの `id` を参照値として付与する(`Some` のときのみ)。
aria-selected各アイテムパーツへ選択状態に応じて `"true"`/`"false"` を付与する。