Components

Steps

An ordered list of steps, those done checked, the current one marked, joined by a line.

Previews are drawn in the theme you made.

Edit it
orientation
size
marker
labels
connector
scheme
direction

Basic #

  1. AccountCompletedYour details
  2. PlanCompletedPick a tier
  3. PaymentCard or invoice
  4. ReviewUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// `current` is the application's: the steps before it are complete, the ones
// after it upcoming, and the list marks the current one `aria-current`.
export default example({
  title: 'Basic',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Checkout',
        steps: [
          { title: 'Account', description: 'Your details' },
          { title: 'Plan', description: 'Pick a tier' },
          { title: 'Payment', description: 'Card or invoice' },
          { title: 'Review' },
        ],
        current: 2,
        style,
      },
      h,
    ),
})

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

Going back #

  1. Review
import { Schema } from 'effect'
import { defineMessageUnion } from 'foldkit/message'
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Message = defineMessageUnion({ WentBack: { index: Schema.Number } })

// With `onSelect`, a completed step is a button that goes back to it. A step
// ahead never is: reaching it is the form's job, not the list's.
export default example({
  title: 'Going back',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  state: {
    Model: Schema.Number,
    Message,
    init: () => ({ model: 3 }),
    update: (_, message) => ({ model: message.index }),
  },
  view: ({ style, model: current, onMessage, h }) =>
    Steps.view(
      {
        label: 'Checkout',
        steps: [{ title: 'Account' }, { title: 'Plan' }, { title: 'Payment' }, { title: 'Review' }],
        current,
        onSelect: index => onMessage(Message.WentBack({ index })),
        style,
      },
      h,
    ),
})

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

Icons #

  1. OrderedCompleted
  2. PackedCompleted
  3. Shipped
  4. DeliveredUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { outline } from '../../snippets/icon.js'

// A step's `icon` stands in its marker for the number, until the step is done.
export default example({
  title: 'Icons',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Shipping',
        steps: [
          { title: 'Ordered', icon: outline(h, 'M3 4h10l-1 8H4zM6 4a2 2 0 0 1 4 0') },
          { title: 'Packed', icon: outline(h, 'M2 5l6-3 6 3v6l-6 3-6-3zM2 5l6 3 6-3M8 8v6') },
          { title: 'Shipped', icon: outline(h, 'M1 4h8v7H1zM9 7h3l3 3v1H9M4 13h1M11 13h1') },
          { title: 'Delivered', icon: outline(h, 'M2 7l6-5 6 5v7H2zM6 14v-4h4v4') },
        ],
        current: 2,
        style,
      },
      h,
    ),
})

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

Vertical, with content #

  1. Create the workspaceCompleted

    Named Northwind, at northwind.example.com.

  2. Invite the teamThree of ten seats

    Ada and Grace have joined. Alan has not answered yet.

  3. Connect a domainUpcoming

    Point a CNAME at the workspace.

import { Button, Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// Vertical, each step's `content` under it beside the line to the next. A
// horizontal stepper has no room under its steps and draws none.
export default example({
  title: 'Vertical, with content',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  pins: { orientation: 'vertical' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Set up the workspace',
        steps: [
          {
            title: 'Create the workspace',
            content: h.p([], ['Named Northwind, at northwind.example.com.']),
          },
          {
            title: 'Invite the team',
            description: 'Three of ten seats',
            content: h.div(
              [h.Style({ display: 'grid', gap: '0.5rem', justifyItems: 'start' })],
              [
                h.p([], ['Ada and Grace have joined. Alan has not answered yet.']),
                Button.view({ label: 'Send a reminder' }, h),
              ],
            ),
          },
          { title: 'Connect a domain', content: h.p([], ['Point a CNAME at the workspace.']) },
        ],
        current: 1,
        style,
      },
      h,
    ),
})

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

A progress connector #

  1. ChooseCompleted
  2. Upload
  3. ProcessUpcoming
  4. DoneUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// The connector is the Progress bar's track: full after each step done and,
// after the current one, filled by `progress`, how far it has gone.
export default example({
  title: 'A progress connector',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  pins: { connector: 'progress' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Upload',
        steps: [{ title: 'Choose' }, { title: 'Upload' }, { title: 'Process' }, { title: 'Done' }],
        current: 1,
        progress: 0.6,
        style,
      },
      h,
    ),
})

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

Dots #

  1. ProfileCompleted
  2. TeamCompleted
  3. Billing
  4. LaunchUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// Dots for a light stepper; `size` sets a numbered marker on the Avatar's sizes.
export default example({
  title: 'Dots',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  pins: { marker: 'dot' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Onboarding',
        steps: [{ title: 'Profile' }, { title: 'Team' }, { title: 'Billing' }, { title: 'Launch' }],
        current: 2,
        style,
      },
      h,
    ),
})

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

Loading and failed #

  1. BuildCompleted
  2. TestNeeds attentionTwo specs failed
  3. ReleaseRunning
  4. AnnounceUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A step may state its own state over the one `current` gives it: a later
// step already complete, the one being taken `loading`, one that `error`ed.
// Each says so in words a screen reader reads; `words` changes them.
export default example({
  title: 'Loading and failed',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Deploy',
        steps: [
          { title: 'Build' },
          { title: 'Test', state: 'error', description: 'Two specs failed' },
          { title: 'Release', state: 'loading' },
          { title: 'Announce' },
        ],
        current: 2,
        words: { loading: 'Running', error: 'Needs attention' },
        style,
      },
      h,
    ),
})

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

A timeline #

  1. BoardingCompletedGate 1209:30
  2. DepartureRunway 310:05
  3. LandingUpcomingTerminal 212:40
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A step's `trailing` Html ends its row: a time, a badge. Vertical, with
// each `description`, this is a timeline.
export default example({
  title: 'A timeline',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  pins: { orientation: 'vertical' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Flight',
        steps: [
          { title: 'Boarding', description: 'Gate 12', trailing: h.span([], ['09:30']) },
          { title: 'Departure', description: 'Runway 3', trailing: h.span([], ['10:05']) },
          { title: 'Landing', description: 'Terminal 2', trailing: h.span([], ['12:40']) },
        ],
        current: 1,
        style,
      },
      h,
    ),
})

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

Only the current label #

  1. ProfileCompleted
  2. Team
  3. BillingUpcoming
  4. LaunchUpcoming
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// `labels: 'current'` keeps the words of the step under way beside its
// marker and leaves the rest to a screen reader; `'hidden'` leaves them all.
export default example({
  title: 'Only the current label',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  pins: { labels: 'current', marker: 'dot' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Onboarding',
        steps: [{ title: 'Profile' }, { title: 'Team' }, { title: 'Billing' }, { title: 'Launch' }],
        current: 1,
        style,
      },
      h,
    ),
})

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

Configure once #

  1. ReadDone
  2. CheckStopped
  3. SaveNot yet
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// The look and the words every stepper of the application starts from, and a
// named preset over them. A use gives only what differs.
const Wizard = Recipes.Steps.style({ connector: 'segments', size: 'sm' })

const AppSteps = Steps.configure({
  base: { style: Wizard, words: { complete: 'Done', upcoming: 'Not yet' } },
  presets: { failing: { words: { error: 'Stopped' } } },
})

export default example({
  title: 'Configure once',
  slots: StepsSlots,
  recipe: Recipes.Steps,
  view: ({ h }) =>
    AppSteps.view(
      {
        label: 'Import',
        steps: [{ title: 'Read' }, { title: 'Check', state: 'error' }, { title: 'Save' }],
        current: 1,
        preset: 'failing',
      },
      h,
    ),
})

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

A look of your own #

  1. AccountCompleted
  2. Plan
  3. ReviewUpcoming
import { Style } from 'foldkit-mixins'
import { Recipes, Steps, StepsSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// A look the recipe lacks, as a new value of an axis it has: `add` gives the
// connector a `dashed` value, and the shipped values still apply.
const Dashed = Recipes.Steps.add({
  connector: {
    dashed: {
      connector: Style.self({
        background: 'transparent',
        backgroundImage:
          'repeating-linear-gradient(to right, var(--fk-outline-default) 0 0.375rem, transparent 0.375rem 0.625rem)',
      }),
    },
  },
})

export default example({
  title: 'A look of your own',
  slots: StepsSlots,
  recipe: Dashed,
  pins: { connector: 'dashed' },
  view: ({ style, h }) =>
    Steps.view(
      {
        label: 'Checkout',
        steps: [{ title: 'Account' }, { title: 'Plan' }, { title: 'Review' }],
        current: 1,
        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 ↗

  • Right to left The direction switch above turns the preview over; this is what each widget reads.