# Tasks

> Mine or the team's to-dos: overdue first, then today, upcoming, without a date and done, with the counts on top.

Pattern · Halo kit · [Live page](https://ui.twentyfirst.media/halo/patterns/TasksScreen/)

Mine or the team's to-dos: overdue first, then today, upcoming, without a date and done, with the
counts on top.

## Code

```tsx
import * as React from "react";
import {
  AppShell,
  Button,
  PageHeader,
  Panel,
  Segmented,
  Stagger,
  StatTile,
  TaskList,
} from "@twentyfirstmedia/halo";
import type { CrmTask } from "@twentyfirstmedia/halo";
import { CRM_NAV, NOW } from "./_crm";

const TASKS: CrmTask[] = [
  {
    id: "1",
    title: "Send revised proposal",
    due: new Date(2026, 10, 13),
    priority: "high",
    assignee: "Mara Ellis",
    related: "Deal · Retainer 2027",
  },
  {
    id: "2",
    title: "Follow up with Lindqvist Studio",
    due: new Date(2026, 10, 14),
    assignee: "Mara Ellis",
    related: "Deal · Brand refresh",
  },
  {
    id: "3",
    title: "Call Lena about the contract",
    due: NOW,
    assignee: "Mara Ellis",
    related: "Person · Lena Hartmann",
  },
  {
    id: "4",
    title: "Prepare workshop agenda",
    due: NOW,
    assignee: "Jonas Pick",
    related: "Deal · Shop migration",
  },
  {
    id: "5",
    title: "Ask for two references",
    due: new Date(2026, 10, 19),
    priority: "low",
    assignee: "Lea Brandt",
    related: "Company · Nordhafen Outdoor",
  },
  {
    id: "6",
    title: "Quarterly review with Velo Werk",
    due: new Date(2026, 10, 24),
    assignee: "Lea Brandt",
    related: "Company · Velo Werk",
  },
  { id: "7", title: "Clean up duplicate contacts" },
  {
    id: "8",
    title: "Book the kick-off room",
    due: new Date(2026, 10, 12),
    done: true,
    assignee: "Jonas Pick",
  },
];

/** Everyone's to-dos: overdue first, then today, upcoming, without a date and done. */
export default function Preview() {
  const [tasks, setTasks] = React.useState(TASKS);
  const [who, setWho] = React.useState("me");
  const shown =
    who === "me" ? tasks.filter((x) => x.assignee === "Mara Ellis" || !x.assignee) : tasks;
  const start = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate());
  const end = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 1);
  const count = (test: (x: CrmTask) => boolean) => shown.filter((x) => !x.done && test(x)).length;
  return (
    <AppShell
      navigation="sidebar"
      brand="Pilot CRM"
      sidebarGroups={CRM_NAV}
      active="tasks"
      user={{ name: "Mara Ellis", email: "mara@pilot.app" }}
      dock={false}
    >
      <div className="tf-in">
        <PageHeader
          title="Tasks"
          subtitle="Monday, 16 November"
          actions={[
            <Segmented
              key="who"
              label="Show"
              value={who}
              onChange={setWho}
              options={[
                { value: "me", label: "Mine" },
                { value: "all", label: "Team" },
              ]}
            />,
            <Button key="new" icon="plus">
              New task
            </Button>,
          ]}
        />
      </div>
      <Stagger className="tf-col" style={{ gap: 16 }}>
        <div
          className="tf-grid"
          style={
            {
              "--cols": "repeat(3, minmax(0, 1fr))",
              "--cols-sm": "1fr",
              gap: 16,
            } as React.CSSProperties
          }
        >
          <StatTile
            label="Overdue"
            value={count((x) => !!x.due && +new Date(x.due) < +start)}
            tint="blush"
          />
          <StatTile
            label="Due today"
            value={count((x) => !!x.due && +new Date(x.due) >= +start && +new Date(x.due) < +end)}
            tint="butter"
          />
          <StatTile label="Done" value={shown.filter((x) => x.done).length} tint="mint" />
        </div>
        <Panel>
          <TaskList
            tasks={shown}
            today={NOW}
            onOpen={() => {}}
            onToggle={(id, done) =>
              setTasks((all) => all.map((x) => (x.id === id ? { ...x, done } : x)))
            }
          />
        </Panel>
      </Stagger>
    </AppShell>
  );
}
```

## Props

### AppShell

| Prop | Type | Notes |
| --- | --- | --- |
| `active?` | `string` |  |
| `brand?` | `ReactNode` | The product name, or a node (a logo mark with the name; collapsed sidebars show it whole). |
| `brandDot?` | `boolean` | The status dot after the brand (default `true`); turn it off next to a logo of your own. |
| `tag?` | `string` |  |
| `nav?` | `NavItem[]` |  |
| `user?` | `{ name: string; email?: string }` |  |
| `onNavigate?` | `(label: string) => void` |  |
| `topExtra?` | `ReactNode` |  |
| `sheetStyle?` | `CSSProperties` |  |
| `contentKey?` | `string \| number` |  |
| `side?` | `ReactNode` |  |
| `dock?` | `boolean` |  |
| `dockItems?` | `DockProps["items"]` |  |
| `railTop?` | `RailItem[]` |  |
| `railBottom?` | `RailItem[]` |  |
| `fill?` | `boolean` | The shell is the whole page: at least the viewport's height (100dvh), no outer radius, the sheet fills the rest; on desktop the sidebar stays in view while the page scrolls, on phones the sheet starts right under the sidebar's bar. |
| `navigation?` | `"top" \| "sidebar"` |  |
| `sidebarGroups?` | `SidebarGroup[]` | With `navigation="sidebar"`: groups instead of the flat `nav` list. |
| `sidebar?` | `Partial<Omit<SidebarProps, "variant" \| "groups">>` | With `navigation="sidebar"`: more sidebar props (collapsed, storageKey, shortcut, linkAs …). |
| `workspaces?` | `WorkspaceSwitcherProps` | With `navigation="sidebar"`: the workspace switcher at the top instead of the brand. |
| `userMenu?` | `(MenuItem \| "-")[]` | The account menu's entries (with `navigation="sidebar"` at the foot of the sidebar). |
| `topbar?` | `boolean \| ReactNode` | With `navigation="sidebar"`: a bar across the top of the frame. The brand (or `workspaces`) moves into its start, as wide as the sidebar below it (expanded or collapsed); `topStart` follows it, `topEnd` sits at the end. Frame, bar and sidebar read as one L around the sheet. Content given here goes between `topStart` and `topEnd`. On phones the bar is the sidebar's bar (menu button and brand) with `topEnd` on the right and `topStart` behind an icon button. |
| `topStart?` | `ReactNode` | With `topbar`: right after the brand, e.g. a search field or a command palette trigger. |
| `topEnd?` | `ReactNode` | With `topbar`: at the end of the bar (buttons, menus); `topExtra` goes there too. |
| `topStartCompact?` | `ReactNode` | With `topbar` on phones: what stands in for `topStart` (default: an icon button that opens `topStart` over the bar). |
| `topStartIcon?` | `IconName` | The icon of that button (default `search`). |
| `topStartLabel?` | `string` | The accessible name of that button (default "Search"). |
| `children?` | `ReactNode` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Button

| Prop | Type | Notes |
| --- | --- | --- |
| `variant?` | `"primary" \| "secondary" \| "soft" \| "ghost" \| "danger" \| "danger-solid"` |  |
| `size?` | `"md" \| "sm"` |  |
| `icon?` | `IconName` |  |
| `iconRight?` | `IconName` |  |
| `disabled?` | `boolean` |  |
| `type?` | `"button" \| "submit" \| "reset"` |  |
| `onClick?` | `(e: MouseEvent<HTMLButtonElement>) => void` |  |
| `children?` | `ReactNode` |  |
| `asChild?` | `boolean` | Render the single child element (a link, a router Link) with the button's look instead of a <button>. |
| `id?` | `string` |  |
| `name?` | `string` | Form field name and value, sent with the form when this button submits it. |
| `value?` | `string` |  |
| `form?` | `string` | The id of the form this button belongs to, when it sits outside it. |
| `title?` | `string` |  |
| `tabIndex?` | `number` |  |
| `autoFocus?` | `boolean` |  |
| `aria-label?` | `string` |  |
| `aria-labelledby?` | `string` |  |
| `aria-describedby?` | `string` |  |
| `aria-expanded?` | `boolean \| "true" \| "false"` | For disclosure and menu triggers: whether what the button controls is open. |
| `aria-controls?` | `string` |  |
| `aria-haspopup?` | `boolean \| "true" \| "false" \| "menu" \| "listbox" \| "tree" \| "grid" \| "dialog"` |  |
| `aria-pressed?` | `boolean \| "true" \| "false" \| "mixed"` | For toggle buttons. |
| `aria-current?` | `boolean \| "true" \| "false" \| "page" \| "step" \| "location" \| "date" \| "time"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### PageHeader

| Prop | Type | Notes |
| --- | --- | --- |
| `crumbs?` | `(string \| Crumb)[]` | A breadcrumb above the title (see `Breadcrumb`): labels, or items with `href`/`onClick`. |
| `crumbLinkAs?` | `ElementType` | The element crumb links render as, e.g. Next.js `Link`. |
| `title` | `string` | Required |
| `subtitle?` | `string` |  |
| `actions?` | `ReactNode[]` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Segmented

| Prop | Type | Notes |
| --- | --- | --- |
| `options` | `(string \| Option)[]` | Required |
| `value?` | `string` |  |
| `defaultValue?` | `string` |  |
| `onChange?` | `(v: string) => void` |  |
| `size?` | `"sm"` |  |
| `block?` | `boolean` |  |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### StatTile

| Prop | Type | Notes |
| --- | --- | --- |
| `value` | `ReactNode` | Required |
| `label` | `string` | Required |
| `tint?` | `Tint \| "surface" \| "placeholder"` |  |
| `delta?` | `string` |  |
| `delay?` | `number` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### TaskList

| Prop | Type | Notes |
| --- | --- | --- |
| `tasks` | `CrmTask[]` | Required |
| `today?` | `Date \| string \| number` | The day that counts as today; pass it so server and client render the same. |
| `onToggle?` | `(id: string, done: boolean) => void` |  |
| `onOpen?` | `(id: string) => void` |  |
| `grouped?` | `boolean` | Groups: overdue, today, upcoming, no date, done (default true). |
| `label?` | `string` | Accessible name (default "Tasks"). |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
