Components

Item

A row of a list: media, a title, a line and actions.

Previews are drawn in the theme you made.

Edit it
variant
density
media
scheme
direction

Basic #

Deploy finished
2 minutes ago
Production is live.
import { Item, ItemSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { t } from '../../snippets/theme.js'

// A status mark in the success colour as the media, a title, a time, and a
// line of content at the end.
export default example({
  title: 'Basic',
  slots: ItemSlots,
  recipe: Recipes.Item,
  view: ({ style, h }) =>
    Item.view(
      {
        media: h.span(
          [
            h.AriaHidden(true),
            h.Style({
              display: 'block',
              inlineSize: '0.5rem',
              blockSize: '0.5rem',
              borderRadius: '50%',
              background: t.success.default,
            }),
          ],
          [],
        ),
        title: 'Deploy finished',
        description: '2 minutes ago',
        content: h.span([], ['Production is live.']),
        style,
      },
      h,
    ),
})

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

Settings #

  • Profile
    Name, photo and email
  • Security
    Passkeys and sessions
  • Billing
    Plan and invoices
import { Item, ItemSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { outline } from '../../snippets/icon.js'

const List = Recipes.ItemGroup.style({})

// Settings: a list of rows, each one control that opens its page. `press`
// draws one link over the row, named by its title.
export default example({
  title: 'Settings',
  slots: ItemSlots,
  recipe: Recipes.Item,
  pins: { media: 'icon' },
  view: ({ style, h }) =>
    Item.group(
      {
        label: 'Settings',
        items: [
          // Pages of this site, standing in for an application's settings pages.
          { key: 'avatar', title: 'Profile', description: 'Name, photo and email' },
          { key: 'password-input', title: 'Security', description: 'Passkeys and sessions' },
          { key: 'pagination', title: 'Billing', description: 'Plan and invoices' },
        ].map(row => ({
          ...row,
          media: outline(h, 'M8 1.5l1.8 4.7 4.7 1.8-4.7 1.8L8 14.5l-1.8-4.7L1.5 8l4.7-1.8z'),
          press: { href: `/components/${row.key}` },
        })),
        style: List,
        itemStyle: style,
      },
      h,
    ),
})

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

A choice #

  • Starter
  • Team
  • Business
import { Schema } from 'effect'
import { defineMessageUnion } from 'foldkit/message'
import { Item, ItemSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Model = Schema.Struct({ chosen: Schema.String })
const Message = defineMessageUnion({ Chose: { plan: Schema.String } })

// Rows as a choice: the chosen one is `selected`, pressed, and keeps a film
// of its text.
export default example({
  title: 'A choice',
  slots: ItemSlots,
  recipe: Recipes.Item,
  state: {
    Model,
    Message,
    init: () => ({ model: { chosen: 'Team' } }),
    update: (model, { plan }) => ({ model: plan === model.chosen ? model : { chosen: plan } }),
  },
  view: ({ style, model, onMessage, h }) =>
    Item.group(
      {
        label: 'Plan',
        items: ['Starter', 'Team', 'Business'].map(title => ({
          key: title,
          title,
          selected: title === model.chosen,
          press: { onClick: onMessage(Message.Chose({ plan: title })) },
        })),
        itemStyle: 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.

Header and footer #

Pull request #589
Example factories
Opened by Ada, 3 checks passing
import { Button, Item, ItemSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Small = Recipes.Button.style({ size: 'sm', variant: 'outline' })

// `header` and `footer` are full-width bands above and below the row. The
// whole item is a link, and the footer's button stays pressable above it.
export default example({
  title: 'Header and footer',
  slots: ItemSlots,
  recipe: Recipes.Item,
  pins: { variant: 'outline' },
  view: ({ style, h }) =>
    Item.view(
      {
        header: h.span([], ['Pull request #589']),
        title: 'Example factories',
        description: 'Opened by Ada, 3 checks passing',
        press: { href: '#' },
        footer: Button.view({ label: 'Review', style: Small }, h),
        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 ↗