Button
Trigger an action or navigate to another page.
Demos
Usage
Import Button from its local folder after installation.
<script setup lang="ts">
import { Button } from '~/components/ui/button'
</script>
<template>
<Button @click="createProject">Create project</Button>
</template>
Variants
Choose solid, soft, subtle, outline, ghost, or link. Primary and accent solid buttons use the tactile material. Secondary and semantic solid buttons use flat fills.
import tailwindcss from '@tailwindcss/vite'
export default defineNuxtConfig({
modules: ['akaza-ui/nuxt', '@nuxt/fonts', '@nuxtjs/color-mode'],
css: ['~/assets/main.css'],
colorMode: { classSuffix: '', preference: 'system', fallback: 'light' },
vite: { plugins: [tailwindcss()] },
})
Colors
Choose primary, secondary, accent, info, success, warning, or destructive. Accent defaults to blue and remains separate from primary and secondary. Soft, subtle, outline, and ghost use matching emphasis text, tints, and borders as defined in Action colors. Use the preview controls to inspect each color with each variant.
<Calendar v-model="dates" selection-mode="range" range-color="accent" />
<DateRangePicker v-model="dates" range-color="secondary" />
<MonthRangePicker v-model="months" range-color="accent" />
<YearRangePicker v-model="years" range-color="secondary" />
Sizes
Each size changes the control geometry, typography, padding, radius, icon size, and gap. Values below use a 16px browser root and the default 10px radius token. The shared geometry profiles define the control scale.
On coarse-pointer devices, buttons have a 44px minimum height and width for touch interaction.
| Size | Height | Padding X / Y | Text / line height | Radius | Icon | Gap |
|---|---|---|---|---|---|---|
| xs | 24px | 8px / 2px | 12px / 16px | 5px | 12px | 4px |
| sm | 28px | 10px / 4px | 13px / 16px | 6px | 14px | 4px |
| md | 32px | 12px / 4px | 14px / 20px | 8px | 16px | 6px |
| lg | 36px | 14px / 6px | 14px / 20px | 10px | 18px | 8px |
| xl | 40px | 16px / 6px | 16px / 24px | 12px | 20px | 10px |
Icon buttons
Use shape="icon" with any size. The width matches the height and horizontal padding becomes zero. Give the button an accessible name with aria-label.
Disabled and loading
Use disabled to block an action and loading to control a pending state. With loading-auto, return a Promise from the click handler. Akaza blocks duplicate activation until that Promise settles.
The default loading slot keeps the label's width and overlays the spinner. Provide #loading to replace the indicator. This demo waits one second; it does not send data.
<Button loading-auto @click="saveChanges">Save changes</Button>
Overrides
Use class for the root and ui for root, content, spinner, or loadingText. Consumer classes take priority through cn.
Links
Pass as="a" and href to use Akaza's alternate root. For Nuxt routing, pass the resolved NuxtLink component through as. Akaza gives alternate roots button keyboard behavior, including Space activation.
Installation
Complete the shared installation. Copy Button.vue and index.ts into app/components/ui/button/.
<script setup lang="ts">
import { Button as ButtonPrimitive } from 'akaza-ui'
import { computed, useAttrs } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import { buttonVariants, resolveButtonVariants, type ButtonProps } from './index'
defineOptions({ inheritAttrs: false })
const props = defineProps<ButtonProps>()
const attrs = useAttrs()
const styles = computed(() => buttonVariants(resolveButtonVariants(props, uiConfig)))
const primitiveProps = computed(() => {
const {
color: _color,
variant: _variant,
size: _size,
shape: _shape,
class: _class,
ui: _ui,
...primitive
} = props
return primitive
})
</script>
<template>
<ButtonPrimitive
v-bind="{ ...primitiveProps, ...attrs }"
data-slot="button"
:class="cn(styles.root(), props.ui?.root, props.class)"
:ui="{
spinner: cn(styles.spinner(), props.ui?.spinner),
loadingText: cn(styles.loadingText(), props.ui?.loadingText),
}"
>
<span :class="cn(styles.content(), props.ui?.content)"><slot /></span>
<template #loading>
<span class="grid items-center justify-items-center">
<span
aria-hidden="true"
:class="cn(styles.content(), 'invisible col-start-1 row-start-1', props.ui?.content)"
><slot
/></span>
<span class="col-start-1 row-start-1 inline-flex items-center justify-center">
<slot name="loading">
<svg
:class="cn(styles.spinner(), props.ui?.spinner)"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
aria-hidden="true"
>
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
<span :class="cn(styles.loadingText(), props.ui?.loadingText)">Loading</span>
</slot>
</span>
</span>
</template>
</ButtonPrimitive>
</template>
API
Props
| Prop | Values | Fallback |
|---|---|---|
| color | primary, secondary, accent, info, success, warning, destructive | primary |
| variant | solid, soft, subtle, outline, ghost, link | solid |
| size | xs, sm, md, lg, xl | sm |
| shape | default, icon | default |
| as | HTML tag or Vue component | button |
| type | button, submit, reset | button |
| disabled | boolean | false |
| loading | boolean | false |
| loadingAuto | boolean | false |
| focusableWhenDisabled | boolean | false |
| ui | Classes for root, content, spinner, loadingText | none |
Use the default slot for content and #loading for custom loading content. Native attributes and event handlers pass through to Akaza's root. Akaza owns keyboard activation, loading state, and disabled behavior.