Skip to content

FxThemeButton 主题切换按钮

太阳/月亮 SVG 图标按钮,点击切换亮/暗主题。内置 View Transition 过渡动画(圆形扩散),不支持时自动降级。

基础用法

vue
<script setup lang="ts">
import { FxThemeButton } from "@fx/layouts"

const isDark = ref(false)
</script>

<template>
  <FxThemeButton :dark="isDark" @toggle="isDark = !isDark" />
</template>

Attributes

参数说明类型默认值
dark当前是否暗色主题boolean—(必填)

Events

事件名说明回调参数
toggle点击请求翻转主题(组件内已用 View Transition 包裹)()

注意事项

  • 消费方需自行管理主题状态(如 store + html.dark class 切换)
  • 遵循 prefers-reduced-motion,开启系统降级动画时跳过过渡