Skip to main content

Skeleton

Reserve content structure while data is loading without implying completed content.

Default

Loading content
On this page

Installation

Copy this component and its required dependencies into the consumer-owned Components project.

dotnet fve add skeleton --config src/Acme.Components/fve.json

The CLI resolves dependencies and preserves consumer-authored files. See Installation for project initialization and Tailwind source detection.

Usage

open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar

let defaultSkeleton =
    SkeletonRegion.create "Loading content" (Skeleton.create () |> Skeleton.render)
    |> SkeletonRegion.render

Text

Loading description

Avatar row

Loading profile

Card

Loading card

API reference

type SkeletonShape =
    | Text
    | Rectangle
    | Circle

type SkeletonConfig

type SkeletonRegionConfig

module SkeletonRegion =
    val create : label:string -> content:HtmlElement -> SkeletonRegionConfig
    val withAttributes : attributes:HtmlAttribute list -> config:SkeletonRegionConfig -> SkeletonRegionConfig
    val render : config:SkeletonRegionConfig -> HtmlElement

/// Use for initial loading, not to replace established content during navigation.
module Skeleton =
    val create : SkeletonConfig
    val withShape : shape:SkeletonShape -> config:SkeletonConfig -> SkeletonConfig
    val withSize : width:string -> height:string -> config:SkeletonConfig -> SkeletonConfig
    val withAttributes : attributes:HtmlAttribute list -> config:SkeletonConfig -> SkeletonConfig
    val render : config:SkeletonConfig -> HtmlElement