IconToggle
Toggles between two icons using smooth transitions. Useful for actions like "like/unlike", "show/hide", or "expand/collapse".
vue
<script setup lang="ts">
import { IconToggle } from '@/components/kuro/icon-toggle';
import { Eye, EyeOff } from 'lucide-vue-next'
</script>
<IconToggle variant="info" mode="click">
<Eye />
<template #alt>
<EyeOff />
</template>
</IconToggle>Installation
bash
npx kuro-ui add icon-togglebash
npx github:Bartek-Nowak/Kuro add icon-toggleProps
| Prop | Type | Default | Description |
|---|---|---|---|
v-model | boolean | false | Two-way binding for toggle state. Controls which icon is currently visible. |
variant | 'default' | 'info' | 'success' | 'warning' | 'danger' | 'default' | Sets icon color using Tailwind utility classes. |
mode | 'click' | 'hover' | 'click' | Determines whether toggle happens on click or hover. |
class | string | '' | Additional classes to apply to both icons. |
Notes
- The
modeprop determines how the toggle is triggered:'click': toggles on click.'hover': toggles on mouseover/mouseout.
- Uses Vue's
v-modelto control the active state. variantis used to apply contextual color using Tailwind (e.g.text-blue-600,text-red-600).