Loading shows an animated indicator for loading states. Multiple types and sizes available.
Basic Example
Different loading types and sizes
await import('/components/data-display/loading.js');
const { tags, $ } = Lightview;
const { div, p, Loading } = tags;
const types = ['spinner', 'dots', 'ring', 'ball', 'bars', 'infinity'];
const loaders = div({ style: 'display: flex; flex-wrap: wrap; gap: 2rem;' },
...types.map(type =>
div({ style: 'text-align: center;' },
Loading({ type, size: 'lg' }),
p({ style: 'font-size: 0.875rem; margin-top: 0.5rem; opacity: 0.5;' }, type)
)
)
);
$('#example').content(loaders);
Loading Button
Button with reactive loading state
await import('/components/data-display/loading.js');
await import('/components/actions/button.js');
const { signal, tags, $ } = Lightview;
const { div, span, Loading, Button } = tags;
const isLoading = signal(false);
const handleClick = async () => {
isLoading.value = true;
await new Promise(r => setTimeout(r, 2000));
isLoading.value = false;
};
const demo = div({ style: 'display: flex; gap: 1rem; align-items: center;' },
() => isLoading.value
? Button({ color: 'primary', disabled: true },
Loading({ type: 'spinner', size: 'sm' }),
span({}, ' Processing...')
)
: Button({ color: 'primary', onclick: handleClick }, 'Submit'),
span({ style: 'font-size: 0.875rem; opacity: 0.7;' },
() => isLoading.value ? 'Please wait...' : 'Click the button'
)
);
$('#example').content(demo);
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type |
string | 'spinner' | 'spinner' | 'dots' | 'ring' | 'ball' | 'bars' | 'infinity' |
size |
string | 'md' | 'xs' | 'sm' | 'md' | 'lg' |
color |
string | - | Color utility class e.g. 'text-primary' |
Loading Gallery
Live examples using <lv-loading> custom elements.
All Types
spinner
dots
ring
ball
bars
infinity
All Sizes
xs
sm
md
lg