Files
heroui-vue/apps/docs/demos/handbook-theme.vue
T

73 lines
1.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
Card,
Input,
Popover,
PopoverContent,
PopoverDialog,
PopoverHeading,
} from "@heroui-vue/components";
const theme = ref("light");
const target = ref<HTMLElement>();
</script>
<template>
<div class="handbook-theme-demo">
<label>
预览主题
<select v-model="theme">
<option value="light">浅色</option>
<option value="dark">深色</option>
</select>
</label>
<section
ref="target"
:class="theme"
class="theme-preview"
data-theme="ocean"
>
<Card>
<strong>自定义主题</strong>
<p>组件通过同一组语义变量更新外观。</p>
</Card>
<Input aria-label="主题预览邮箱" placeholder="输入你的邮箱" />
<Popover>
<Button>打开主题弹层</Button>
<PopoverContent :to="target">
<PopoverDialog>
<PopoverHeading>同一主题容器</PopoverHeading>
<p>to 指向局部容器,保留 CSS 变量继承。</p>
</PopoverDialog>
</PopoverContent>
</Popover>
</section>
</div>
</template>
<style scoped>
.handbook-theme-demo {
width: 100%;
display: grid;
gap: 16px;
}
.theme-preview {
display: grid;
gap: 16px;
padding: 20px;
border-radius: 16px;
background: var(--background);
color: var(--foreground);
}
[data-theme="ocean"] {
--accent: oklch(0.62 0.2 253.83);
--accent-foreground: var(--snow);
}
select {
background: var(--field-background);
color: var(--field-foreground);
border: 1px solid var(--border);
border-radius: 6px;
padding: 4px 8px;
}
</style>