Files
Quick-Ling/app/components/ThemeToggle.vue
T

51 lines
1.0 KiB
Vue

<script setup lang="ts">
import { useTheme } from "~/composables/useTheme";
const { theme, toggleTheme } = useTheme();
const label = computed(() =>
theme.value === "dark" ? "Switch to light mode" : "Switch to dark mode",
);
</script>
<template>
<button
class="theme-toggle"
@click="toggleTheme"
type="button"
:aria-label="label"
:title="label"
>
<span v-if="theme === 'dark'" class="theme-icon">&#9788;</span>
<span v-else class="theme-icon">&#9790;</span>
</button>
</template>
<style scoped>
.theme-toggle {
background: none;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 4px;
color: white;
cursor: pointer;
padding: 0.25rem 0.5rem;
font-size: 1.25rem;
line-height: 1;
transition:
border-color 0.2s,
background-color 0.2s;
display: flex;
align-items: center;
justify-content: center;
}
.theme-toggle:hover {
border-color: rgba(255, 255, 255, 0.6);
background-color: rgba(255, 255, 255, 0.1);
}
.theme-icon {
display: inline-block;
}
</style>