NpButton

A wrapper around n-button that extends it with throttling and async capabilities.

Basic Usage

The default click event is throttled.

浏览器不支持,请手动复制 basic.en.vue

Async Button

Use the :click prop to replace the original @click event.

浏览器不支持,请手动复制 async.en.vue

Button Types

浏览器不支持,请手动复制 type.en.vue

Props

Props

PropDescriptionTypeDefault
throttle-delayThrottle delay in msnumber350
loading-delayLoading delay in msnumber250
clickClick handler() => Promise<void>-
typeTheme styledefault/primary/warning/success/info/errordefault
propsOther button propsobject -> Button Propsopen in new window

Events

EventDescriptionCallback
clickTriggered on click() => void

Slots

SlotDescription
defaultCustom default content

Types

The component exports the following type definitions:

import type { NpButtonProps } from 'naive-plus'

Global Defaults

Use NpConfigProvider to change the default props globally. Props passed to the component itself always win.

<np-config-provider
  :component-options="{ Button: { type: 'primary', props: { size: 'small' } } }"
>
  <np-button>Button</np-button>
</np-config-provider>

Note: click / onClick belong to the usage behavior and cannot be set globally.