Skip to content

BbButton

Button with loading state, tooltip, and icon support.

import { BbButton } from 'bitboss-ui';

On this page

Props

NameTypeDefaultDescription
activeClassstring | undefined-

Class to apply when the link is active.

append:iconstring | undefined-

Icon to be added on the right of the text.

See example
ariaCurrentValue"page" | "step" | "location" | "date" | "time" | "true" | "false" | undefined'page'

Value passed to the attribute aria-current when the link is exact active.

asyncboolean | undefinedfalse

Inertia: runs the visit without blocking — the page stays interactive and several async visits can be in flight at once.

blockboolean | undefinedfalse

Displays the component as full width.

See example
cacheForstring | number | (string | number)[] | undefined-

Inertia: how long a prefetched response stays fresh before it is re-fetched. A single duration, or [staleAfter, expiresAfter]. Typed platform-agnostically (matching BbButton) so the library's types never require @inertiajs/vue3 to be installed.

cacheTagsstring | string[] | undefined-

Inertia: tags to file this visit's prefetch cache under, so a later request can invalidate the whole tagged group.

componentstring | undefined-

Inertia: the page component this visit resolves to. Rarely set by hand — the server normally decides it.

dataobject | undefined-
disableAutoLoadingboolean | undefinedfalse

Disables the automatic loading state that tracks async click handlers (enabled by default).

Use only when an async click should intentionally remain interactive without automatic pending state.

See example
disabledboolean | undefinedfalse

Disables the component: native disabled (or aria-disabled on a link), muted paint. Beside loading, loading wins the look (spinner and variant colours) and this only adds the native blocking — redundant but harmless.

downloadstring | boolean | undefined-

Marks an href link as a download: renders a plain <a download> doing a native navigation (never an Inertia/router visit), so file downloads work. Pass a string for the suggested filename. A native-anchor signal alongside target and external.

exactActiveClassstring | undefined-

Class to apply when the link is exact active.

exceptstring[] | undefined-

Inertia: the inverse of only — properties to EXCLUDE from a partial reload. Pass one or the other, not both.

externalboolean | undefinedfalse

Forces an href link to render as a plain <a> (native navigation), bypassing Inertia/router interception — same intent as Nuxt's external. A native-anchor signal alongside target and download.

falseValueanyfalse

Value emitted when the toggle is deactivated.

See example
groupboolean | undefinedfalse

Identifies the button as part of a button group.

See example
headersobject | undefined-
hrefstring | undefined-

Returns the hyperlink's URL. Can be set, to change the URL.

Use for a destination, not an action. The rendered link keeps browser navigation behaviour.

See example
iconstring | undefined-

Used when only an icon with no text should be displayed.

Slot content becomes the visually hidden accessible name. Do not ship an icon-only button without slot text or an explicit aria-label.

See example
instantboolean | undefinedfalse

Inertia: navigate optimistically on click and reconcile when the response lands, instead of waiting for the round trip.

interactiveWhileLoadingboolean | undefinedfalse

Keeps the button clickable while it is loading. Buttons are disabled while loading by default; this escape hatch exists for toggles that must stay interactive (e.g. the dropdown-button caret).

loadingboolean | undefinedfalse

Triggers a loading indicator. A loading button is soft-disabled on its own (aria-disabled, out of the tab order, clicks and navigation blocked) and keeps its variant colours; with disabled set too, loading still wins the look.

Bind this when pending state is owned outside the click handler, such as a form or store request.

See example
method"get" | "post" | "put" | "patch" | "delete" | undefined-
modelValueany-
onBefore(() => void) | undefined-
onCancel(() => void) | undefined-
onCancelToken((cancelToken: unknown) => void) | undefined-
onError((errors: Record<string, string>) => void) | undefined-

Lifecycle hook invoked by Inertia when the server responds with VALIDATION errors — the ordinary 422 path. This is the only failure callback Inertia's Link accepts. onHttpException (server answered 5xx) and onNetworkError (the request never arrived) are router.visit() / useForm() options, NOT Link props — declaring them here would only paste bogus listeners onto the anchor. Use a form or an explicit visit when you need to tell them apart.

onFinish(() => void) | undefined-
onlystring[] | undefined-
onPrefetched(() => void) | undefined-

Lifecycle hook invoked by Inertia when a prefetch for this link has completed and is cached.

onPrefetching(() => void) | undefined-

Lifecycle hook invoked by Inertia when a prefetch for this link starts.

onProgress((progress: { percentage: number | undefined; }) => void) | undefined-
onStart(() => void) | undefined-
onSuccess(() => void) | undefined-
pagePropsRecord<string, unknown> | ((currentProps: Record<string, unknown>, sharedProps: Record<string, unknown>) => Record<string, unknown>) | null | undefined-

Inertia: props to merge into the next page optimistically, before the server responds. Either an object or a function of the current props. Typed platform-agnostically (matching BbButton) so the library's types never require @inertiajs/vue3 to be installed.

prefetchstring | boolean | string[] | undefined-

Inertia: fetch and cache this link's page ahead of the click. true uses the default trigger; a string or list of strings picks them ('mount', 'hover', 'click').

prepend:iconstring | undefined-

Icon to be added on the left of the text.

See example
preserveScrollboolean | ((props: Record<string, unknown>) => boolean) | undefined-
preserveStateboolean | ((props: Record<string, unknown>) => boolean) | null | undefined-
preserveUrlboolean | undefinedfalse

Inertia: keep the current URL in the address bar even though the page content changes.

ptPtMap<BbButtonPtPart, BbButtonPtState> | undefined-

Passthrough, object form: { icon: '…', 'icon:loading': '…' } — the same keys as the pt:* attributes without the prefix. Parts: root, icon, spinner, text. States: loading, disabled.

pt:iconPtValue | undefined-
pt:icon:disabledPtValue | undefined-
pt:icon:loadingPtValue | undefined-
pt:rootPtValue | undefined-
pt:root:disabledPtValue | undefined-
pt:root:loadingPtValue | undefined-
pt:spinnerPtValue | undefined-
pt:spinner:disabledPtValue | undefined-
pt:spinner:loadingPtValue | undefined-
pt:textPtValue | undefined-
pt:text:disabledPtValue | undefined-
pt:text:loadingPtValue | undefined-
queryStringArrayFormat"brackets" | "indices" | undefined-
replaceboolean | undefinedfalse

Calls router.replace instead of router.push.

sizeResponsive<Sizes> | undefined"md"

Sets the size of the button. A single value applies at every breakpoint; a per-breakpoint map (e.g. { default: 'sm', lg: 'md' }) switches responsively. Purely CSS-driven — no runtime breakpoint watching.

See example
tagButtonTag | undefined'button'

Element to render for the plain (non-link, non-router) button: 'button' (default), 'div'/'span' when nesting inside another button or link, or 'label' for a file-upload trigger. Ignored when href/to make the button render as a link.

targetstring | undefined-

Sets or retrieves the window or frame at which to target content.

textstring | undefined-

Text content of the component.

tostring | wt | bt | undefined-

Route Location the link should navigate to when clicked on.

Use for internal Vue Router or Nuxt navigation instead of calling the router from @click.

See example
trueValueanytrue

Value emitted when the toggle is activated.

See example
type"button" | "submit" | "reset" | undefined-

Gets the classification and default behavior of the button.

Defaults to button. Set submit only when the surrounding form owns the action.

See example
variantButtonVariantType | undefined"primary"

Visual variant of the button. Controls colors and surface style while keeping spacing and sizing unchanged.

Choose by hierarchy, not colour. Register recurring project variants; use BbBaseButton for a completely custom primitive.

See example
viewTransitionboolean | undefinedfalse

Inertia: run the page swap inside a View Transition, where the browser supports one.

v-model

Values kept in sync through v-model.

NameTypeDescription
modelValueanySee example

Events

NameTypeDescription
update:modelValue(event: "update:modelValue", value: any): void

Slots

The listed properties are the ones exposed to the slot scope.

NameTypeDescription
defaultobject

Primary content rendered inside the button. Falls back to the text prop when empty.

The visible label, or the accessible name when icon makes the text visually hidden.

See example

Changes from v2

Props removed or renamed in 3.0. If you are coming from v2, the answer is here.

  • enabledWhileLoadinginteractiveWhileLoadingfails silently
  • themeremovedfails silently
  • tooltipremovedfails silently
  • tooltipPlacementremovedfails silently
  • tooltipTimeoutremovedfails silently