组件
切换 Swap
Swap:两个内容互换位置,新内容以回弹曲线放大进场,旧内容缩小退场。部件:Root、Indicator(type="on" | "off")、RootProvider。
#基础用法
<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>
#属性
#Indicator
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
type | 'on' | 'off' | — |
#Root
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
lazyMount | boolean | 是否启用懒挂载 | |
swap | boolean | swap 是否处于 on 状态 | |
unmountOnExit | boolean | 退出时是否卸载 |