Home / Docs / Buttons & Elements
Components / Elements
View Source

Buttons, Badges, Trees & Visual Elements

Accessible action triggers, button groups, code diff viewers, avatars, presence indicators, keyboard shortcuts, status chips, hierarchical trees, progress meters, and skeletons.

Button Variants

Button Sizes & Loading States

Triggers 2s async spinner

ButtonGroup & Native Icons

Badges & Pulsing Radar Chips

Primary Operational Degraded Outage Beta
Live Deploy
Connected
High Load
Offline

Avatars, Presence & AvatarGroup Stacks

SA
AL
MA
OF
EL
DA
SO
+3
XS
SM
MD
LG

Keyboard Key Badges (Kbd)

Command Palette:
⌘ K
Save Changes:
Ctrl S
Multi-size: XS SM MD LG

Progress Bars & Status Meters

Storage Quota 68%
API Rate Limit (Requests / min) 84%
System Health 99%

Enhanced Skeleton Loaders (Shimmer, Multi-Line & Shapes)

Multi-Line Paragraph Stagger

UI Drag & Drop Reordering (<SortableList />)

Drag items by handle to reorder, or use keyboard arrow buttons:

Design user onboarding flow UI
Set up Polar.sh subscription webhook Billing
Configure Drizzle ORM migrations Database
Deploy static site to Cloudflare Pages DevOps

Zero-WASM Syntax-Highlighted <CodeBlock /> (Multi-Language)

src/routes/demo/+page.svelte
svelte
1<script lang="ts">
2 import { Button, CodeBlock, useLocale } from 'yaxa-svelte';
3 const { formatCurrency } = useLocale();
4 let count = $state(0);
5</script>
6
7<div class="space-y-4">
8 <p>Price: {formatCurrency(49.99, 'USD')}</p>
9 <Button color="primary" onclick={() => count++}>
10 Clicks: {count}
11 </Button>
12</div>
equations.tex
latex
1% Euler's Identity & Gaussian Integral
2\[ e^{i\pi} + 1 = 0 \]
3\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}
4
5% Quadratic Formula
6x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
Counter.vue
vue
1<template>
2 <div class="counter-card">
3 <h2>{{ title }}</h2>
4 <button @click="increment" :disabled="isLoading">
5 Count: {{ count }}
6 </button>
7 </div>
8</template>
9
10<script setup lang="ts">
11import { ref } from 'vue';
12const count = ref(0);
13const increment = () => count.value++;
14</script>
Metric.tsx
tsx
1import React, { useState, useEffect } from 'react';
2
3interface MetricProps {
4 label: string;
5 initialValue?: number;
6}
7
8export const Metric: React.FC<MetricProps> = ({ label, initialValue = 0 }) => {
9 const [val, setVal] = useState(initialValue);
10 return (
11 <div className="metric-pill" onClick={() => setVal(v => v + 1)}>
12 <span>{label}</span>
13 <strong>{val}</strong>
14 </div>
15 );
16};

Interactive Code Diff & Changelog (<CodeDiff />)

Counter.svelte
+7 -9
1
-// Svelte 4 Legacy Syntax
2
-<script>
3
- export let data;
4
- let count = 0;
5
- function increment() {
6
- count += 1;
7
- }
1
+// Svelte 5 Modern Runes
2
+<script lang="ts">
3
+ import { Button } from 'yaxa-svelte';
4
+ let { data } = $props();
5
+ let count = $state(0);
8 6
${'<'}/script>
9 7
10
-<button on:click={increment}>
8
+<Button onclick={() => count++} color="primary">
11 9
Count: {count}
12
-</button>
10
+</Button>

MetricCard (Zero-Dep SVG Sparkline Trend Card)

Total Users
8,924
+12.5% vs last month
Conversion
3.42%
-0.8% vs last week

Hierarchical Tree Explorer (<Tree />)

File Tree page-svelte

Button Props & API Reference

14 Props

Props, variants, semantic colors, and snippet slots supported by the <Button /> primitive.

PropertyType DefinitionDefaultDescription
variant
'solid'| 'outline'| 'soft'| 'subtle'| 'ghost'| 'link'
'solid'Visual styling preset determining background, border, and elevation.
color
'primary'| 'neutral'| 'success'| 'warning'| 'error'| 'info'
'primary'Semantic theme palette applied to background, text, and focus ring.
size
'xs'| 'sm'| 'md'| 'lg'| 'xl'
'md'Button size, typography scale, padding, and icon gap.
icon
IconSource
undefinedLeading icon name (e.g. "bolt", "plus") or custom Svelte component.
trailingIcon
IconSource
undefinedTrailing icon name (e.g. "arrow-right", "chevron-down") or custom component.
loading
boolean
falseReplaces lead icon with an animated SVG spinner and disables interaction.
disabled
boolean
falseDisables user click events, keyboard focus, and applies opacity reduction.
href
string
undefinedWhen provided, automatically renders an accessible HTML <a> anchor tag.
as
'button'| 'a'| 'span'| 'div'
'button'Custom underlying HTML tag to prevent invalid nested button markup.
block
boolean
falseIf true, stretches button width to 100% of parent container.
square
boolean
falseApplies 1:1 aspect-ratio and removes horizontal padding for icon-only buttons.
leading
Snippet
undefinedCustom Svelte 5 snippet slot rendered before button text content.
trailing
Snippet
undefinedCustom Svelte 5 snippet slot rendered after button text content.
children
Snippet
undefinedMain default snippet slot for button label and nested elements.