Skip to content

BbButton

Button with loading state, tooltip, and icon support.

import { BbButton } from 'bitboss-ui';

On this page

Props

NameDescription
activeClass Type: string

Class to apply when the link is active.

append:icon Type: string

Icon to be added on the right of the text.

See example
ariaCurrentValue Type: "time" | "true" | "false" | "page" | "step" | "location" | "date"Default'page'

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

async Type: booleanDefaultfalse

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

block Type: boolean

Displays the component as full width.

See example
cacheFor Type: string | number | (string | number)[]

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.

cacheTags Type: string | string[]

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

component Type: string

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

data Type: object

Request payload forwarded to Inertia when navigating via href in an Inertia-enabled app. Ignored when not using Inertia.

disableAutoLoading Type: booleanDefaultcomponents.BbButton.disableAutoLoading, else false

Disables the spinners the button starts on its own (an async click handler's, a submit button's while its BbForm saves); only loading shows one then. Unset: the components map (a scope's, then the app's); false turns them back on here.

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

See example
disabled Type: booleanDefaultfalse

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.

download Type: string | boolean

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.

See example
exactActiveClass Type: string

Class to apply when the link is exact active.

except Type: string[]

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

external Type: booleanDefaultfalse

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.

See example
falseValue Type: anyDefaultfalse

Value emitted when the toggle is deactivated.

See example
group Type: booleanDefaultfalse

Identifies the button as part of a button group: adjacent group buttons fuse into one segment (shared borders and radius). Adjacent group toggles (each with a v-model) are also one Tab stop, with ArrowLeft / ArrowRight / Home / End moving between them.

See example
headers Type: object

Additional HTTP headers forwarded to Inertia when navigating via href in an Inertia-enabled app.

href Type: string | { url: string; method: "get" | "post" | "put" | "patch" | "delete"; }

The link target: renders an anchor (an Inertia <Link> under Inertia). Also takes Inertia's { url, method }, a Wayfinder route: Inertia visits with its method; elsewhere the link is its url.

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

See example
iconOnly Type: Responsive<boolean>

Shows only the button's icon (prepend:icon when it has both); the label is hidden but stays its accessible name, so always write it. true, or per breakpoint: { default: true, md: false }.

Keep writing the label: it becomes the visually hidden accessible name. An icon-only button without a label or an explicit aria-label is an error for bitboss-ui check and the ESLint rule bitboss-ui/require-accessible-name.

See example
instant Type: booleanDefaultfalse

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

interactiveWhileLoading Type: booleanDefaultfalse

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).

loading Type: booleanDefaultfalse

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 Type: "get" | "post" | "put" | "patch" | "delete"

HTTP method used for Inertia navigation when href is provided in an Inertia-enabled app. Ignored otherwise.

Only with href in an Inertia app. A to link is a router link and sends no method; the ESLint rule bitboss-ui/require-partner-prop flags method without href.

modelValue Type: any

Makes the button a toggle: clicking flips the model between trueValue and falseValue, and the button reports aria-pressed. Leave it unbound for a plain button.

onBefore Type: (() => void)

Lifecycle hook invoked by Inertia right before the request is sent.

onCancel Type: (() => void)

Lifecycle hook invoked by Inertia when a request is cancelled.

onCancelToken Type: ((cancelToken: unknown) => void)

Receives the Inertia cancel token source when a request is initiated. Can be used to cancel the request. Typed platform-agnostically (matching BbButton) so the library's types never require @inertiajs/vue3 to be installed.

onError Type: ((errors: Record<string, string>) => void)

Inertia's hook for a VALIDATION error answer (the 422 path): the only failure callback Link accepts. onHttpException (5xx) and onNetworkError are router.visit() / useForm() options, never Link props.

onFinish Type: (() => void)

Lifecycle hook invoked by Inertia after the request has finished (regardless of success or error).

only Type: string[]

Limits the properties that are preserved in Inertia partial reloads.

onPrefetched Type: (() => void)

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

onPrefetching Type: (() => void)

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

onProgress Type: ((progress: { percentage: number | undefined; }) => void)

Progress callback invoked by Inertia with the upload/download percentage when available.

onStart Type: (() => void)

Lifecycle hook invoked by Inertia when a request starts.

onSuccess Type: (() => void)

Lifecycle hook invoked by Inertia when a request succeeds.

pageProps Type: Record<string, unknown> | ((currentProps: Record<string, unknown>, sharedProps: Record<string, unknown>) => Record<string, unknown>) | null

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.

prefetch Type: string | boolean | string[]

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:icon Type: string

Icon to be added on the left of the text.

See example
preserveScroll Type: boolean | ((props: Record<string, unknown>) => boolean)Defaultfalse

Controls whether Inertia should preserve the current scroll position after navigation. Can be a boolean or a predicate receiving the visit props.

preserveState Type: boolean | ((props: Record<string, unknown>) => boolean) | nullDefaultfalse

Controls whether Inertia should preserve the current state after navigation. Can be a boolean or a predicate receiving the visit props.

preserveUrl Type: booleanDefaultfalse

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

pt Type: (PtCompoundOf<"", { readonly parts: readonly ["root", "icon", "spinner", "text"]; readonly states: readonly ["activeLink", "exactActiveLink", "pressed", "disabled", "loading"]; readonly wide: readonly ["activeLink", "exactActiveLink", "pressed", "disabled", "loading"]; readonly variant: { readonly names: readonly ["primary", "outline", "secondary", "ghost", "destructive", "link"]; readonly option: "buttonVariants"; }; }> & PtMap<BbButtonPtPart, "link" | "disabled" | "outline" | "primary" | "destructive" | "loading" | "activeLink" | "exactActiveLink" | "secondary" | "pressed" | "ghost">)

Passthrough, object form: { icon: '…', 'icon:loading': '…' } — the same keys as the pt:* attributes without the prefix. Parts: root, icon, spinner, text. States: loading, disabled, pressed, and the registered variants (an app's own included).

pt:<part> Type: PtValue

Passthrough, attribute form: one attribute per part, pt:<part>, and per part and state, pt:<part>:<state>. Parts: icon, root, spinner, text. States: activeLink, destructive, disabled, exactActiveLink, ghost, link, loading, outline, pressed, primary, secondary.

See example
queryStringArrayFormat Type: "brackets" | "indices"Default'brackets'

Format to use when serializing array values into the query string for Inertia requests.

replace Type: booleanDefaultfalse

Calls router.replace instead of router.push.

size Type: Responsive<Sizes>Defaultcomponents.BbButton.size, else '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. Unset: the components map (the nearest config scope's, then the app's).

See example
tag Type: ButtonTagDefault'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.

target Type: string

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

See example
text Type: string

Text content of the component.

to Type: string | et | X

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
trueValue Type: anyDefaulttrue

Value emitted when the toggle is activated.

See example
type Type: "button" | "reset" | "submit"

Gets the classification and default behavior of the button.

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

See example
variant Type: ButtonVariantTypeDefaultcomponents.BbButton.variant, else 'primary'

Visual variant: colours and surface only, never spacing or size. 'none' takes no look (you own hover, focus and disabled); register a real one with components.BbButton.variants and style .bb-button--<name>. Unset: the the components map (a scope's, then the app's).

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

See example
viewTransition Type: booleanDefaultfalse

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

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: any

Binding it is what makes the button a toggle, with aria-pressed and the bb-button--active class. A hand-bound aria-pressed is ignored, with a development warning.

See example

Events

NameDescription
update:modelValue Type: (value: any): void

Emitted with the new value whenever v-model changes.

Slots

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

NameDescription
append:icon Type: BbButtonIconSlotProps

The trailing icon, replacing append:icon; inside the icon part.

default Type: BbLinkSlotProps

Primary content rendered inside the button. Falls back to the text prop when empty. A link's slot gets { activeLink, exactActiveLink }: whether it points at the current page (both false on a button).

The visible label, or the accessible name when icon-only hides the text visually.

See example
prepend:icon Type: BbButtonIconSlotProps

The leading icon, replacing prepend:icon (the one icon-only shows). Renders inside the icon part: pt:icon, --icon-size and the loading spinner apply.

Exposed methods

NameDescription
$el Type: HTMLElement

Renamed and removed

Names from v2 and from earlier 3.0 betas that no longer work, and what to write instead.

  • enabledWhileLoadinginteractiveWhileLoadingfails silently
  • iconprepend:iconfails silently

    An icon-only button: prepend:icon="…" icon-only, and write the label (the slot or text): it stays the accessible name.

  • sloticonprepend:iconfails silently

    An icon-only button: #prepend:icon with icon-only.

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