toggle
Toggle with text label that changes
Toggle with text label that changes
Загрузка превью…
src/toggle/c-toggle-10.vue
<!--
Расхождение с апстримом: `IconPlaceholder` заменена инлайновым `<svg>`
(lucide-react v0.545.0 "bookmark"/"bookmark-check") — см. docs/PORTING.md §5.
Состояние зафиксировано: исходник управляет `pressed` через
`useState(false)` — контролируемое значение задано тем же `false`.
-->
<script setup lang="ts">
import { Toggle } from "@/components/ui/toggle"
const pressed = false
</script>
<template>
<div class="flex items-center justify-center">
<Toggle variant="outline" aria-label="Toggle bookmark" :model-value="pressed">
<svg
v-if="pressed"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-bookmark-check fill-current"
>
<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z" />
<path d="m9 10 2 2 4-4" />
</svg>
<svg
v-else
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="lucide lucide-bookmark"
>
<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z" />
</svg>
{{ pressed ? "Bookmarked" : "Bookmark" }}
</Toggle>
</div>
</template>
Установка
npx shadcn-vue@latest add https://revueui.rootapi.dev/r/c-toggle-10.jsonЗависимости реестра
Источник: порт из ReUI (Keenthemes, MIT)