---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# A board

Items in one column per stage, moved by drag and by the keys, each opening beside the board

This recipe draws ListPage `arrangement="filtered"`; the others (agent/layout-chooser.md) take the same slots. Your page fits another? Change the one prop:

- `plain` (fields: few): `filters` a few, in the header line; `collection` rows or a feed.
- `views-column` (views: saved): `views` the saved views, a column beside the list.
- `centred` (fields: few; Trail draws it as `plain`): `collection` rows read as items.

Copy the file below whole (`src/screens/board.tsx`, say) beside `frame.tsx` (`docs/screen-frame.md`), whose pages hold its page (`/board`), and swap the sample stages and items for yours; keep the parts and their props. Use it for items a person moves forward through stages (work, deals, applicants, orders); the same items as rows are `docs/screen-list.md`. ListPage: its heading and its New item button, a filter row of a search and an owner filter (a Select, "Owner: Everyone 7", whose options each count the cards they would show, the count at the option's end and in its name, as the list recipe's status filter: its words stay whole on a 320 px phone, where a SegmentedControl cuts them), the Board at the panel's full width (`gutter="page"`). Each stage is a column with its count (the cards it shows); its add button opens the CreateDialog with that stage chosen. A card moves by drag (on a touch screen, held still a moment first), by the keys (Space picks it up, the arrows carry it across stages and places, Space drops it, Escape puts it back; each step said aloud) or by its "Move to" menu (`moveMenu`); the counts follow. A press on a card (or Enter) opens it in a RecordPeek beside the board, kept in the URL (`?peek=<id>`; your router: `useRecordPeek({ adapter })`), its card ringed (`selected`); a second press closes it; ↑ ↓ step through the cards stage by stage. In the panel the stage, priority and owner are working chips: a new stage sends the card to that column's end. A card's title links to its full page (`href`, `hrefOf('/board/<id>')` from `./router`; your router's own link: the Board's `itemLink`). Light, dark, phone (one column at a time, snapping) and desktop are the parts' own: add no class for them.

```tsx
// src/screens/board.tsx: the board, one column a stage
import { useRef, useState } from 'react';
import { CreateDialog } from '@/components/goop/patterns/create-dialog';
import { ListPage } from '@/components/goop/patterns/list-page';
import {
  RecordPeekBody,
  RecordPeekHeader,
  RecordPeekPanel,
  useRecordPeek,
} from '@/components/goop/patterns/record-peek';
import { Board, type BoardColumnData, type BoardItem, moveBoardItem } from '@/components/ui/goop/board';
import { Button, ButtonIcon, ButtonLabel } from '@/components/ui/goop/button';
import { CommandShortcut } from '@/components/ui/goop/command';
import { PageHeader, PageHeaderTitle } from '@/components/ui/goop/page-header';
import { PersonSelect } from '@/components/ui/goop/person-select';
import { PriorityMark } from '@/components/ui/goop/priority-mark';
import { Properties, PropertyRow } from '@/components/ui/goop/properties';
import { Prose } from '@/components/ui/goop/prose';
import { SearchInput } from '@/components/ui/goop/search-input';
import {
  Select,
  SelectContent,
  SelectIcon,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/goop/select';
import { StatusMark } from '@/components/ui/goop/status-mark';
import { ScreenFrame, ScreenTopBar } from './frame';
import { hrefOf } from './router';

// ---- the sample data: swap it for yours
/** The stages, in the board's order: each one a column, its StatusMark before its name. */
const STAGES = [
  { id: 'planned', title: 'Planned', status: 'todo' },
  { id: 'started', title: 'In progress', status: 'in-progress' },
  { id: 'review', title: 'In review', status: 'in-review' },
  { id: 'done', title: 'Done', status: 'done' },
] as const satisfies readonly BoardColumnData[];
type Stage = (typeof STAGES)[number]['id'];
type Priority = 'urgent' | 'high' | 'medium' | 'low';
const PRIORITY_WORDS: Record<Priority, string> = { urgent: 'Urgent', high: 'High', medium: 'Medium', low: 'Low' };
const PEOPLE = [
  { id: 'teodora', name: 'Teodora Valk' },
  { id: 'bilal', name: 'Bilal Rashed' },
  { id: 'ngozi', name: 'Ngozi Ilori' },
  { id: 'dagny', name: 'Dagny Holm' },
  { id: 'cormac', name: 'Cormac Foley' },
];
const ME = 'cormac';
interface Item {
  id: string;
  /** Its stage: the board's `column`, so `moveBoardItem` saves a move as it is. */
  column: Stage;
  title: string;
  customer: string;
  priority: Priority;
  /** The due day, `YYYY-MM-DD`, or null. */
  due: string | null;
  /** The owner's id; '' for no one yet. */
  owner: string;
}
/** The day `days` from today, `YYYY-MM-DD`: the sample's due days move with the calendar, never fall behind it. */
const fromToday = (days: number) => {
  const day = new Date();
  day.setDate(day.getDate() + days);
  return [day.getFullYear(), day.getMonth() + 1, day.getDate()].map((n) => String(n).padStart(2, '0')).join('-');
};
const ITEMS: Item[] = [
  {
    id: 'FW-131',
    column: 'planned',
    title: 'Plan the patient interviews',
    customer: 'Diallo Dental',
    priority: 'high',
    due: fromToday(4),
    owner: 'ngozi',
  },
  {
    id: 'FW-129',
    column: 'planned',
    title: 'Recruit six library visitors',
    customer: 'Eastgate Library',
    priority: 'medium',
    due: null,
    owner: '',
  },
  {
    id: 'FW-126',
    column: 'started',
    title: 'Run the front-desk diary study',
    customer: 'Diallo Dental',
    priority: 'urgent',
    due: fromToday(1),
    owner: 'teodora',
  },
  {
    id: 'FW-124',
    column: 'started',
    title: 'Map the book returns journey',
    customer: 'Eastgate Library',
    priority: 'medium',
    due: fromToday(3),
    owner: ME,
  },
  {
    id: 'FW-122',
    column: 'review',
    title: 'Draft the findings deck',
    customer: 'Okafor Plumbing',
    priority: 'high',
    due: fromToday(0),
    owner: 'bilal',
  },
  {
    id: 'FW-119',
    column: 'review',
    title: 'Tag the interview notes',
    customer: 'Mill Lane Florist',
    priority: 'low',
    due: null,
    owner: ME,
  },
  {
    id: 'FW-115',
    column: 'done',
    title: 'Share the survey results',
    customer: 'Okafor Plumbing',
    priority: 'medium',
    due: fromToday(-6),
    owner: 'dagny',
  },
];
const OWNERS = [
  { value: 'everyone', words: 'Everyone' },
  { value: 'mine', words: 'Mine' },
  { value: 'unassigned', words: 'Unassigned' },
] as const;
type Owner = (typeof OWNERS)[number]['value'];
const ownedBy = (owner: Owner, item: Item) => owner === 'everyone' || item.owner === (owner === 'mine' ? ME : '');
const nameOf = (id: string) => PEOPLE.find((person) => person.id === id)?.name;
const dayOf = (due: string) => new Date(`${due}T00:00`).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' });
const itemsWord = (n: number) => `${n} ${n === 1 ? 'item' : 'items'}`;

/** An item as its card: the customer on its second line, its priority's mark alone, its due day, its owner. */
function cardOf(item: Item): BoardItem {
  const name = nameOf(item.owner);
  return {
    id: item.id,
    column: item.column,
    title: item.title,
    description: item.customer || undefined,
    href: hrefOf(`/board/${item.id}`),
    chips: [
      { label: `${PRIORITY_WORDS[item.priority]} priority`, priority: item.priority, iconOnly: true },
      ...(item.due ? [{ label: dayOf(item.due), icon: 'calendar' as const }] : []),
    ],
    owner: name ? { name } : 'unassigned',
  };
}

export default function BoardScreen() {
  const [items, setItems] = useState(ITEMS);
  const [query, setQuery] = useState('');
  const [owner, setOwner] = useState<Owner>('everyone');
  // the stage a create starts in (null: closed), and the control it was started from, where the focus goes back
  const [creating, setCreating] = useState<string | null>(null);
  const opener = useRef<HTMLElement | null>(null);
  const peek = useRecordPeek();
  const words = query.trim().toLowerCase();
  const found = items.filter((item) => `${item.title} ${item.customer}`.toLowerCase().includes(words));
  const shown = found.filter((item) => ownedBy(owner, item));
  const countOf = (value: Owner) => found.filter((item) => ownedBy(value, item)).length;
  const ownerWords = (value: Owner) => OWNERS.find((each) => each.value === value)?.words ?? '';
  // previous and next step through the cards stage by stage, as the board shows them
  const records = STAGES.flatMap((stage) => shown.filter((item) => item.column === stage.id).map((item) => item.id));
  const open = items.find((item) => item.id === peek.id);
  const change = (id: string, next: Partial<Item>) =>
    setItems((all) => all.map((item) => (item.id === id ? { ...item, ...next } : item)));
  // the board counts its index among the cards it shows: put the item before the same card in the whole list
  const move = (id: string, column: string, index: number) =>
    setItems((all) => {
      const before = shown.filter((item) => item.column === column && item.id !== id)[index];
      const rest = all.filter((item) => item.column === column && item.id !== id);
      return moveBoardItem(all, id, column, before ? rest.findIndex((item) => item.id === before.id) : rest.length);
    });
  const startCreate = (stage: string) => {
    opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
    setCreating(stage);
  };
  return (
    <ScreenFrame current="/board">
      <ListPage
        arrangement="filtered"
        header={<ScreenTopBar title="Board" />}
        heading={
          <PageHeader>
            <PageHeaderTitle asChild>
              <h1>Work</h1>
            </PageHeaderTitle>
          </PageHeader>
        }
        primaryAction={
          <Button onClick={() => startCreate(STAGES[0].id)}>
            <ButtonIcon icon="plus" />
            <ButtonLabel>New item</ButtonLabel>
          </Button>
        }
        filters={
          <>
            <SearchInput
              label="Search items"
              placeholder="Search items"
              value={query}
              onChange={(event) => setQuery(event.currentTarget.value)}
            />
            <Select value={owner} onValueChange={(next) => setOwner(next as Owner)}>
              <SelectTrigger aria-label={`Owner: ${ownerWords(owner)}, ${itemsWord(countOf(owner))}`}>
                <SelectValue>{`Owner: ${ownerWords(owner)} ${countOf(owner)}`}</SelectValue>
                <SelectIcon />
              </SelectTrigger>
              <SelectContent aria-label="Owner" search={false}>
                {OWNERS.map((each) => (
                  <SelectItem
                    key={each.value}
                    value={each.value}
                    aria-label={`${each.words}, ${itemsWord(countOf(each.value))}`}
                  >
                    {each.words}
                    <CommandShortcut>{countOf(each.value)}</CommandShortcut>
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
          </>
        }
        collection={
          <Board
            aria-label="Work by stage"
            gutter="page"
            className="grow"
            columns={STAGES}
            items={shown.map(cardOf)}
            countLabel={itemsWord}
            empty="No items"
            onMove={move}
            moveMenu
            selected={peek.id}
            onItemSelect={(card) => (card.id === peek.id ? peek.close() : peek.open(card.id))}
            onAdd={(stage) => startCreate(stage.id)}
            addLabel={(stage) => `New item in ${stage.title}`}
          />
        }
        peek={{
          open: open !== undefined,
          onOpenChange: (next) => {
            if (!next) peek.close();
          },
          records,
          value: peek.id,
          onValueChange: peek.step,
          href: open ? hrefOf(`/board/${open.id}`) : undefined,
          storageKey: 'work:peek',
        }}
        record={
          <RecordPeekPanel>
            <RecordPeekHeader title={open?.title ?? ''} />
            <RecordPeekBody>
              {open ? (
                <>
                  <Properties aria-label="Item details">
                    <PropertyRow label="Stage" icon="circle-dotted">
                      {(control) => (
                        <Select
                          value={open.column}
                          onValueChange={(next) => setItems((all) => moveBoardItem(all, open.id, next, all.length))}
                        >
                          <SelectTrigger {...control} shape="chip">
                            <SelectValue />
                          </SelectTrigger>
                          <SelectContent aria-label="Stage" search={false}>
                            {STAGES.map((stage) => (
                              <SelectItem
                                key={stage.id}
                                value={stage.id}
                                mark={<StatusMark status={stage.status} aria-hidden="true" />}
                              >
                                {stage.title}
                              </SelectItem>
                            ))}
                          </SelectContent>
                        </Select>
                      )}
                    </PropertyRow>
                    <PropertyRow label="Priority" icon="antenna-bars-4">
                      {(control) => (
                        <Select
                          value={open.priority}
                          onValueChange={(next) => change(open.id, { priority: next as Priority })}
                        >
                          <SelectTrigger {...control} shape="chip">
                            <SelectValue />
                          </SelectTrigger>
                          <SelectContent aria-label="Priority" search={false}>
                            {Object.entries(PRIORITY_WORDS).map(([value, label]) => (
                              <SelectItem
                                key={value}
                                value={value}
                                mark={<PriorityMark priority={value as Priority} aria-hidden="true" />}
                              >
                                {label}
                              </SelectItem>
                            ))}
                          </SelectContent>
                        </Select>
                      )}
                    </PropertyRow>
                    <PropertyRow label="Owner" icon="user">
                      <PersonSelect
                        shape="chip"
                        people={PEOPLE}
                        value={open.owner}
                        onValueChange={(next) => change(open.id, { owner: next })}
                        optional
                      />
                    </PropertyRow>
                    <PropertyRow label="Customer">{open.customer || 'None'}</PropertyRow>
                    <PropertyRow label="Due">{open.due ? dayOf(open.due) : 'No date'}</PropertyRow>
                  </Properties>
                  <Prose>{`${open.id} for ${open.customer || 'no customer yet'}. Open the full page for its history.`}</Prose>
                </>
              ) : null}
            </RecordPeekBody>
          </RecordPeekPanel>
        }
      />
      <CreateDialog
        open={creating !== null}
        onOpenChange={(next) => {
          if (!next) setCreating(null);
        }}
        heading="New item"
        titleLabel="Item name"
        titlePlaceholder="Item name"
        summaryPlaceholder="Customer"
        submitLabel="Create item"
        properties={[
          {
            name: 'stage',
            label: 'Stage',
            icon: 'circle-dotted',
            options: STAGES.map((stage) => ({ value: stage.id, label: stage.title, status: stage.status })),
          },
          {
            name: 'priority',
            label: 'Priority',
            icon: 'antenna-bars-4',
            options: Object.entries(PRIORITY_WORDS).map(([value, label]) => ({
              value,
              label,
              priority: value as Priority,
            })),
          },
          {
            kind: 'person',
            name: 'owner',
            label: 'Owner',
            options: PEOPLE.map((person) => ({ value: person.id, label: person.name })),
            optional: true,
          },
          { kind: 'date', name: 'due', label: 'Due date' },
        ]}
        defaultValues={{ properties: { stage: creating ?? STAGES[0].id, priority: 'medium' } }}
        onCreate={(values) => {
          const number = 1 + Math.max(...items.map((item) => Number(item.id.replace(/\D/g, ''))));
          setItems((all) => [
            ...all,
            {
              id: `FW-${number}`,
              column: (values.properties.stage || STAGES[0].id) as Stage,
              title: values.title,
              customer: values.summary,
              priority: (values.properties.priority || 'medium') as Priority,
              due: values.properties.due || null,
              owner: values.properties.owner ?? '',
            },
          ]);
        }}
        onCloseAutoFocus={(event) => {
          // back to where the create began: the New item button, or the stage's add button
          if (!opener.current?.isConnected) return;
          event.preventDefault();
          opener.current.focus();
        }}
      />
    </ScreenFrame>
  );
}
```
