vael-ui v0.5.7

Feedback

Layout

Skeleton

A placeholder shape that stands in for content while it loads. Use it when you know the layout before the data arrives.

Install

import { Skeleton } from 'vael-ui'

Playground

Your content, drawn as bones while it loads
Usage
<script setup lang="ts">
import { Skeleton } from 'vael-ui'
</script>

<template>
  <Skeleton>Your content, drawn as bones while it loads</Skeleton>
</template>

Props

NameTypeDefaultDescription
variant'text' | 'rect' | 'circle''text''text': a 1em-tall rounded line. 'circle': round, with aspect-ratio: 1. 'rect': --ui-radius corners; content or ui.root sets its size.
loadingbooleanWraps your content and draws it as bones of itself while true: each line of text a bar, images, icons, avatars, buttons and fields blocks of their own shape, the rest (a card's border and background) as it is. false brings the content in. Unset, it's one shape (variant), as before.
animatedbooleantrueShows the shimmer animation.
motionSkeletonMotionHow it moves: its appearance ({ initial: { root: { opacity: 0 } } }). false turns its appearance and the pulse off.
uiPartial<Record<'root' | 'bone', UiPartValue>>Class and style overrides for each part. bone is each shape drawn while loading.

Events

No events.

Slots

NameTypeDescription
default{ loading: boolean; }With loading, your content; render it with placeholder data while loading is true. Without it, placeholder content that sizes the skeleton, rendered hidden.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Skeleton: its appearance; false holds the pulse still.

<Skeleton
  :motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Always aria-hidden; content in its slot only sizes it and stays hidden.
  • Screen readers get no loading state from it, so mark the region it stands for with aria-busy="true" or add a Loader with a label.
  • Under reduced motion, the pulse runs at half speed.