Buttons allow the user to take actions or make choices. Available in multiple variants, colors, and sizes with reactive state support.
Basic Usage
Standard buttons with default styling.
await import('/components/actions/button.js');
const { tags, $ } = Lightview;
const { div, Button } = tags;
const buttons = div({ style: 'display: flex; gap: 0.5rem;' },
Button({}, 'Default'),
Button({ color: 'primary' }, 'Primary'),
Button({ color: 'secondary' }, 'Secondary')
);
$('#example').content(buttons);
Reactive State
Buttons with built-in loading and state handling.
await import('/components/actions/button.js');
const { signal, tags, $ } = Lightview;
const { div, span, Button } = tags;
const isLoading = signal(false);
const button = div({ style: 'display: flex; gap: 1rem; align-items: center;' },
Button({
color: 'primary',
loading: () => isLoading.value,
onclick: async () => {
isLoading.value = true;
await new Promise(r => setTimeout(r, 2000));
isLoading.value = false;
}
}, 'Save Changes'),
span({ style: 'opacity: 0.7;' },
() => isLoading.value ? '⏳ Saving...' : 'Click to test'
)
);
$('#example').content(button);
Props
| Prop | Type | Default | Description |
|---|---|---|---|
color |
string | - | 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'ghost' | 'link' |
size |
string | 'md' | 'xs' | 'sm' | 'md' | 'lg' |
variant |
string | - | 'outline' | 'soft' | 'dash' | 'wide' | 'block' | 'square' | 'circle' |
disabled |
boolean | function | false | Disable the button (supports reactive function) |
loading |
boolean | function | false | Show loading spinner (supports reactive function) |
active |
boolean | false | Force active/pressed state |
glass |
boolean | false | Glass morphism effect |
noAnimation |
boolean | false | Disable click animation |
Button Gallery
Live examples using <lv-button> custom elements.