# Task quick add

The last row of a task list. It reads “Add a task” until it's opened with a click or N; then you write the whole task in the title, as you'd say it. The words that name a date, a person or a priority are underlined as you type and fill their slots on the right, and Tab steps through the slots to check or change each. Every detail is optional: Enter adds, Esc cancels and puts focus back on the row, and after adding the field stays open and empty for the next one. A task just added never gets the highlight.

- Beta: ready to use; its API can still change in a minor release.
- Category: Patterns · Notes & tasks

```tsx
import { parseTaskSentence, TaskQuickAdd } from "@leap-crm/design-system";
```

## Best practices

- Do: Pass it as `TaskList`'s `addRow`, so it is the last row of the open tasks.
- Do: Pass `people`, so a name in the sentence, like “for Mia”, fills the assignee slot.
- Do: Set `shortcut={false}` on every add row but one when a page holds more than one. It is on by default, and N should open one row.
- Do: Set `defaultOpen` only on a page that's only for adding tasks. Elsewhere it reads “Add a task” until it's opened.
- Don't: Add separate date, assignee or priority fields beside it. The sentence fills those slots, and Tab steps through them to check or change each.

## Keyboard

| Keys | What they do |
| --- | --- |
| N | Opens the add row, when its shortcut is on and focus isn't in a text field. |
| Enter | Adds the task. |
| ArrowDown, ArrowUp | While a list of suggestions is open, move through it. |
| Enter, Tab | While a list of suggestions is open, accept the highlighted one. |
| Backspace | In an empty field, removes the last token. |
| Escape | Closes an open picker first, then cancels the draft and puts focus back on the row. |

## Related

- [Task row](./task-row.md)
- [Task list](./task-list.md)
- [Note composer](./note-composer.md)

## Examples

What the examples import:

```tsx
import { useState } from "react";
import { TaskList, TaskQuickAdd, type TaskDraft, type TaskItem, type TaskQuickAddMode } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const today = "2026-11-24";

const people = [
  { id: "se", name: "Sam Evans", initials: "SE", onMatter: true },
  { id: "mg", name: "Mia Gold", initials: "MG", onMatter: true },
  { id: "st", name: "Sam Taylor", initials: "ST" },
];

function Demo({ mode }: { mode: TaskQuickAddMode }) {
  const [tasks, setTasks] = useState<TaskItem[]>([
    {
      id: "1",
      title: "Confirm finance approval with lender",
      priority: "low",
    },
  ]);
  const add = (draft: TaskDraft) =>
    setTasks(current => [
      ...current,
      {
        id: String(current.length + 1),
        title: draft.title,
        due: draft.due,
        priority: draft.priority,
        assignee: people.find(person => person.id === draft.assigneeId) ?? null,
      },
    ]);
  return (
    <TaskList
      // Room below for the slots' pickers in this example box.
      className="w-150 pb-72"
      tasks={tasks}
      today={today}
      addRow={
        <TaskQuickAdd
          mode={mode}
          people={people}
          today={today}
          shortcut={false}
          onAdd={add}
        />
      }
    />
  );
}
```

### Write the whole task

Try “Order strata report by Friday for Mia, high priority”: Due, Assignee and Priority fill themselves as each phrase is recognised, and the task is added as “Order strata report”. Then Tab moves to Due, Assignee and Priority in turn, each with its own picker, and a value picked by hand wins. “for Sam” asks which Sam, people on the matter first. Shift+Tab goes back.

```tsx
<Demo mode="steps" />
```

### Tokens

The alternative: type @ for a person, ! for a priority, or the start of a day; pick from the suggestions with the arrows and Enter or Tab, and it becomes a token. Backspace in an empty field removes the last token.

```tsx
<Demo mode="tokens" />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | `"steps" \| "tokens"` | `"steps"` | Steps: write the whole task in the title, like "Order strata report by Friday for Mia, high priority"; the date, the person and the priority it names fill their slots as you type, and Tab steps through them to check or change each. Tokens: @, ! and day names turn into tokens as you type. |
| `people` | `unknown` | `[]` | Who a task can be assigned to. People on this matter come first. |
| `onAdd` (required) | `(task: TaskDraft) => void` |  | Runs with the new task when it's added. The row then clears and stays open for the next one. |
| `defaultPriority` | `"low" \| "medium" \| "high" \| "urgent" \| "critical"` | `"medium"` | The priority a task gets when none is chosen. |
| `shortcut` | `boolean` | `true` | Pressing N anywhere outside a text field opens the row. |
| `today` | `string` |  | Today's ISO date. The page's today by default. |
| `defaultOpen` | `boolean` | `false` | Starts open, for a page that's only for adding. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
