Skip to content

<XrButton> ​

A button with primary, secondary and ghost variants in three sizes. One click for the mouse, a controller ray, a hand pinch and a fingertip poke.

Usage ​

vue
<XrButton @click="count++">Increment</XrButton>
<XrButton variant="secondary" :disabled="count === 0" @click="count = 0">Reset</XrButton>
<XrButton variant="ghost" size="sm">More</XrButton>

Icons ​

icon takes a Lucide icon node or an SVG string (see XrIcon) and draws it before the label, or after it with icon-end. A button with an icon and no label is round:

vue
<script setup lang="ts">
import { Share2, Trash2 } from 'lucide'
</script>

<template>
  <XrButton :icon="Share2" label="Share" />
  <XrButton :icon="Trash2" variant="ghost" name="delete" />
</template>

API ​

Props ​

PropTypeDefaultDescription
uiRecord<string, unknown>{}Escape hatch: raw uikit (@pmndrs/uikit) properties, merged last.
iconEndbooleanPut the icon after the label instead of before it.
disabledbooleanGreys it out; it does not react to any input.
blockbooleanStretch to the parent's width.
variantXrButtonVariant'primary'Colour role: primary (filled accent), secondary (filled neutral) or ghost (no background).
sizeXrButtonSize'md'Height: sm (the theme's minTarget), md or lg.
partsPartial<Record<"label" | "icon", Record<string, unknown>>>Raw uikit properties per inner part, merged after the defaults: label (the text), icon.
labelstringText on the button. The default slot replaces it.
iconXrIconSourceA Lucide icon node or an <svg> string (see XrIcon), drawn before the label, or alone.

Events ​

EventPayloadDescription
clickevent: ControlPointerEventPressed and released on it, with any input.

MIT License