toggle
Toggle with icon swap on press
Toggle with icon swap on press
Загрузка превью…
src/toggle/c-toggle-9.vue
<!--
Расхождение с апстримом: `IconPlaceholder` заменена инлайновым `<svg>`
(lucide-react v0.545.0 "heart") — см. 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 aria-label="Toggle favorite" :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-heart fill-current"
>
<path
d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"
/>
</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-heart"
>
<path
d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"
/>
</svg>
</Toggle>
</div>
</template>
Установка
npx shadcn-vue@latest add https://revueui.rootapi.dev/r/c-toggle-9.jsonЗависимости реестра
Источник: порт из ReUI (Keenthemes, MIT)