本文へスキップ

Switch スイッチ ​

明確なオン/オフの状態をすぐに切り替えます。

基本的な使い方 ​

インタラクティブプレビュー
HUD オン
Vue のソースを表示
Vue · TypeScript
<script setup lang="ts">
import { AgmSwitch } from 'augma'
import { shallowRef } from 'vue'

const enabled = shallowRef(true)
</script>

<template>
  <div class="example-stack">
    <AgmSwitch v-model="enabled" label="HUD を表示" />
    <output>{{ enabled ? 'HUD オン' : 'HUD オフ' }}</output>
    <AgmSwitch label="使用できないスイッチ" disabled />
  </div>
</template>

<style scoped>
.example-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.example-stack {
  display: grid;
  gap: 24px;
  width: 100%;
  max-width: 360px;
}
</style>

API ​

プロパティ型デフォルト説明
modelValuebooleanfalsev-model で更新
labelstring必須表示ラベル
disabledbooleanfalse切り替えを無効にする
namestringundefinedフォームのフィールド名

イベント ​

  • update:modelValue(boolean)

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

Tab でフォーカス、Space または Enter で切り替えます。

インストール ​

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