Files
dcalc/frontendNew/src/components/ui/tabs/Tabs.vue
T
2026-05-11 00:32:03 +08:00

36 lines
719 B
Vue

<script lang="ts">
export const tabsContextKey = Symbol("tabs") as InjectionKey<TabsContextValue>;
</script>
<script setup lang="ts">
import { provide } from "vue";
import type { InjectionKey, Ref } from "vue";
import { cn } from "@/lib/utils";
export interface TabsContextValue {
modelValue: Ref<string>;
setValue: (value: string) => void;
}
const props = defineProps<{
class?: string;
}>();
const modelValue = defineModel<string>({ required: true });
const setValue = (value: string) => {
modelValue.value = value;
};
provide(tabsContextKey, {
modelValue,
setValue,
});
</script>
<template>
<div data-slot="tabs" :class="cn('flex flex-col gap-3', props.class)">
<slot />
</div>
</template>