switch
Compact settings table with switches
Compact settings table with switches
Загрузка превью…
src/switch/c-switch-13.vue
<script setup lang="ts">
import { Separator } from "@/components/ui/separator"
import { Switch } from "@/components/ui/switch"
const settings = [
{
id: "auto-save",
label: "Auto-save",
description: "Save changes automatically",
checked: true,
},
{
id: "spell-check",
label: "Spell check",
description: "Highlight spelling errors",
checked: true,
},
{
id: "line-numbers",
label: "Line numbers",
description: "Show line numbers in editor",
checked: false,
},
]
</script>
<template>
<div class="mx-auto w-full max-w-xs">
<p class="mb-3 text-sm font-medium">Editor Preferences</p>
<Separator />
<div class="flex flex-col">
<label
v-for="setting in settings"
:key="setting.id"
:for="setting.id"
class="flex cursor-pointer items-center justify-between border-b py-3 last:border-b-0"
>
<div class="flex flex-col gap-0.5">
<span class="text-sm font-medium">{{ setting.label }}</span>
<span class="text-muted-foreground text-xs">
{{ setting.description }}
</span>
</div>
<Switch
:id="setting.id"
:default-value="setting.checked"
size="sm"
/>
</label>
</div>
</div>
</template>