---
title: "セレクトフィールド"
description: "決まったリストの中から 1 つの値を、完成した 1 つのフォームのフィールドとして選べるようにします。必須または任意であることを伝えられるラベル、選ばれているオプションを表示してオプションのリストを開くトリガー、下に置く補足またはエラーの 1 行から成り、支援技術に対して 1 つにまとめられ、フォームには 1 つのコントロールとして加わります。"
url: "https://tanrei.chnotchy.com/ja/components/select-field/"
last_updated: 2026-10-23T21:17:12.000Z
---

# セレクトフィールド

> 決まったリストの中から 1 つの値を、完成した 1 つのフォームのフィールドとして選べるようにします。必須または任意であることを伝えられるラベル、選ばれているオプションを表示してオプションのリストを開くトリガー、下に置く補足またはエラーの 1 行から成り、支援技術に対して 1 つにまとめられ、フォームには 1 つのコントロールとして加わります。

## 概要

セレクトフィールドは、フォームの中で、あらかじめ決まっていて、ほかの値を受け付けないリストから 1 つの値を選ぶときに使います。国、タイムゾーン、プランなどです。ラベル、選ばれているオプションを表示してリストを開くボックス、補足の 1 行、値を受け付けなかったときの言葉という、いつもの組み合わせが、そのまま使える形でそろっています。

**構成要素**は、[フィールド](https://tanrei.chnotchy.com/ja/components/field/)と[セレクト](https://tanrei.chnotchy.com/ja/components/select/)です。フィールドは枠で、ラベル、必須または任意の印、補足、エラーを受け持ちます。セレクトはコントロールで、トリガーとリスト、その中でユーザーが行うすべてを受け持ちます。セレクトフィールドが自分で描くものはなく、トークンもありません。プロパティはどれも 2 つのどちらかのもので、そのまま渡されます。渡したオプションは、中のセレクトのオプションになります。

幅は置かれた場所に合わせて広がり、ボックスはその幅いっぱいに広がります。ボックスを狭くするには、置く場所を狭くします。

Web では、`<tanrei-option>` を子に持つ `<tanrei-select-field>` です。ほかのプラットフォームはまだ実装していません。

### 使い方

オプションはセレクトフィールドの子で、それぞれが値とラベルを持ちます。選ばれているオプションは `value` で指定します。`change` と `toggle` はセレクトのイベントで、どちらかを受け取った時点で、フィールドの `value` と `open` はすでに新しい値になっています。

**Web**

```html
<form>
  <tanrei-select-field name="country" label="国" value="jp" required required-text="必須"
    supporting-text="請求書の宛先になります。">
    <tanrei-option value="ca">カナダ</tanrei-option>
    <tanrei-option value="jp">日本</tanrei-option>
  </tanrei-select-field>
</form>

<!-- グループに分け、ラベルの下に 1 行を添え、フィールドを表すグリフを置いた例。 -->
<tanrei-select-field label="タイムゾーン" value="Europe/Lisbon">
  <span slot="leading-icon">public</span>
  <tanrei-option-group label="アジア">
    <tanrei-option value="Asia/Tokyo" supporting-text="UTC+9">東京</tanrei-option>
  </tanrei-option-group>
  <tanrei-option-group label="ヨーロッパ">
    <tanrei-option value="Europe/Lisbon" supporting-text="UTC+0">リスボン</tanrei-option>
  </tanrei-option-group>
</tanrei-select-field>

<script type="module">
  import '@tanrei/web/components/select-field';

  const country = document.querySelector('[name="country"]');
  // ユーザーが別のオプションを選びました。value はすでに新しい値です。
  country.addEventListener('change', () => save(country.value));
  // ユーザーが開いたか、閉じました。閉じたときは理由が付きます。
  country.addEventListener('toggle', (e) => console.log(e.detail.open, e.detail.reason));
  // 検証は利用者側で行います。セレクトフィールドが自分で error を設定することはありません。
  country.error = submitted && !ships(country.value);
  country.errorText = 'この国にはまだ発送できません。別の国を選んでください。';
</script>
```

**React**

```tsx
import { Option, SelectField } from '@tanrei/react';

<SelectField label="国" value={country} required requiredText="必須" onChange={(event) => setCountry(event.currentTarget.value)}>
  <Option value="ca">カナダ</Option>
  <Option value="jp">日本</Option>
</SelectField>
```

### 1 つ下の階層

同じフィールドを 2 つの構成要素から自分で書いても、見た目は同じで、支援技術にとっても同じコントロールになります。

```html
<tanrei-field label="国" required required-text="必須"
  supporting-text="請求書の宛先になります。">
  <tanrei-select name="country" placeholder="国を選択">
    <tanrei-option value="jp">日本</tanrei-option>
    <tanrei-option value="ke">ケニア</tanrei-option>
  </tanrei-select>
</tanrei-field>
```

セレクトフィールドにない並べ方が必要なときに、1 つ下の階層で書きます。

| 必要なもの | 使うもの |
| --- | --- |
| ラベル、ボックス、補足、エラー | セレクトフィールド |
| 枠の中、ボックスの横や下に置く自分の要素 | [フィールド](https://tanrei.chnotchy.com/ja/components/field/)に、[セレクト](https://tanrei.chnotchy.com/ja/components/select/)と自分の要素を入れる |
| ボックスだけ。ラベルは別の場所にある（バーに置くテーマ、ツールバーに置く並び順、テーブルのセル） | [セレクト](https://tanrei.chnotchy.com/ja/components/select/)を単独で使い、セレクトの `label` で名前を付ける |
| スクロールするより入力したくなるほど長いリスト | [コンボボックス](https://tanrei.chnotchy.com/ja/components/combobox/) |

1 つ下の階層で変わるのは、何をどこに指定するかです。`name`、`value`、オプションはセレクトに指定し、フォームに加わるコントロールもイベントが届く先もセレクトになります。`label`、`error`、`disabled` はフィールドに指定したままにします。フィールドがコントロールに伝えるので、セレクトの側には指定しません。

## 仕様

### それぞれの構成要素が受け持つもの

| 観点 | フィールドから | セレクトから |
| --- | --- | --- |
| プロパティ | `label`、`labelHidden`、`supportingText`、`errorText`、`error`、`disabled`、`required`、`optional`、`requiredMark`、`requiredText`、`optionalText` | `variant`、`size`、`value`、`placeholder`、`readOnly`、`open`、`separation`、`iconSpace`、`status`、`statusText`、`emptyText` |
| イベント | — | `change`、`toggle` |
| スロット | `label-icon` | `leading-icon` と、オプション |
| トークン | `comp.field.*` | ボックスは `comp.input-box.*`（すべての入力ボックスが読みます）。リストは `comp.select.*` |

セレクトは、自分の `label`、`labelHidden`、`error`、`disabled` を持っています。これらはセレクトフィールドのプロパティではありません。フィールドの `label` がコントロールに名前を付け、`error` がボックスをエラーの状態にし、`disabled` がボックスを無効にします。そのため、どれもセレクトフィールドに 1 回指定すればよく、ラベルもコントロールと一緒に変わります。

`stacked` では、ラベルはボックスの上にあるフィールドの行です。`filled` と `outlined` では、同じラベルをセレクトがボックスの中で浮き上がるラベルとして描き、フィールドはラベルの行を描きません。このとき必須のフィールドは、デザインシステムがどの印を指定していても、ラベルの後のアスタリスクで示されます。補足は、先頭のアイコンを過ぎた、値の始まる位置から始まります。リストが開いている間は、ボックスと同じように、ラベルと補足もフォーカスされた状態で描かれます。

トリガーとリストの動き（開く、矢印キー、文字の入力、選ぶ、グループ）は[セレクトのページ](https://tanrei.chnotchy.com/ja/components/select/)に、枠の動き（必須の印、補足、エラーとその読み上げ）は[フィールドのページ](https://tanrei.chnotchy.com/ja/components/field/)にあります。

### 1 つのフィールドだけを変える

セレクトフィールドに自分のトークンはありません。枠はフィールドのトークンを、ボックスとリストはセレクトのトークンを、どこで設定されていても読みます。1 つだけ変えるには、構成要素のトークンをその要素に設定します。

```html
<tanrei-select-field label="国"
  style="--tanrei-comp-field-label-gap: 12px"></tanrei-select-field>
```

- Category: Selection
- Level: composed
- Listing: default
- Built from: Field, Select
- Page: https://tanrei.chnotchy.com/components/select-field/
- Spec: https://github.com/chnotchy/tanrei/blob/main/specs/select-field.spec.json

### Availability

| Design system | Has it | Notes |
| --- | --- | --- |
| Tanrei (`tanrei`) | Yes | Variants left out: `filled`, `outlined`. |
| Cupertino (Apple HIG-inspired) (`cupertino`) | Yes | — |
| M3 Expressive-like (Material 3 Expressive-inspired) (`m3-expressive-like`) | Yes | — |
| M3-like (Material 3-inspired) (`m3-like`) | Yes | — |

### Platforms

- Web: the element `<tanrei-select-field>`, registered by importing `@tanrei/web` (or only its own module, `@tanrei/web/components/select-field`).
- React: `SelectField` from `@tanrei/react`.

| Platform | Name | Status |
| --- | --- | --- |
| Web | `tanrei-select-field` | lagging |
| SwiftUI | `TanreiSelectField` | planned |
| Jetpack Compose | `TanreiSelectField` | planned |
| Flutter | `TanreiSelectField` | planned |
| React Native | `SelectField` | planned |

Names a platform gives in its own idiom:

| Spec | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
| --- | --- | --- | --- | --- | --- |
| `value` (prop) | `value` | `selection` | `value` | `value` | `value` |
| `label` (prop) | `label` | `label` | `label` | `labelText` | `label` |
| `labelHidden` (prop) | `labelHidden` | `labelsHidden` | `labelHidden` | `labelHidden` | `labelHidden` |
| `placeholder` (prop) | `placeholder` | `prompt` | `placeholder` | `hintText` | `placeholder` |
| `supportingText` (prop) | `supportingText` | `supportingText` | `supportingText` | `helperText` | `supportingText` |
| `error` (prop) | `error` | `error` | `isError` | `isError` | `error` |
| `disabled` (prop) | `disabled` | `disabled` | `enabled` | `enabled` | `disabled` |
| `required` (prop) | `required` | `isRequired` | `required` | `required` | `required` |
| `optional` (prop) | `optional` | `isOptional` | `optional` | `optional` | `optional` |
| `open` (prop) | `open` | `isPresented` | `expanded` | `controller` | `open` |
| `change` (event) | `change` | `selection` | `onValueChange` | `onChanged` | `onValueChange` |
| `toggle` (event) | `toggle` | `isPresented` | `onExpandedChange` | `onOpenChanged` | `onOpenChange` |

Statuses: `planned` — In the inventory. Nothing shippable exists yet. `lagging` — An implementation of an earlier spec exists; it has not caught up with the current one. `alpha` — Implemented with tests. The API may still change. `beta` — Feature complete and at parity. Only fixes are expected. `stable` — Covered by semantic versioning. `deprecated` — Still shipped; scheduled for removal.

### Anatomy

- `field`: The Field: the label row with its glyph and its requirement mark, and the supporting row with the help and the error text. In a look whose select floats the label it draws no label row.
- `select`: The select, as the Field's one control: the trigger with the value it shows, its leading icon and its chevron, the label that floats in it in the looks that float one, and the list of options that opens from it.

### Props

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `variant` | `enum`: `stacked`, `filled`, `outlined` | `"stacked"` | `variant` | The text input's three looks, so that a select is drawn as the text inputs beside it. Stacked is a filled box that shows focus and error with a line inside its edge and draws no label: the label of the Field that frames it stands above it. Filled and outlined float the label inside the box. Use one style per form. A design system may leave some out (the Tanrei system ships stacked only) or add values. (From Select.) |
| `size` | `enum`: `small`, `medium`, `large` | `"medium"` | `size` | Minimum height of the container: stacked 32 / 40 / 56, as tall as a Button of the same size, so that the box and a Button side by side in one row stand as tall as each other; filled and outlined 40 / 48 / 56, which hold the label that floats inside them. The text input's three sizes: medium and large for forms, small for a select in an app bar, a toolbar or a dense row of controls, where nothing frames it. The hit area always meets the minimum target. A design system may add values. (From Select.) |
| `value` | `string` | `""` | `value` | The value of the chosen option. The select shows that option's label; while value names no option it shows the placeholder. An option whose value is the empty string is a choice like any other ("None", "Any") and is the chosen one while value is empty. (From Select.) |
| `label` | `string` | `""` | `label` | Names the control, visibly and to assistive technology. Required, unless the control names itself (a checkbox or a switch with its own label): then leave it empty and the field adds only help and an error. (From Field: Names the select. In a filled or outlined look the select draws it, floating in its box, and the Field draws no label row (FLD-25, SEL-15).) |
| `labelHidden` | `boolean` | `false` | `label-hidden` | Does not draw the label, which stays the accessible name. For a control whose visible label is elsewhere (a table column, a toolbar). (From Field: Hides the label wherever it would be drawn: the Field's row, or the select's floating label (FLD-25).) |
| `placeholder` | `string` | `""` | `placeholder` | A hint shown while nothing is chosen and the label is not in the line ("Choose a country"). Never a replacement for label, and never a choice. (From Select.) |
| `supportingText` | `string` | `""` | `supporting-text` | Help shown below the control and given to assistive technology as the control's description. While the field is in error it gives way to errorText, unless the design system keeps both (comp.field.error-text.placement append). (From Field.) |
| `errorText` | `string` | `""` | `error-text` | Shown while error is true, in supportingText's place — or below it, which then stays, where the design system's comp.field.error-text.placement is append: what is wrong and how to put it right, in words. (From Field.) |
| `error` | `boolean` | `false` | `error` | Puts the field in the error condition: the error text is drawn, the control is exposed as invalid and, where it has an error condition of its own, drawn in it. What a value means is the product's to validate; the field never sets this itself. (From Field: The Field puts its select in the select's own error condition (FLD-8, SEL-9).) |
| `disabled` | `boolean` | `false` | `disabled` | Disables the control and draws the frame as disabled. Disable a framed control here, not on the control, so that its label follows. (From Field: The Field disables its select (FLD-14, SEL-46); the select field is then left out of its form (SEF-2).) |
| `readOnly` | `boolean` | `false` | `readonly` | The value is shown, can be focused and is submitted, but cannot be changed: the list does not open and no chevron is drawn. (From Select.) |
| `required` | `boolean` | `false` | `required` | What the form asks of the control: true exposes it as required and draws the required mark beside the label. It never validates: a missing answer is the product's to report with error. (From Field: The Field exposes its select as required (FLD-10, SEL-11).) |
| `optional` | `boolean` | `false` | `optional` | Draws the optional tag after the label and adds optionalText to the control's description, because assistive technology has no state for it. Ignored while required is true: a control is never both. (From Field.) |
| `requiredMark` | `enum`: `auto`, `tag`, `asterisk`, `none` | `"auto"` | `required-mark` | How this control shows that it is required: tag is a small filled Tag with requiredText, asterisk is "*" after the label, none draws nothing and keeps the semantics. Auto takes comp.field.requirement.mark, which follows sys.behavior.requirement-mark, the system's one answer. Ignored unless required is true. (From Field.) |
| `requiredText` | `string` | `""` | `required-text` | The text of the required tag, in the product's language ("Required", "必須"). The product's: Tanrei has no word for it. Empty reads the product's words; with neither, FLD-24 says what is drawn. (From Field.) |
| `optionalText` | `string` | `""` | `optional-text` | The text of the optional tag, in the product's language ("Optional", "任意"); also read to assistive technology as part of the description. The product's: Tanrei has no word for it. Empty reads the product's words. (From Field.) |
| `open` | `boolean` | `false` | `open` | Whether the list is shown. The select opens and closes itself and emits toggle; the product may also set it. Ignored while the select is disabled or read-only or has nothing to show: no option, no status row and no empty text (SEL-61). (From Select.) |
| `separation` | `enum`: `auto`, `divider`, `gap` | `"auto"` | `separation` | How a group of options is told from what is next to it. divider: a line between them. gap: empty space and no line. Auto takes comp.select.separation, which follows the design system's choice. (From Select.) |
| `iconSpace` | `enum`: `auto`, `always`, `never` | `"auto"` | `icon-space` | Whether an option keeps the room of the leading icon column where it has no icon, so that the labels of a section start on one line — a section being an option group, or a run of adjacent options outside any group. auto: an option keeps the column while another option of its section has a leading icon, so that a section without icons starts its labels where the row's content starts. always: every option keeps it. never: only an option that has an icon has the column. The menu's iconSpace, with the same values and default (SEL-66). (From Select.) |
| `density` | `enum`: `regular`, `compact` | `"regular"` | `density` | How much room an option of the list takes: its least height, its paddings, the gap between its columns and the size of its glyphs (the leading icon, the check), and never its text style. regular (a 48 row in the default system) is for a product used by touch as well as by pointer; compact (a 32 row with 20 glyphs, the menu's compact row) is for a tool used with a pointer, whose lists are long. For touch an option is never lower than the touch target in either (SEL-37). The field's own box is not changed: its height is size's. A design system may add values. (From Select.) |
| `status` | `enum`: `idle`, `loading`, `error` | `"idle"` | `status` | What the product's source of options is doing, which the product sets: idle (the options given are final), loading (options are on their way: the status row shows a loading indicator and the list is marked busy) or error (the source failed: the status row shows statusText in the error color, announced at once). The combobox's and the search's values, with the same meaning. The select never loads anything itself. (From Select.) |
| `statusText` | `string` | `""` | `status-text` | The status row's text, in the product's language, read to assistive technology when the list opens and when it changes: a count ("20 of 340 projects shown"), that loading failed ("Projects could not be loaded"), or, while status is loading, the loading indicator's name ("Loading projects"). Empty draws no status row unless status is loading. (From Select.) |
| `emptyText` | `string` | `""` | `empty-text` | Shown in the list while the select holds no option, status is idle and statusText is empty, in the product's language ("No projects yet"), so that the select still opens and says why there is nothing to choose. The product's: Tanrei has no words for it. Empty reads the product's words (noOptionsText); with neither, the select has nothing to show and does not open (SEL-61), and it is reported. (From Select.) |

### Events

| Event | Description |
| --- | --- |
| `change` | The person chose an option whose value differs from the select's; carries the new value. Not emitted when the product sets value, when the chosen option is chosen again, or while the person only moves through the list. (From Select.) |
| `toggle` | The list was opened or closed by the person; carries the new open and, for a close, the reason: select, escape, back, outside, focus-out, anchor-hidden, press or tab (in the platform's casing). After a choice it follows change. (From Select.) |

### Slots

| Slot | Description |
| --- | --- |
| `leading-icon` | A glyph at the start of the container that stands for the field whatever is chosen (a globe before a language). It takes the place of the chosen option's own glyph. (From Select.) |
| `label-icon` | A glyph before the label. (From Field.) |

### Item: `option`

One choice of the select: a label, the value it stands for, and optionally a supporting line and a glyph.

Names: Web `tanrei-option`, SwiftUI `TanreiSelectOption`, Jetpack Compose `TanreiSelectOption`, Flutter `TanreiSelectOption`, React Native `SelectOption`.

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `label` | `string` | `""` | `label` | The option's text and its accessible name; the container shows it once the option is chosen. Required. |
| `value` | `string` | `""` | `value` | Identifies the choice: the option is the chosen one while the select's value equals it. Unique within the select. The empty string is a value like any other, for an option that stands for no choice ("None"). |
| `supportingText` | `string` | `""` | `supporting-text` | A line below the label that says more about the choice. Shown in the list, not in the container. |
| `leadingIcon` | `string` | `""` | `leading-icon` | The name of an icon (a glyph of the system's icon set) before the label; the container shows it too while the option is chosen and the select has no leading icon of its own. |
| `disabled` | `boolean` | `false` | `disabled` | Prevents the option from being chosen. It stays reachable with the arrow keys. |

### Item: `option-group`

A run of related options, optionally titled. The select separates a group from what is next to it by a divider or a gap.

Names: Web `tanrei-option-group`, SwiftUI `TanreiSelectSection`, Jetpack Compose `TanreiSelectGroup`, Flutter `TanreiSelectGroup`, React Native `SelectOptionGroup`.

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `title` | `string` | `""` | — | A short heading drawn above the group's options, which also names the group; empty draws none and leaves the group unnamed. |

### States

`enabled`, `disabled`, `hovered`, `focused`, `pressed`, `selected`, `error`

### Accessibility

- Role: `combobox`
- Labeling: The select field adds nothing to what its members expose and coordinates nothing: the Field gives the select its name, its description and its required, invalid and disabled states (FLD-8, FLD-10, FLD-11, FLD-14), and the select carries them on its own trigger and names its list by the same name (SEL-11, SEL-48). Assistive technology meets one control that opens a list of choices, named by label, with the chosen option's label as its value — exactly as it meets a Field around a select written by hand.
- Minimum target size: yes

| Keys | Action |
| --- | --- |
| Every key | The select's (its accessibility block; SEL-23, SEL-27, SEL-28, SEL-31, SEL-33, SEL-34). The select field handles no key and adds no focus stop (SEF-3). |

- One level down is the same thing: a Field with a select in it, holding the same options. Every fixture has that pair as its twin, and the accessibility tree of the two is the same (SEF-1).
- On the web the two members stand in the select field's own shadow root, so the form meets the select field and not the select (SEF-2), focus passes through to the trigger (SEF-3), and the options, which stay the product's children, reach the select through a slot and are read by it as data.
- A select with no visible label of its own — in a header, a toolbar, a column of a table — is the bare select, named by its own label, not a select field with labelHidden.

### Behaviour

Requirements in EARS form, each with its stable id.

- **SEF-1** THE select field SHALL be a Field that frames one select, and nothing else. It SHALL give label, labelHidden, supportingText, errorText, error, disabled, required, optional, requiredMark, requiredText and optionalText to its Field and every other prop to its select, each unchanged; SHALL hold the label-icon slot for its Field and the leading-icon slot for its select; SHALL give its select every option and option group the product gives it, in the order given, as that select's own items, read, drawn and chosen by the select (SEL-17, SEL-31 to SEL-45); and SHALL emit its select's events as its own, each once. It SHALL draw no part of its own, hold no state of its own and have no token of its own: what it shows, how it behaves and what it exposes to assistive technology SHALL be exactly what that Field and that select do when a product places the one in the other (FLD-1 to FLD-28; SEL-1 to SEL-64) — the label row and its requirement mark (FLD-2 to FLD-6), or the label that floats in the box with the Field's row left out (FLD-25, SEL-15, SEL-7); the supporting row and the error, started where the value starts (FLD-7 to FLD-9, FLD-26); the rows drawn focused while the list is open (FLD-13, SEL-20); the name, the description and the states (FLD-10, FLD-11, FLD-14, SEL-11); and the width, which is the Field's and which the select fills (FLD-1, SEL-49).
- **SEF-2** WHERE the platform has forms (the web) THE select field SHALL be the one control the form sees: it SHALL take name, submit its select's value, reset to the value it was first given, restore it on navigation, report to the form's constraint validation exactly what its select would report there (SEL-11), be submitted WHILE readOnly is true (SEL-47), and be left out WHILE disabled is true or a disabled group of the form holds it (SEL-46); its select and its Field SHALL take no part in the form themselves.
- **SEF-3** WHEN the select field is given focus — by the product, by a press on its label row (FLD-12), or by a form that reports its validity — THE select field SHALL pass the focus to its select's container and SHALL add no stop to the focus order: the one stop inside it is its select's (SEL-13). WHILE focus is anywhere inside it, or its select's list is open, THE select field SHALL count as focused for its Field (FLD-13).
- **SEF-4** IF the select field is placed in a Field THE select field SHALL in debug builds report that it is a field already and that the bare control is the select, and both SHALL still render (FLD-15). WHILE it stands in a field group THE select field SHALL follow that group's disabled, through its own Field, and take nothing else from the group (FGR-20).
- **SEF-5** THE select field SHALL have no words of its own and SHALL read none: requiredText and optionalText are read by its Field (FLD-24), emptyText by its select (SEL-62), each from the instance's prop and then from the product's words.
- **SEF-6** WHERE the platform has ARIA attributes (the web), WHEN the product sets an aria- attribute on the host, by the attribute or by the ARIA property that reflects it, THE select field SHALL move it to the data-aria- attribute of the same name, so that the host is no second node with its name, description or state, and SHALL expose it on the element that carries its role — an id reference by the elements it names in the host's tree or a tree around it, an error message as part of the description while the select field is invalid — except those the select field owns (aria-label, aria-labelledby, aria-disabled, aria-haspopup, aria-expanded, aria-controls), which it SHALL move and not expose: its name is label (SEF-1). WHEN the product removes the aria- attribute or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaDescribedByElements…) to null, THE select field SHALL take it off that element. WHEN the product sets an aria- attribute the select field owns THE select field SHALL report it in debug builds.

### Tokens

As written in the token documents (DTCG): an alias in braces names the token it takes its value from, which each design system resolves. On the web each token is a CSS custom property: `--tanrei` and the name after `tanrei`, joined by hyphens (`tanrei.comp.field.…` → `--tanrei-comp-field-…`).

#### `tanrei.comp.field`

| Token | Type | Value |
| --- | --- | --- |
| `comp.field.label.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.label.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.label-icon.size` | `dimension` | `{tanrei.sys.icon.small}` |
| `comp.field.label-icon.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.mark` | `number` | `{tanrei.sys.behavior.requirement-mark}` |
| `comp.field.requirement.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.asterisk-gap` | `dimension` | `{tanrei.sys.space.space25}` |
| `comp.field.supporting-text.typescale` | `typography` | `{tanrei.sys.typescale.label-small}` |
| `comp.field.supporting-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.counter.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.motion.state-duration` | `duration` | `{tanrei.sys.motion.role.state.default}` |
| `comp.field.motion.state-easing` | `cubicBezier` | `{tanrei.sys.motion.easing.state}` |
| `comp.field.standard.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.error.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error-text.color` | `color` | `{tanrei.sys.color.error}` |
| `comp.field.value-text.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.value-text.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.error-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.error-text.placement` | `number` | `0` |

Per-state tokens, valued by the design system's pattern rules (not written by hand):

- `comp.field.<variant>.<state>.<property>` for the variants `standard`, the states `focused`, `disabled` and the properties `label.color`, `label-icon.color`, `supporting-text.color`, `required-asterisk.color`, `error.label.color`, `error.label-icon.color`, `error.supporting-text.color`, `error.required-asterisk.color`, `counter.color`, `error.counter.color`, `value-text.color`, `error.value-text.color`, `error-text.color`.

### Web での描き方の違い

- 要素のシャドウルートにあるのは、`<tanrei-select>` を入れた `<tanrei-field>` だけです。要素をインポートすると、2 つとも定義されます。
- オプションは、`<tanrei-select-field>` の子のままです。移動も複製もされません。スロットを通して中のセレクトに届き、変わるたびにセレクトが読み直します。`replaceChildren()` で入れ替えても、セレクトのときと同じように動きます。
- 要素はフォームに関連付けられます。`name` と `form` を受け取り、値だけを送信します（無効の間は何も送信せず、読み取り専用の間は送信します）。リセットすると `value` 属性の値に戻り、無効な `<fieldset>` に従い、`required` が設定されていて値が空の間は、値がないことを報告します。2 つの構成要素がフォームに項目を加えることはありません。
- `change` は、composed でバブルする、セレクトのイベントです。`toggle` は、`detail.open` と `detail.reason` を持つ、セレクトの CustomEvent です。composed ですがバブルしないので、この要素では受け取れますが、`<details>` のような祖先には届きません。イベントのターゲットはこの要素で、どのリスナーでも `event.target.value` と `event.target.open` は新しい値です。
- パーツ: `field` と `select` が 2 つの構成要素です。構成要素のパーツは、1 つ下の階層と同じ名前です。`label-icon`、`supporting-text` と、`container`、`outline`、`active-indicator`、`value`、`placeholder`、`leading-icon`、`chevron`、`list`、`option`、`option-label`、`option-supporting-text`、`option-leading-icon`、`mark`、`group`、`group-title`、`divider`、`status` です。`label` と `requirement-label` は、2 つのうち描かれているほう（フィールドの行か、セレクトの浮き上がるラベル）を指します。`field-label`、`select-label`、`field-requirement-label`、`select-requirement-label` は、どちらか一方だけを指します。
- 要素そのものはフォーカスを受け取りません。`focus()` はトリガーに移り、ページの `<label for>` もフォーカスをトリガーに移します。ラベルの行を押すと、トリガーにフォーカスが移るだけで、何も開きません。トリガーを押すとリストが開き、補足を押しても何も起こりません。
- 要素にロールはありません。名前は `label` で付けます。ラベルが別の場所に描かれているときは `label-hidden` を併せて指定します。`aria-label` はここでは何にも名前を付けないので、使いません。
- 属性は構成要素のものと同じです。`label-hidden`、`supporting-text`、`error-text`、`required-mark`、`required-text`、`optional-text`、`readonly` です。
- オプションでも、オプションのグループでも、`label-icon` や `leading-icon` に入れるグリフでもない子は、描かれません。デバッグビルドはそのことを伝えます。
- 要素が定義されるまでの間、オプションはふつうのテキストとして表示されます。`tanrei-select-field:not(:defined) > *` を隠し、高さを確保しておいてください。スクリプトなしで動く必要があるページでは、`<label>` を付けた素の `<select>` を使います。

## ガイドライン

### 推奨

- ラベルには、何を選ぶのかを書き、フォームの中では見える状態にしておきます。
- オプションは、ユーザーが探す順に並べます。五十音順やアルファベット順、数の順、またはよく選ばれるものを先にした順です。
- 長いリストはグループに分け、それぞれに短いタイトルを付けます。
- あらかじめ値を選んでおくのは、ほとんどの人がその値を選ぶ場合だけにします。
- フィールドの幅は、置く場所（フォームの列）で決めます。ボックスはその幅いっぱいに広がります。

### 非推奨

- バーやツールバーで、`labelHidden` を付けたセレクトフィールドを使わない。それは、自身の `label` で名前を付けた単独の[セレクト](https://tanrei.chnotchy.com/ja/components/select/)です。
- プレースホルダーをラベルの代わりにしない。何かを選ぶと消えてしまいます。
- 断りなく、`change` でページの移動、送信、削除をしない。ユーザーは、読むためにリストの中を移動します。
- セレクトフィールドをフィールドの中に入れない。すでにフィールドです。デバッグビルドがそのことを伝えます。フィールドが囲むコントロールは、セレクトです。
- `aria-label` で名前を付けない。ラベルを描かないときは、`label` と `labelHidden` を指定します。

## アクセシビリティ

### コンポーネントが担うこと

- 1 つの、編集できないコンボボックスです。これはセレクトのものです。名前は `label` で、描かれていてもいなくても変わりません。説明は、表示している補足テキストまたはエラーテキストで、フィールドが任意の間は任意であることを伝えるテキストも加わります。
- `error` が true の間は invalid であることを、`required` が設定されている間は必須であることを、`disabled` が true の間は無効であることを、`readOnly` が true の間は読み取り専用であることを、リストが開いている間は展開されていることを伝えます。
- 名前、説明、状態は、フィールドが囲んだコントロールに結び付けるのとまったく同じ方法で結び付けられます。1 つ下の階層で自分で書いたフィールドも、同じコントロールになります。
- 描かれたラベル、必須・任意の印、グリフが、もう一度伝わることはありません。
- Tab キーで止まる位置は 1 つです。ラベルを押すとトリガーにフォーカスが移り、何も開きません。補足を押しても何も起こりません。
- セレクトフィールドの中にフォーカスがある間に現れたエラーは、構成要素のフィールドが 1 度だけ、控えめに読み上げます。
- リストの中のこと（アクティブなオプション、オプションの名前と説明と状態、グループ）は、すべてセレクトのものです。[セレクトのページ](https://tanrei.chnotchy.com/ja/components/select/#%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B7%E3%83%93%E3%83%AA%E3%83%86%E3%82%A3)にあります。
- 文字の方向、拡大したテキスト、強制カラーモードへの対応は、それぞれの構成要素が受け持ちます。
- 自分の言葉は持ちません。`requiredText` と `optionalText` が空のときは、フィールドがプロダクトの言葉から読みます。

Web での既知の制約は、構成要素のものです。グループの間の区切り線はセパレーターとしては伝わりません。入力した文字とラベルは JavaScript のやり方で比べます。要素が定義されるまでの間は、テキストとしてのオプションのほかに何も描かれません。

### 利用者側で行うこと

- すべてのセレクトフィールドに `label` を、すべてのオプションにラベルを付けます。
- 値は利用者側で検証して `error` を設定し、どう直せばよいかが分かる `errorText` を書きます。
- 必須・任意の言葉を渡します。`required-text` と `optional-text` をセレクトフィールドに書くか、`setWords({ requiredText, optionalText })` でプロダクト全体に一度だけ渡します。Tanrei は言葉を同梱しません。`requiredText` がなければタグの位置にアスタリスクを描き、`optionalText` がなければタグを描かず、何も伝えません。[プロダクトの言葉](https://tanrei.chnotchy.com/ja/foundations/words/)を参照してください。
- オプションの値は、1 つのセレクトフィールドの中で重複させません。
