UNPKG

@nuxt/devtools-ui-kit

Version:

<a href="https://www.npmjs.com/package/@nuxt/devtools-ui-kit"><img src="https://flat.badgen.net/npm/v/@nuxt/devtools-ui-kit"></a>

41 lines (40 loc) 1.1 kB
import { NuxtLink } from "#components"; import { defineComponent, h, renderSlot } from "vue"; import NIcon from "./NIcon.vue"; export default defineComponent({ name: "NButton", props: { to: String, icon: String, border: { type: Boolean, default: true }, disabled: Boolean, type: { type: String, default: "button" } }, setup(props, { attrs, slots }) { return () => h(props.to ? NuxtLink : "button", { to: props.to, ...attrs, ...!props.to && { type: props.type }, ...props.disabled ? { disabled: true } : { tabindex: 0 }, class: [ props.border ? "n-button-base active:n-button-active focus-visible:n-focus-base hover:n-button-hover" : "", slots.default ? "" : "n-icon-button", "n-button n-transition n-disabled:n-disabled" ].join(" ") }, [ renderSlot(slots, "icon", {}, () => props.icon ? [ h(NIcon, { icon: props.icon, class: slots.default ? "n-button-icon" : "" }) ] : []), renderSlot(slots, "default") ]); } });