skeleton

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package skeleton provides loading placeholder components.

Available variants:

  • New() creates a skeleton line (template: "lvt:skeleton:default:v1")
  • NewAvatar() creates avatar placeholder (template: "lvt:skeleton:avatar:v1")
  • NewCard() creates card placeholder (template: "lvt:skeleton:card:v1")

Example usage:

// In your controller/state
Loading: skeleton.New("line-1",
    skeleton.WithWidth("100%"),
    skeleton.WithHeight("16px"),
)

// In your template
{{template "lvt:skeleton:default:v1" .Loading}}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Templates

func Templates() *base.TemplateSet

Templates returns the skeleton component's template set for registration with the LiveTemplate framework.

Example usage in main.go:

import "github.com/livetemplate/lvt/components/skeleton"

tmpl, err := livetemplate.New("app",
    livetemplate.WithComponentTemplates(skeleton.Templates()),
)

Available templates:

  • "lvt:skeleton:default:v1" - Basic skeleton line
  • "lvt:skeleton:avatar:v1" - Circular avatar placeholder
  • "lvt:skeleton:card:v1" - Card placeholder

Types

type Animation

type Animation string

Animation defines the skeleton animation type.

const (
	AnimationPulse Animation = "pulse"
	AnimationWave  Animation = "wave"
	AnimationNone  Animation = "none"
)

type AvatarOption

type AvatarOption func(*AvatarSkeleton)

AvatarOption is a functional option for avatar skeletons.

func WithAvatarBadge

func WithAvatarBadge(show bool) AvatarOption

WithAvatarBadge shows or hides the status badge.

func WithAvatarSize

func WithAvatarSize(size string) AvatarOption

WithAvatarSize sets the avatar size.

func WithAvatarStyled

func WithAvatarStyled(styled bool) AvatarOption

WithAvatarStyled enables Tailwind CSS styling.

type AvatarSkeleton

type AvatarSkeleton struct {
	base.Base

	// Size of the avatar (sm, md, lg, xl)
	Size string

	// ShowBadge shows a small circle for status
	ShowBadge bool
}

AvatarSkeleton is a circular avatar placeholder.

func NewAvatar

func NewAvatar(id string, opts ...AvatarOption) *AvatarSkeleton

NewAvatar creates an avatar skeleton.

Example:

a := skeleton.NewAvatar("user-avatar",
    skeleton.WithAvatarSize("lg"),
)

func (*AvatarSkeleton) SizeClass

func (a *AvatarSkeleton) SizeClass() string

SizeClass returns the CSS class for avatar size.

func (*AvatarSkeleton) Styles

Styles returns the resolved AvatarSkeletonStyles for this component.

type CardOption

type CardOption func(*CardSkeleton)

CardOption is a functional option for card skeletons.

func WithCardDescription

func WithCardDescription(show bool, lines int) CardOption

WithCardDescription shows or hides description lines.

func WithCardFooter

func WithCardFooter(show bool) CardOption

WithCardFooter shows or hides the footer area.

func WithCardImage

func WithCardImage(show bool) CardOption

WithCardImage shows or hides the image placeholder.

func WithCardImageHeight

func WithCardImageHeight(height string) CardOption

WithCardImageHeight sets the image height.

func WithCardStyled

func WithCardStyled(styled bool) CardOption

WithCardStyled enables Tailwind CSS styling.

func WithCardTitle

func WithCardTitle(show bool) CardOption

WithCardTitle shows or hides the title placeholder.

type CardSkeleton

type CardSkeleton struct {
	base.Base

	// ShowImage shows image placeholder
	ShowImage bool

	// ImageHeight for image area
	ImageHeight string

	// ShowTitle shows title placeholder
	ShowTitle bool

	// ShowDescription shows description lines
	ShowDescription bool

	// DescriptionLines number of description lines
	DescriptionLines int

	// ShowFooter shows footer area
	ShowFooter bool
}

CardSkeleton is a card-shaped placeholder.

func NewCard

func NewCard(id string, opts ...CardOption) *CardSkeleton

NewCard creates a card skeleton.

Example:

c := skeleton.NewCard("card-loading",
    skeleton.WithCardImage(true),
    skeleton.WithCardDescription(true, 3),
)

func (*CardSkeleton) DescLineIndices

func (c *CardSkeleton) DescLineIndices() []int

DescLineIndices returns indices for description line rendering.

func (*CardSkeleton) IsLastDescLine

func (c *CardSkeleton) IsLastDescLine(i int) bool

IsLastDescLine returns true if this is the last description line.

func (*CardSkeleton) Styles

Styles returns the resolved CardSkeletonStyles for this component.

type Option

type Option func(*Skeleton)

Option is a functional option for configuring skeletons.

func WithAnimation

func WithAnimation(animation Animation) Option

WithAnimation sets the animation type.

func WithHeight

func WithHeight(height string) Option

WithHeight sets the skeleton height.

func WithLineHeight

func WithLineHeight(height string) Option

WithLineHeight sets the line height for multi-line spacing.

func WithLines

func WithLines(lines int) Option

WithLines sets the number of lines for multi-line skeleton.

func WithShape

func WithShape(shape Shape) Option

WithShape sets the skeleton shape.

func WithStyled

func WithStyled(styled bool) Option

WithStyled enables Tailwind CSS styling.

func WithWidth

func WithWidth(width string) Option

WithWidth sets the skeleton width.

type Shape

type Shape string

Shape defines the skeleton shape.

const (
	ShapeRectangle Shape = "rectangle"
	ShapeCircle    Shape = "circle"
	ShapeRounded   Shape = "rounded"
)

type Skeleton

type Skeleton struct {
	base.Base

	// Width of the skeleton
	Width string

	// Height of the skeleton
	Height string

	// Shape of the skeleton
	Shape Shape

	// Animation type
	Animation Animation

	// Lines for multi-line skeletons
	Lines int

	// LineHeight for multi-line spacing
	LineHeight string
}

Skeleton is a loading placeholder component. Use template "lvt:skeleton:default:v1" to render.

func New

func New(id string, opts ...Option) *Skeleton

New creates a skeleton placeholder.

Example:

s := skeleton.New("loading",
    skeleton.WithWidth("200px"),
    skeleton.WithHeight("20px"),
)

func (*Skeleton) AnimationClass

func (s *Skeleton) AnimationClass() string

AnimationClass returns CSS class for animation.

func (*Skeleton) IsCircle

func (s *Skeleton) IsCircle() bool

IsCircle returns true if shape is circle.

func (*Skeleton) IsMultiLine

func (s *Skeleton) IsMultiLine() bool

IsMultiLine returns true if Lines > 1.

func (*Skeleton) IsRounded

func (s *Skeleton) IsRounded() bool

IsRounded returns true if shape is rounded.

func (*Skeleton) LineIndices

func (s *Skeleton) LineIndices() []int

LineIndices returns indices for multi-line rendering.

func (*Skeleton) ShapeClass

func (s *Skeleton) ShapeClass() string

ShapeClass returns CSS class for the shape.

func (*Skeleton) Styles

func (s *Skeleton) Styles() styles.SkeletonStyles

Styles returns the resolved SkeletonStyles for this component.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL