<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
| Prop | Type | Default | Description |
|---|---|---|---|
ui | Record<string, unknown> | {} | Escape hatch: raw uikit (@pmndrs/uikit) properties, merged last. |
iconEnd | boolean | Put the icon after the label instead of before it. | |
disabled | boolean | Greys it out; it does not react to any input. | |
block | boolean | Stretch to the parent's width. | |
variant | XrButtonVariant | 'primary' | Colour role: primary (filled accent), secondary (filled neutral) or ghost (no background). |
size | XrButtonSize | 'md' | Height: sm (the theme's minTarget), md or lg. |
parts | Partial<Record<"label" | "icon", Record<string, unknown>>> | Raw uikit properties per inner part, merged after the defaults: label (the text), icon. | |
label | string | Text on the button. The default slot replaces it. | |
icon | XrIconSource | A Lucide icon node or an <svg> string (see XrIcon), drawn before the label, or alone. |
Events
| Event | Payload | Description |
|---|---|---|
click | event: ControlPointerEvent | Pressed and released on it, with any input. |