Components
Swap
Swap, dressed in the paper-and-ink system: two impressions occupying one seal, the arriving one growing into place on the spring while the departing one shrinks away. The parts — Root, Indicator (type="on" | "off"), RootProvider.
#Basic usage
<script setup lang="ts">
import { check, x } from "@bysages/icons";
import { Icon, Swap } from "@bysages/vue";
import { ref } from "vue";
const swapped = ref(false);
</script>
<template>
<button
type="button"
aria-label="Toggle check"
:aria-pressed="swapped"
class="inline-flex size-10 cursor-pointer items-center justify-center rounded-sm border border-border bg-surface-2 text-foreground"
@click="swapped = !swapped"
>
<Swap.Root :swap="swapped">
<Swap.Indicator type="on">
<Icon :glyph="check" />
</Swap.Indicator>
<Swap.Indicator type="off">
<Icon :glyph="x" />
</Swap.Indicator>
</Swap.Root>
</button>
</template>
#Props
#Indicator
| Prop | Type | Default | Description |
|---|---|---|---|
type | 'on' | 'off' | — |
#Root
| Prop | Type | Default | Description |
|---|---|---|---|
lazyMount | boolean | Whether to enable lazy mounting. | |
swap | boolean | Whether the swap is in the "on" state. | |
unmountOnExit | boolean | Whether to unmount on exit. |