Skip to content

Skeleton

Skeleton preview

Skeleton renders an animated placeholder in place of content while data loads. Size it identically to the content it replaces so layout does not shift on load.

Constructor func NewSkeleton() *Skeleton

Usage

skeleton := components.NewSkeleton().
SetVariant(components.SkeletonText).
SetLines(3).
SetAnimated(true)
fmt.Println(skeleton != nil)

Methods

Method Signature Description
GetFieldHeight func (s *Skeleton) GetFieldHeight() int GetFieldHeight returns preferred height
SetAnimated func (s *Skeleton) SetAnimated(animated bool) *Skeleton SetAnimated enables/disables animation
SetLines func (s *Skeleton) SetLines(lines int) *Skeleton SetLines sets number of text lines
SetVariant func (s *Skeleton) SetVariant(v SkeletonVariant) *Skeleton SetVariant sets the skeleton shape
Start func (s *Skeleton) Start() *Skeleton Start begins the animation
Stop func (s *Skeleton) Stop() *Skeleton Stop ends the animation

Types

type SkeletonVariant SkeletonVariant controls the shape rendered during animated loading: Text for multi-line stubs, Block for rectangular placeholders, Circle for avatars.
ConstantDescription
SkeletonText
SkeletonBlock
SkeletonCircle