Skeleton

Lockness UI Component

VIEW

DOCUMENTATION

Skeleton

Animated pulse placeholder component for content loading states. Provides multiple preset variants for common UI patterns.

Installation

bash
deno run -A jsr:@lockness/ui add skeleton

Usage

tsx
import { Skeleton } from '@lockness/ui/components'

// Default skeleton with custom dimensions
<Skeleton class="h-12 w-12" />

// Text skeleton
<Skeleton variant="text" />

// Multiple lines of text
<Skeleton variant="text" lines={3} />

// Heading skeleton
<Skeleton variant="heading" />

// Avatar skeleton
<Skeleton variant="avatar" />

// Button skeleton
<Skeleton variant="button" />

// Image skeleton
<Skeleton variant="image" />

// Card skeleton
<Skeleton variant="card" />

// Without animation
<Skeleton variant="text" animate={false} />

Props

PropTypeDefaultDescription
variantSkeletonVariant'default'Skeleton variant for common shapes
linesnumber1Number of lines (for text variant)
animatebooleantrueWhether to animate the skeleton
classstring-Additional CSS class names
idstring-Element id attribute

Variants

VariantDescriptionDimensions
defaultBase skeleton, requires custom dimensionsSet via class
textSingle or multiple text linesFull width, h-4 per line
headingHeading placeholder75% width, h-8
avatarCircular avatar placeholder48x48px, rounded-full
buttonButton placeholder96x40px
imageImage placeholderFull width, h-48
cardComplete card with header, image, and textFull card layout

CSS Variables

VariableDescription
--skeleton-backgroundBackground color of skeleton elements
--skeleton-border-radiusBorder radius of skeleton elements
--borderBorder color (for card variant)

Examples

Loading Card

tsx
<div class='flex items-center space-x-4'>
    <Skeleton variant='avatar' />
    <div class='space-y-2'>
        <Skeleton variant='heading' class='w-62.5' />
        <Skeleton variant='text' class='w-50' />
    </div>
</div>

Loading Article

tsx
<div class='space-y-4'>
    <Skeleton variant='heading' />
    <Skeleton variant='text' lines={4} />
    <Skeleton variant='image' />
    <Skeleton variant='text' lines={3} />
</div>

Loading Table Row

tsx
<div class='flex space-x-4'>
    <Skeleton class='h-4 w-25' />
    <Skeleton class='h-4 w-37.5' />
    <Skeleton class='h-4 w-20' />
</div>

Features

  • Animated pulse - Smooth CSS animation for loading indication
  • Multiple variants - Pre-built shapes for common UI patterns
  • Multi-line text - Support for multiple text lines with varying widths
  • Disable animation - Option to turn off animation
  • Themeable - Uses CSS variables for styling

DEFAULT SKELETON

tsx
import { Skeleton } from '@lockness/ui/components'

<Skeleton class="h-12 w-48" />

TEXT SKELETON

Single line:

Multiple lines:

tsx
import { Skeleton, SkeletonText } from '@lockness/ui/components'

// Single line
<Skeleton variant="text" />

// Multiple lines
<SkeletonText lines={3} />

// Or use the variant prop
<Skeleton variant="text" lines={3} />

HEADING SKELETON

tsx
<Skeleton variant="heading" />

AVATAR SKELETON

tsx
import { SkeletonAvatar } from '@lockness/ui/components'

<div class="flex items-center space-x-4">
    <SkeletonAvatar />
    <div class="space-y-2 flex-1">
        <Skeleton variant="text" />
        <Skeleton variant="text" class="w-4/5" />
    </div>
</div>

BUTTON SKELETON

tsx
<Skeleton variant="button" />
<Skeleton variant="button" class="w-32" />
<Skeleton variant="button" class="w-full" />

IMAGE SKELETON

tsx
<Skeleton variant="image" />

CARD SKELETON

tsx
import { SkeletonCard } from '@lockness/ui/components'

<div class="grid md:grid-cols-3 gap-4">
    <SkeletonCard />
    <SkeletonCard />
    <SkeletonCard />
</div>

WITHOUT ANIMATION

tsx
<Skeleton variant="avatar" animate={false} />
<Skeleton variant="text" animate={false} />