本文へスキップ

Select セレクト ​

わかりやすい選択肢のリストから選びます。

基本的な使い方 ​

インタラクティブプレビュー
今のシーンに合った情報量を選びます。
選択中:focus
起動する前に、利用できるモードを選んでください。
Vue のソースを表示
Vue · TypeScript
<script setup lang="ts">
import { AgmButton, AgmSelect } from 'augma'
import { shallowRef } from 'vue'

const mode = shallowRef('focus')
const destination = shallowRef<string>()
const submitted = shallowRef(false)
const options = [
  { label: '集中モード', value: 'focus' },
  { label: '探索モード', value: 'explore' },
  { label: '使用できないモード', value: 'locked', disabled: true },
]
</script>

<template>
  <div class="example-stack">
    <AgmSelect v-model="mode" label="表示モード" hint="今のシーンに合った情報量を選びます。" :options="options" />
    <output>選択中:{{ mode }}</output>
    <AgmSelect
      v-model="destination"
      label="起動モード"
      hint="起動する前に、利用できるモードを選んでください。"
      placeholder="モードを選択"
      :error="submitted && !destination ? '起動モードを選んでください' : undefined"
      :options="options"
      required
    />
    <AgmButton variant="outline" @click="submitted = true">起動モードを確定</AgmButton>
    <output v-if="submitted && destination" role="status">起動モードを確定しました。</output>
    <AgmSelect label="使用できないセレクト" placeholder="モードを選択" :options="options" disabled />
  </div>
</template>

<style scoped>
.example-stack {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 360px;
}
</style>

API ​

プロパティ型デフォルト説明
idstringundefinedトリガー要素の ID(省略時は自動生成)
hintstringundefined補足説明。セレクトに関連付けられ、エラー時も表示されます
errorstringundefinedエラーメッセージ。同時に無効な状態としてマークします
requiredbooleanfalseフォームの必須項目
modelValuestringundefinedv-model で更新
labelstring必須表示ラベル
options{ label: string, value: string, disabled?: boolean }[]必須各 value は空でない一意の文字列にしてください
placeholderstring'请选择'未選択時に表示するテキスト
disabledbooleanfalse選択を無効にする
namestringundefinedフォームのフィールド名

イベント ​

  • update:modelValue(string)

キーボード操作と利用上の注意 ​

Enter / Space で開き、矢印キーで移動、Enter で選択、Escape で閉じます。文字入力による検索に対応し、無効な項目はスキップします。class / style はフィールドのコンテナに残り、その他の属性とリスナーはトリガーボタンに渡されます。hint / error は自動で関連付けられます。

インストール ​

ts
import { AgmSelect } from 'augma'
import 'augma/style.css'