59 lines
1.4 KiB
Vue
59 lines
1.4 KiB
Vue
<script setup lang="ts">
|
|
import { defineComponent, h, type PropType } from "vue";
|
|
import { Button, buttonVariants, tv } from "@heroui-vue/components";
|
|
const myButtonVariants = tv({
|
|
extend: buttonVariants,
|
|
base: "text-base font-semibold shadow-md text-shadow-lg data-[pending=true]:opacity-40",
|
|
variants: {
|
|
variant: {
|
|
primary:
|
|
"text-white dark:bg-white/10 dark:text-white dark:hover:bg-white/15",
|
|
},
|
|
radius: {
|
|
full: "rounded-full",
|
|
lg: "rounded-lg",
|
|
md: "rounded-md",
|
|
sm: "rounded-sm",
|
|
},
|
|
size: {
|
|
sm: "h-10 px-4",
|
|
md: "h-11 px-6",
|
|
lg: "h-12 px-8",
|
|
xl: "h-13 px-10",
|
|
},
|
|
},
|
|
defaultVariants: { radius: "full", size: "md", variant: "primary" },
|
|
});
|
|
const CustomButton = defineComponent({
|
|
inheritAttrs: false,
|
|
props: {
|
|
radius: {
|
|
type: String as PropType<"full" | "lg" | "md" | "sm">,
|
|
default: "full",
|
|
},
|
|
size: {
|
|
type: String as PropType<"sm" | "md" | "lg" | "xl">,
|
|
default: "md",
|
|
},
|
|
},
|
|
setup(props, { attrs, slots }) {
|
|
return () =>
|
|
h(
|
|
Button,
|
|
{
|
|
...attrs,
|
|
class: myButtonVariants({
|
|
radius: props.radius,
|
|
size: props.size,
|
|
class: attrs.class as string,
|
|
}),
|
|
},
|
|
slots,
|
|
);
|
|
},
|
|
});
|
|
</script>
|
|
<template>
|
|
<CustomButton>自定义按钮</CustomButton>
|
|
</template>
|