Components

Separator

A rule between groups of content.

Previews are drawn in the theme you made.

Edit it
line
thickness
spacing
inset
scheme
direction

Basic #

Foldkit Plus

Packages for Foldkit applications.

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

// One style draws both: across, between sections; stood up, between links in
// a row, where it stretches to the row's height.
export default example({
  title: 'Basic',
  slots: SeparatorSlots,
  recipe: Recipes.Separator,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ display: 'grid', gap: '0.75rem', inlineSize: 'min(100%, 22rem)' })],
      [
        h.div(
          [],
          [
            h.p([h.Style({ fontWeight: '600' })], ['Foldkit Plus']),
            h.p([], ['Packages for Foldkit applications.']),
          ],
        ),
        Separator.view({ style }, h),
        h.div(
          [h.Style({ display: 'flex', alignItems: 'center', gap: '0.75rem' })],
          [
            h.a([h.Href('#')], ['Blog']),
            Separator.view({ orientation: 'vertical', style }, h),
            h.a([h.Href('#')], ['Docs']),
            Separator.view({ orientation: 'vertical', style }, h),
            h.a([h.Href('#')], ['Source']),
          ],
        ),
      ],
    ),
})

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

A label #

or
import { Button, Recipes, Separator, SeparatorSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Face = Recipes.Button.style({ tone: 'neutral', variant: 'outline' })

// Words in the middle of the rule, read as text; the rules either side are drawing.
export default example({
  title: 'A label',
  slots: SeparatorSlots,
  recipe: Recipes.Separator,
  view: ({ style, h }) =>
    h.div(
      [h.Style({ display: 'grid', gap: '1rem', inlineSize: 'min(100%, 20rem)' })],
      [
        Button.view({ label: 'Continue with a passkey', style: Face }, h),
        Separator.view({ label: 'or', style }, h),
        Button.view({ label: 'Continue with email', style: Face }, h),
      ],
    ),
})

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

In a toolbar #

import { Button, Recipes, Separator, SeparatorSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { outline } from '../../snippets/icon.js'

const Tool = Recipes.Button.style({ tone: 'neutral', variant: 'icon', size: 'sm' })

// Pinned: `Recipes.Separator({ spacing: 'sm', inset: 'sm' })`. Between groups
// of a toolbar's buttons, the rule stops short of the row's height.
export default example({
  title: 'In a toolbar',
  slots: SeparatorSlots,
  recipe: Recipes.Separator,
  pins: { spacing: 'sm', inset: 'sm' },
  view: ({ style, h }) => {
    const tool = (label: string, d: string) =>
      Button.view({ label, icon: outline(h, d), style: Tool }, h)
    return h.div(
      [
        h.Role('group'),
        h.AriaLabel('Formatting'),
        h.Style({ display: 'flex', alignItems: 'center', gap: '0.25rem' }),
      ],
      [
        tool('Bold', 'M4.5 2.5h4.25a2.75 2.75 0 0 1 0 5.5H4.5zM4.5 8h5a2.75 2.75 0 0 1 0 5.5h-5z'),
        tool('Italic', 'M7 2.5h5M4 13.5h5M10 2.5l-4 11'),
        Separator.view({ orientation: 'vertical', style }, h),
        tool('Align left', 'M2.5 4h11M2.5 8h7M2.5 12h9'),
        tool('Align center', 'M2.5 4h11M4.5 8h7M3.5 12h9'),
      ],
    )
  },
})

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

Dashed #

Subtotal$40.00
Shipping$5.00
Total$45.00
import { Recipes, Separator, SeparatorSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// Pinned: `Recipes.Separator({ line: 'dashed', thickness: 'thick', spacing: 'md' })`.
// Dashed and thick, with room above and below, above a receipt's total.
export default example({
  title: 'Dashed',
  slots: SeparatorSlots,
  recipe: Recipes.Separator,
  pins: { line: 'dashed', thickness: 'thick', spacing: 'md' },
  view: ({ style, h }) => {
    const line = (label: string, amount: string) =>
      h.div(
        [h.Style({ display: 'flex', justifyContent: 'space-between' })],
        [h.span([], [label]), h.span([], [amount])],
      )
    return h.div(
      [h.Style({ inlineSize: 'min(100%, 16rem)' })],
      [
        line('Subtotal', '$40.00'),
        line('Shipping', '$5.00'),
        Separator.view({ style }, h),
        line('Total', '$45.00'),
      ],
    )
  },
})

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 ↗