Components

Skeleton

A placeholder where content is still loading.

Previews are drawn in the theme you made.

Edit it
shape
animation
scheme
direction

Basic #

import { Recipes, Skeleton, SkeletonSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A bar of the page's colour, drawn where text will go. The first names the
// whole loading region for a screen reader; the rest are silent.
export default example({
  title: 'Basic',
  slots: SkeletonSlots,
  recipe: Recipes.Skeleton,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ display: 'grid', gap: '0.5rem', inlineSize: 'min(20rem, 100%)' })],
      [
        Skeleton.view({ label: 'Loading the profile', style }, h),
        Skeleton.view({ style }, h),
        Skeleton.view({ style }, h),
      ],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Lines #

import { Recipes, Skeleton, SkeletonSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A paragraph still loading: whole lines, the last one ending early.
export default example({
  title: 'Lines',
  slots: SkeletonSlots,
  recipe: Recipes.Skeleton,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ inlineSize: 'min(24rem, 100%)' })],
      [Skeleton.lines({ lines: 4, label: 'Loading the article', style }, h)],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Shapes #

import { Recipes, Skeleton, SkeletonSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// The shapes content will take: a person, a card, rows of a table.
export default example({
  title: 'Shapes',
  slots: SkeletonSlots,
  recipe: Recipes.Skeleton,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ display: 'grid', gap: '1.5rem', inlineSize: 'min(24rem, 100%)' })],
      [
        Skeleton.avatarRow({ label: 'Loading the author', style }, h),
        Skeleton.card({ label: 'Loading the post', style }, h),
        h.div(
          [],
          [1, 2, 3].map(() => Skeleton.tableRow({ columns: 4, label: 'Loading a row', style }, h)),
        ),
      ],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Shimmer #

import { Recipes, Skeleton, SkeletonSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A band of the page sweeping across; still under reduced motion.
export default example({
  title: 'Shimmer',
  slots: SkeletonSlots,
  recipe: Recipes.Skeleton,
  pins: { animation: 'shimmer' },
  view: ({ style, h }) =>
    h.div(
      [h.Style({ inlineSize: 'min(24rem, 100%)' })],
      [Skeleton.avatarRow({ label: 'Loading the author', style }, h)],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Sized #

import { Recipes, Skeleton, SkeletonSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// `inline` and `block` are CSS lengths: the size of what is loading, so a
// bar can stand in for a thumbnail or a heading with no style of its own.
export default example({
  title: 'Sized',
  slots: SkeletonSlots,
  recipe: Recipes.Skeleton,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ display: 'grid', gap: '0.75rem', justifyItems: 'start' })],
      [
        Skeleton.view({ label: 'Loading the cover', inline: '12rem', block: '6rem', style }, h),
        Skeleton.view({ inline: '8rem', block: '1.5rem', style }, h),
      ],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Usage

Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.

The recipe ↗This code ↗