Button
Usage
Label
Use the label prop to set the text of the button. The default slot replaces it.
<KButton label="Button" />
Variant
Use the variant prop to change the look of the button: solid (default), soft, outline or ghost.
<KButton label="Solid" />
<KButton label="Soft" variant="soft" />
<KButton label="Outline" variant="outline" />
<KButton label="Ghost" variant="ghost" />
Color
Use the color prop to change the color of the button: primary, secondary, neutral (default), gray or danger.
<KButton label="Save" color="primary" />
<KButton label="Edit" color="secondary" />
<KButton label="Submit" />
<KButton label="Cancel" color="gray" />
<KButton label="Delete" color="danger" />
Size
Use the size prop to change the size of the button, from 3xs to 4xl. The default is md.
<KButton label="3xs" size="3xs" />
<KButton label="md" size="md" />
<KButton label="4xl" size="4xl" />
Pill
Buttons are pills by default. Set pill to false to get rounded corners that follow the size.
<KButton label="Pill" />
<KButton label="Rounded" :pill="false" />
Icon
Use the leading-icon and trailing-icon props to show an icon before or after the label. They take a Lucide icon component.
<script setup lang="ts">
import { ArrowLeftRight, ArrowRight, Trash2 } from 'lucide-vue-next'
</script>
<template>
<KButton label="Delete" color="danger" :leading-icon="Trash2" />
<KButton label="Next" variant="outline" :trailing-icon="ArrowRight" />
<KButton label="Compare" variant="ghost" :leading-icon="ArrowLeftRight" />
</template>
Square
Use the square prop for an icon-only button. The label is still required: it becomes the accessible name of the button.
<script setup lang="ts">
import { Bell, Plus, Trash2, X } from 'lucide-vue-next'
</script>
<template>
<KButton label="Add account" square :leading-icon="Plus" />
<KButton label="Delete" color="danger" square :pill="false" :leading-icon="Trash2" />
<KButton label="Close" variant="ghost" color="gray" square :leading-icon="X" />
<KButton label="Notifications" variant="outline" size="2xl" square :leading-icon="Bell" />
</template>
Block
Use the block prop to make the button fill the width of its container.
<KButton label="Continue" size="3xl" block />
Link
Use the href prop to render the button as a link.
<KButton label="Read the installation guide" href="/getting-started/installation" variant="outline" />
Loading
Use the loading prop to show a spinner. The button is disabled and announced as busy while it loads.
<KButton label="Saving" loading />
<KButton label="Saving" variant="soft" loading />
Disabled
Use the disabled prop to disable the button. A disabled link loses its href.
<KButton label="Disabled" disabled />
<KButton label="Disabled" variant="outline" disabled />
<KButton label="Disabled" variant="ghost" disabled />
Selected
Use the selected prop to show the button as pressed, for toggles and filters. It sets aria-pressed.
<KButton label="Selected" variant="soft" selected />
<KButton label="Selected" variant="outline" selected />
<KButton label="Selected" variant="ghost" selected />
Customization
Use the ui prop to change the classes of each part of the button, and class for the root element. Your classes always win: rounded-none replaces the default rounded-full instead of being added to it.
<KButton label="Square corners" :ui="{ base: 'rounded-none' }" />
API
Props
| Prop | Type | Default |
|---|---|---|
label | string | |
variant | 'solid' | 'soft' | 'outline' | 'ghost' | 'solid' |
color | 'primary' | 'secondary' | 'neutral' | 'gray' | 'danger' | 'neutral' |
size | '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | 'md' |
leadingIcon | Component | |
trailingIcon | Component | |
square | boolean | false |
pill | boolean | true |
block | boolean | false |
disabled | boolean | false |
loading | boolean | false |
selected | boolean | false |
type | 'button' | 'submit' | 'reset' | 'button' |
href | string | |
ui | { base?, content?, label?, leadingIcon?, trailingIcon?, loadingOverlay?, loadingIndicator? } | |
class | string |
Slots
| Slot | Description |
|---|---|
default | Replaces the label. |