T templcn/ui
Componentskeleton

Skeleton

Use to show a placeholder while content is loading.

Preview

Use to show a placeholder while content is loading.

Installation

Add this component to your project using the CLI.

templcn add skeleton

Usage

1. Import the component in your Go or templ file:

import "your-module/ui"

2. Use the component in your template:

<div class="flex items-center space-x-4">
  @ui.Skeleton(ui.DOMProps{Class: "size-12 rounded-full"})
  <div class="space-y-2">
    @ui.Skeleton(ui.DOMProps{Class: "h-4 w-[250px]"})
    @ui.Skeleton(ui.DOMProps{Class: "h-4 w-[200px]"})
  </div>
</div>

Composition

Use these parts together to build the component.

Skeleton

Examples

Named examples and common variations.

User avatar skeleton

A typical loading placeholder for a user card.

Card skeleton

A full card placeholder.

API Reference
PropTypeDefaultDescription
DOMProps.Classstring""Width, height, and shape classes (e.g. h-4 w-1/2 rounded-full).
View source
package ui

import (
	"context"
	"io"

	"github.com/a-h/templ"
)

func Skeleton(props DOMProps) templ.Component {
	return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
		return renderElement(ctx, w, "div", attrsFromDOMProps(props, "skeleton", "animate-pulse rounded-md bg-accent"), nil)
	})
}