<script setup>
import { ref } from "vue";
import { Button } from "@dicehub/kappa/components/button";
const message = ref("No action yet");
</script>
<template>
<section class="run-panel">
<div><span>Rotor study · Run 042</span><strong>Ready to submit</strong></div>
<div class="actions">
<Button @click="message = 'Draft saved'">Save draft</Button>
<Button variant="primary" @click="message = 'Run submitted'">Run simulation</Button>
</div>
<output role="status" aria-live="polite">{{ message }}</output>
</section>
</template>Installation
Barrel
import { Button, LinkButton, ToolbarButton } from "@dicehub/kappa";Granular
import { Button, LinkButton, ToolbarButton } from "@dicehub/kappa/components/button";Usage
Use Button for actions and LinkButton for navigation. Button defaults to type="button", preventing accidental form submission.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
function saveCase() {
// Persist the current case.
}
</script>
<template>
<Button variant="primary" @click="saveCase">Save case</Button>
</template>Examples
Basic
Secondary is the default variant. Neutral variants use --kappa-control-hover for the hover fill and --kappa-line-strong for a visible hover border. Popup triggers keep this border while open.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button>Save draft</Button>
</template>Variants
Choose emphasis from the action’s meaning and local hierarchy. A view should rarely need more than one primary action.
Primary
Highest-emphasis action in the local context.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="primary">Primary</Button>
</template>Secondary
Quiet default action for dense workflows.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="secondary">Secondary</Button>
</template>Outline
Neutral action on the surrounding surface.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="outline">Outline</Button>
</template>Ghost
Lowest-emphasis toolbar or contextual action.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="ghost">Ghost</Button>
</template>Destructive
Primary irreversible or dangerous action.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="destructive">Destructive</Button>
</template>Secondary Destructive
Quiet destructive action with red text.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="secondary-destructive">Secondary Destructive</Button>
</template>Destructive Outline
Outlined destructive compatibility treatment.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="destructive-outline">Destructive Outline</Button>
</template>Success
Explicit approval or successful transition.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="success">Success</Button>
</template>Warning
Action that needs caution before continuing.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="warning">Warning</Button>
</template>Link
Inline action styling; use LinkButton when it navigates.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button variant="link">Link</Button>
</template>Sizes
Use compact sizes in toolbars and data-dense controls; use base for standard forms.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button size="xs">Extra small</Button>
<Button size="sm">Small</Button>
<Button size="base">Base</Button>
<Button size="lg">Large</Button>
</template>Toolbar buttons
Use ToolbarButton for compact counters and actions. It shares the native Button behavior, with ghost as the default variant and outline for a visible boundary. The default base size is 32 px high; sm is 24 px high. Both use 16 px icons, 12 px text at weight 500, 8 px corners, and 8 px inline padding for text buttons. An icon without label content gets a square button automatically.
Hover and press use 200 ms color transitions without moving the control. Keyboard focus keeps a visible ring, and reduced-motion settings remove the transitions. Disabled and loading states use the same activation rules as Button.
Set tooltip to show a label below the button after 500 ms. It closes without a delay and stays hidden while the button is disabled, loading, or has an open menu. For an icon-only button, the tooltip also supplies its accessible name unless you setaria-label or aria-labelledby.
Use tooltip-placement="left" for a right-side toolbar or "top" for a bottom toolbar. The default is "bottom". Tooltips use fixed positioning and adjust to viewport edges.
The “+” button opens a Dropdownwith showArrow on its content. The components manage the tooltip and menu together.
<script setup>
import { Download, Layers, Plus, RotateCcw } from "@lucide/vue";
import { ref } from "vue";
import { ToolbarButton } from "@dicehub/kappa/components/button";
import { Dropdown } from "@dicehub/kappa/components/dropdown";
const message = ref("3 result layers · Last saved just now");
</script>
<template>
<div class="toolbar-button-demo" data-button-demo="toolbar">
<header class="toolbar-button-demo__header">
<strong>Results</strong>
<div class="toolbar-button-demo__actions" role="group" aria-label="Result actions">
<Dropdown.Root aria-label="Create item" @select="message = $event.value">
<Dropdown.Trigger as-child>
<ToolbarButton :icon="Plus" tooltip="Create new…" aria-label="Create item" variant="outline" size="sm" />
</Dropdown.Trigger>
<Dropdown.Content show-arrow>
<Dropdown.Group>
<Dropdown.Label>Rotor study</Dropdown.Label>
<Dropdown.Item value="New case selected">New case</Dropdown.Item>
<Dropdown.Item value="New report selected">New report</Dropdown.Item>
</Dropdown.Group>
<Dropdown.Separator />
<Dropdown.Group>
<Dropdown.Label>Workspace</Dropdown.Label>
<Dropdown.Item value="New project selected">New project</Dropdown.Item>
<Dropdown.Item value="Import geometry selected">Import geometry</Dropdown.Item>
</Dropdown.Group>
</Dropdown.Content>
</Dropdown.Root>
<ToolbarButton
:icon="RotateCcw" tooltip="Reset view" data-trace="reset-view"
@click="message = 'View reset'"
/>
<ToolbarButton
:icon="Layers" tooltip="Result layers" aria-label="View 3 result layers"
@click="message = '3 result layers shown'"
>3</ToolbarButton>
<ToolbarButton
:icon="Download" tooltip="Export results" aria-label="Export results"
@click="message = 'Results export selected'"
>Export</ToolbarButton>
</div>
</header>
<output class="toolbar-button-demo__status" role="status" aria-live="polite">{{ message }}</output>
</div>
</template>
<style scoped>
.toolbar-button-demo { display: grid; inline-size: 100%; min-inline-size: 0; gap: 0.75rem; }
.toolbar-button-demo__header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
padding: 0.75rem;
border: 1px solid var(--kappa-line);
border-radius: 0.625rem;
background: var(--kappa-tint);
}
.toolbar-button-demo__header strong { color: var(--kappa-default); font-size: 0.875rem; }
.toolbar-button-demo__actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.25rem;
margin-inline-start: auto;
}
.toolbar-button-demo__status { color: var(--kappa-subtle); font-size: 0.75rem; line-height: 1.5; }
</style>Compose a menu trigger with Dropdown.Trigger as-child, as shown above. Dropdown owns menu state, keyboard navigation, and focus return. Standalone ToolbarButton has native button keyboard behavior. For a group with arrow-key navigation, use Toolbar.Root andToolbar.Button. Inside a Toolbar.Root, the button keeps the group's ghost styling, shared size, and disabled state; standalone size and variant props do not apply.
With Icons
These examples use @lucide/vue, but icon accepts any Vue component. Set iconPosition with logical values so placement follows the reading direction.
pnpm add @lucide/vue<script setup>
import { ArrowRight, Plus } from "@lucide/vue";
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button :icon="Plus">New case</Button>
<Button :icon="ArrowRight" icon-position="inline-end" variant="outline">Export</Button>
</template>Icon-only
Use square or circle geometry and provide aria-label oraria-labelledby; the decorative icon is hidden from assistive technology.
<script setup>
import { Plus, RefreshCw } from "@lucide/vue";
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button :icon="Plus" shape="square" aria-label="Add case" />
<Button :icon="RefreshCw" shape="circle" variant="ghost" aria-label="Refresh runs" />
</template>Loading
Loading preserves the visible label, adds a spinner and aria-busy="true", and blocks duplicate activation.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button loading>Saving case</Button>
<Button variant="primary" loading>Submitting run</Button>
</template>Disabled
Disabled Button uses native disabled semantics. Disabled LinkButton renders a disabled native button so it cannot remain an apparently actionable anchor.
<script setup>
import { Button, LinkButton } from "@dicehub/kappa/components/button";
</script>
<template>
<Button disabled>Save case</Button>
<LinkButton href="/runs/042" disabled>Open run</LinkButton>
</template>Full Width
Use fullWidth for stacked mobile forms and narrow confirmation panels.
<script setup>
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<Button full-width variant="primary">Create project</Button>
</template>Links and asChild
LinkButton renders a real anchor. Use external for safe new-tab links andasChild to compose a router link without coupling Kappa to a router. The child owns its icon markup; when disabled, Kappa unwraps its label into a native disabled button.
<script setup>
import { RouterLink } from "vue-router";
import { LinkButton } from "@dicehub/kappa/components/button";
</script>
<template>
<LinkButton href="/runs">View runs</LinkButton>
<LinkButton href="https://dicehub.com" external>dicehub website</LinkButton>
<LinkButton as-child disabled>
<RouterLink to="/unavailable">Unavailable run</RouterLink>
</LinkButton>
<LinkButton as-child>
<RouterLink to="/projects">Open projects</RouterLink>
</LinkButton>
</template>Native Forms
Opt into native submit or reset behavior with the type prop.
<script setup>
import { ref } from "vue";
import { Button } from "@dicehub/kappa/components/button";
const message = ref("Ready");
</script>
<template>
<form aria-label="Case action form" @submit.prevent="message = 'Submitted'" @reset="message = 'Reset'">
<input name="case" value="Rotor study" />
<Button type="submit">Submit</Button>
<Button type="reset" variant="ghost">Reset</Button>
<output role="status" aria-live="polite">{{ message }}</output>
</form>
</template>Right-to-left
Logical icon positions preserve the intended leading and trailing relationships in RTL.
<script setup>
import { ArrowLeft, Plus } from "@lucide/vue";
import { Button } from "@dicehub/kappa/components/button";
</script>
<template>
<div dir="rtl">
<Button :icon="Plus">حالة جديدة</Button>
<Button :icon="ArrowLeft" icon-position="inline-end" variant="outline">تصدير</Button>
</div>
</template>Accessibility
- Use Button for actions and LinkButton for navigation; styling does not replace semantics.
- Icon-only controls need a concise accessible name describing the action.
- Loading retains its label, exposes
aria-busy, and prevents repeated activation. - Do not use only color to distinguish destructive, warning, success, or disabled actions.
- Keep visible focus indicators. Native buttons activate with Enter and Space; links activate with Enter.
- A title supplements a concise label; it is not a replacement for an accessible name.
API Reference
Button
Renders a native button and forwards native attributes, ARIA properties, classes, and listeners.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | ButtonVariant | "secondary" | Visual and semantic treatment. |
size | "xs" | "sm" | "base" | "lg" | "base" | Control height, spacing, and icon scale. |
shape | "base" | "square" | "circle" | "base" | Standard text control or icon-only geometry. |
type | "button" | "submit" | "reset" | "button" | Native button behavior, including form submission and reset. |
loading | boolean | false | Shows a spinner, sets aria-busy, and prevents activation. |
disabled | boolean | false | Disables native activation and focus. |
fullWidth | boolean | false | Fills the available inline size. |
icon | Component | — | Decorative icon rendered beside the label. |
iconProps | Record<string, unknown> | — | Attributes forwarded to the icon component. |
iconPosition | "inline-start" | "inline-end" | "inline-start" | Logical icon placement that follows text direction. |
title | string | number | — | Native advisory text; not a replacement for an accessible name. |
LinkButton
Renders an anchor when enabled, a disabled button when unavailable, or merges onto one semantic child when composed.
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | undefined | — | Native anchor destination; omit only when asChild supplies navigation. |
external | boolean | false | Opens in a new tab with a safe rel value. |
disabled | boolean | false | Renders a disabled native button so navigation and activation are unavailable. |
asChild | boolean | false | Merges styling and attributes onto one child link, such as RouterLink. |
icon | Component | — | Decorates native links. With asChild, render the icon inside the child instead. |
iconProps | Record<string, unknown> | — | Attributes forwarded to the native-link icon component. |
iconPosition | "inline-start" | "inline-end" | "inline-start" | Logical native-link icon placement. |
title | string | number | — | Native advisory text; not a replacement for an accessible name. |
variant / size / shape / fullWidth | Button styling props | shared defaults | Shares Button geometry and visual variants. |
ToolbarButton
Shares Button props, its default slot, and native attribute forwarding. These defaults apply outside Toolbar.Root. The named export is also available from @dicehub/kappa/components/toolbar.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "ghost" | "outline" | "ghost" | Quiet action or bordered control. Other Button variants are not supported. |
size | "sm" | "base" | "base" | 24 or 32 pixel height. Both sizes use 16 pixel icons and 12 pixel text. |
shape | "base" | "square" | "circle" | automatic | Square when only the icon prop is present; base with label content. An explicit shape takes priority. |
tooltip | string | — | Optional bottom tooltip with a 500 ms open delay and no close delay. Hidden while disabled, loading, or expanded. Supplies the icon-only accessible name when no explicit name is set. |
tooltipPlacement | TooltipPositioningOptions["placement"] | "bottom" | Preferred tooltip placement. Use left beside a right rail or top above a bottom rail. Viewport collision handling remains enabled. |
Other props / native attributes | ButtonProps | shared defaults | Shares Button type, disabled, loading, fullWidth, icon, iconProps, iconPosition, title, native attributes, and listeners. |
Variant Reference
| Variant | Purpose |
|---|---|
primary | Highest-emphasis action in the local context. |
secondary | Quiet default action for dense workflows. |
outline | Neutral action on the surrounding surface. |
ghost | Lowest-emphasis toolbar or contextual action. |
destructive | Primary irreversible or dangerous action. |
secondary-destructive | Quiet destructive action with red text. |
destructive-outline | Outlined destructive compatibility treatment. |
success | Explicit approval or successful transition. |
warning | Action that needs caution before continuing. |
link | Inline action styling; use LinkButton when it navigates. |
Exports
| Export | Description |
|---|---|
Button | Native action button with complete visual and async states. |
LinkButton | Anchor and router-link composition with Button styling. |
ToolbarButton | Compact native Button preset for toolbar counters and actions. |
ToolbarButtonProps / ToolbarButtonSlots | Standalone and grouped toolbar button Vue contracts. |
ToolbarButtonSize / ToolbarButtonVariant | Restricted standalone toolbar button option unions. |
TOOLBAR_BUTTON_SIZES / TOOLBAR_BUTTON_VARIANTS | Readonly standalone toolbar button option lists. |
TOOLBAR_BUTTON_DEFAULT_SIZE / TOOLBAR_BUTTON_DEFAULT_VARIANT | Standalone defaults: base and ghost. |
isToolbarButtonSize / isToolbarButtonVariant | Runtime guards for standalone toolbar button options. |
resolveToolbarButtonSize / resolveToolbarButtonVariant | Runtime default resolvers for standalone toolbar button options. |
BUTTON_VARIANTS / BUTTON_SIZES / BUTTON_SHAPES | Readonly visual option lists. |
BUTTON_ICON_POSITIONS / BUTTON_TYPES | Readonly logical icon-position and native-type lists. |
BUTTON_DEFAULT_* | Public variant, size, shape, icon-position, and type defaults. |
isButton* | Runtime guards for every public option union. |
resolveButton* | Runtime default resolvers for every public option union. |
ButtonProps / ButtonSlots / LinkButtonProps / LinkButtonSlots | Public Vue contracts. |
ButtonVisualProps | Visual props shared by Button and LinkButton. |
ButtonVariant / ButtonSize / ButtonShape / ButtonIconPosition / ButtonType | Public option unions. |