Skip to content

Documentation

Custom cards

You can customize how a card looks and behaves with a React component, adding controls, progress bars or your own layout.

To edit a card’s code:

  1. Select the card to open its panel.
  2. Expand Code and choose Edit code.
  3. Edit the code. The preview beside it shows the card as it will look.
  4. Choose Save, or press Cmd+S (Ctrl+S on Windows and Linux). Code with a syntax error can’t be saved.

To go back to the default card, choose Use the default card. Agents can customize cards with code too, with the cards.setCode MCP action.

Your first card

The editor starts with code that renders the default card:

import { Card, Excerpt, Properties, Title } from "@pluto/cards"

export default function MyCard() {
  return (
    <Card>
      <Title />
      <Properties />
      <Excerpt />
    </Card>
  )
}

The code must have a default export: the component that renders the card. It can import only from react and @pluto/cards.

Example: a task card

This example adds a slider and a switch to track a task’s progress. It assumes the canvas has a number property Progress and a checkbox property Done:

import { Card, Slider, Title, Toggle } from "@pluto/cards"

export default function Task() {
  return (
    <Card>
      <Title />
      <Slider property="Progress" min={0} max={100} step={5} />
      <Toggle property="Done" label="Done" />
    </Card>
  )
}

Moving the slider sets the card’s Progress property, as if you had typed the value in the panel.

A card titled Write the launch post, with a Progress slider at 60 and a Done switch turned off.

How a card is laid out

<Card> draws the card’s outline in its shape and colors, and stacks its children from top to bottom. Each part brings its own spacing, so you don’t need to add margins:

<Card /> with no children is the default card. The card grows to fit what it holds. To change the outline, pass shape or color to <Card>. Use padding to add space inside it.

You don’t have to use <Card>. Code that returns something else renders just that, with no outline.

To place things side by side, use <Row>. To stack them with a set gap, use <Stack>.

<Card>
  <Title />
  <Row justify="between">
    <Stat label="Open" value={12} />
    <Stat label="Closed" value={30} />
  </Row>
</Card>
A card titled Bugs, with 12 Open and 30 Closed side by side under the title.

Reading and setting properties

There are three ways to work with a card’s properties:

This card shows a warning when a task is late:

import { Badge, Button, Card, Row, Title, useProperty } from "@pluto/cards"

export default function Task() {
  const [due] = useProperty("Due")
  const [, setStatus] = useProperty("Status")
  const late = typeof due === "string" && due < new Date().toISOString().slice(0, 10)
  return (
    <Card>
      <Title />
      <Row>
        {late && <Badge tone="red">Late</Badge>}
        <Button onClick={() => setStatus("Done")}>Mark done</Button>
      </Row>
    </Card>
  )
}
A card titled Renew the SSL certificate, with a red Late badge and a Mark done button.

Rules for setting a property

Iterating over properties

useProperty is a React hook, so it can’t be called inside a loop over useCard().properties. The list changes when someone adds a property, which would change the number of hooks. Instead, pass each property’s name to a control, or to a small component of your own:

import { Badge, Button, Card, Row, Stack, Title, useCard, useProperty } from "@pluto/cards"

// One component per property, so each useProperty call stays in place.
function Field({ name }: { name: string }) {
  const [value, setValue] = useProperty(name)
  if (value === null) return null
  return (
    <Row justify="between">
      <Badge>{name}: {String(value)}</Badge>
      <Button onClick={() => setValue(null)}>Clear</Button>
    </Row>
  )
}

export default function TextFields() {
  const card = useCard()
  return (
    <Card>
      <Title />
      <Stack>
        {card.properties
          .filter((p) => p.type === "text" && !p.calculated)
          .map((p) => <Field key={p.name} name={p.name} />)}
      </Stack>
    </Card>
  )
}
A card titled Onboarding guide, listing Owner: Maya and Audience: New hires, each with a Clear button.

If a built-in control does what you need, skip the extra component: <TextInput key={p.name} property={p.name} label={p.name} /> works inside the loop, because the control calls the hook itself.

Either way, pass the property’s name to a control, not its value: property={p.name}. To show a value as Pluto formats it, use p.display or <PropertyValue property={p.name} />.

People, state and time

useViewer() returns the person looking at the card: id, name, initials, color and access ("owner", "edit", "comment" or "view"). It works in embeds too, and is null for someone not signed in. usePeople(name) returns the people a person property names. Card code never sees email addresses.

useCardState(key, initial) keeps data that belongs to the card but isn’t a property: the votes in a poll, a checklist’s items, when a timer started. It works like React’s useState, but the value is saved with the workspace and shared live with everyone who sees the card. Tables and queries don’t see it, and no other card can read it. A reference shares its original’s state.

With { perPerson: true }, each person keeps their own value, so two people can vote at once without losing either. It returns [mine, setMine, all], where all lists everyone’s value with their person.

useNow() returns the time in milliseconds by the server’s clock, so every device agrees, and redraws the card every second ({ every: 250 } for faster). It stops while the card is off screen or the tab is hidden. A countdown everyone sees saves its end time with useCardState and compares it with useNow:

import { Button, Card, Stat, Title, useCardState, useNow } from "@pluto/cards"

export default function Timer() {
  const [endsAt, setEndsAt] = useCardState<number | null>("endsAt", null)
  const now = useNow()
  const left = endsAt ? Math.max(0, endsAt - now) : 0
  const clock = `${Math.floor(left / 60000)}:${String(Math.floor(left / 1000) % 60).padStart(2, "0")}`
  return (
    <Card>
      <Title />
      <Stat label="left" value={clock} />
      <Button onClick={() => setEndsAt(now + 5 * 60000)}>Start 5 minutes</Button>
    </Card>
  )
}

Only people who can edit the workspace can change a card’s state. A card keeps at most 64 KB, and state is deleted when the card goes back to the default card.

Settings

Settings are what a person fills in once when they add a card: which card is the goal, which frame holds the work, what color to use. Declare them next to the component as export const settings, and the card’s panel shows a Setup form for them. The values are kept with the card, apart from its properties, so tables and queries don’t see them.

import { Card, Progress, Title, setting, useSetting } from "@pluto/cards"

export const settings = {
  tasks: setting.frame({ label: "Tasks", required: true }),
  goal: setting.number({ label: "Goal", default: 10, min: 1 })
}

export default function Burndown() {
  const tasks = useSetting(settings.tasks)
  const goal = useSetting(settings.goal)
  const done = tasks?.cards.filter((c) => c.options("Status")[0] === "Done").length ?? 0
  return (
    <Card>
      <Title />
      <Progress value={done} max={goal} label={`${done} of ${goal}`} />
    </Card>
  )
}
Setting The person fills in Reads as
setting.text() Text A string
setting.number({ min, max, step }) A number A number
setting.switch() On or off true or false
setting.choice({ options }) One of the options The option
setting.color() A card color The color’s name
setting.property({ type }) A property of this canvas, or a new one The property’s name
setting.card({ multiple, thisCanvasOnly, needs }) A card, picked on the canvas or by search A card handle, or a list with multiple: true
setting.frame({ multiple, thisCanvasOnly }) A frame A frame handle, or a list

Every setting takes label, and all but card and frame settings take default. A required card or frame setting shows Finish setup on the card until it’s filled. Card and frame settings pick only on the card’s own canvas unless thisCanvasOnly is false; then the search groups results by canvas, this canvas first.

A card setting’s needs names the properties the picked cards must have, such as { Status: { type: "select", options: ["Todo", "Done"] }, Points: "number" }. Setup checks the picked cards’ canvas. When something is missing, it offers to add it, or to use a property with another name, so a card that needs Status can work on a canvas that calls it State. Code always uses the name it declared.

Other cards and frames

Code can read and change cards other than its own, but only ones a person tied to it: cards and frames picked in its settings, cards it’s connected to, the frames holding it, and the cards in those frames. There’s no search from code, so a card can’t reach anything nobody pointed it at.

useConnected(filter?) lists the card’s connections. Each has from, to, directed, label, and other(card) for the card at the other end. Filter by label or by direction ("out", "in" or "any"). useFrames() lists the frames holding the card, innermost first.

Cards come as handles. A handle has the card’s id, title, canvas, here (on the canvas the viewer is looking at) and box (where it is, or null on another canvas), and:

useCard() returns the card’s own handle, so the same code works on any card. Frame handles have cards and add(card) and remove(card), which move a card into or out of the frame.

import { Button, Card, Title, useConnected, useCard } from "@pluto/cards"

export default function Unblock() {
  const me = useCard()
  const blockers = useConnected({ label: "blocks", direction: "in" }).map((c) => c.other(me))
  return (
    <Card>
      <Title />
      {blockers.map((b) => (
        <Button key={b.id} onClick={() => b.set("Status", "Done")}>Mark {b.title} done</Button>
      ))}
    </Card>
  )
}

Rules for changing other cards

set, add and remove return a promise of { ok: true } or { ok: false, reason, message }. They never create a property, and follow the same rules as the card’s own properties. Also:

Each change is made by the person who clicked, and History shows it quietly as “via” the card. One click’s changes undo together.

Moving the view

useViewport() returns [viewport, go]. viewport says where the viewer is looking: canvasId, viewId, the middle of the screen (x, y) and zoom in canvas units, and visible, the part of the canvas showing beside any open panels. Only cards that call it redraw as the canvas moves.

go(target, options?) moves the viewer’s view to a card or frame handle, or to a point such as { x: 0, y: 0 } (add canvasId for another canvas). Options:

Like changes to other cards, go only works in response to a click or key press, and at most once a second. Each move is a step in the browser’s history, so Back returns to where the viewer was. Inside an embed, the view stays on the embed’s canvas, and moves work even in an embed that can’t be panned.

A reference runs its original’s code, and useCard().viewedAs is "reference" there. So a button that calls go(useCard(), { zoom: "fit", open: true }) turns every reference into a link to the original:

import { Button, Card, Title, useCard, useViewport } from "@pluto/cards"

export default function Spec() {
  const me = useCard()
  const [, go] = useViewport()
  return (
    <Card>
      <Title />
      {me.viewedAs === "reference" && (
        <Button onClick={() => go(me, { zoom: "fit", open: true })}>Go to {me.title}</Button>
      )}
    </Card>
  )
}

Library reference

Everything below is imported from @pluto/cards. The editor’s autocomplete shows each item’s full type.

The card and its parts

Item What it draws Props
Card The card’s outline. With no children, the default card. shape, color, padding (pixels), className, style
Title The card’s title. className, style
Properties Properties that have a value. names (show only the properties named in this list, in the list’s order), max (default 5)
Excerpt The start of the card’s text. className, style
PropertyValue One property’s value, formatted. property

Controls

Each control sets one of the card’s properties, named by property. Each also takes an optional label.

Control Property type Other props
Slider Number min, max, step
NumberInput Number min, max, step
Toggle Checkbox
Choice Select. Buttons, or a menu with menu. menu
TextInput Text placeholder, multiline
DateInput Date
Button Any. Sets property to value when clicked. value, onClick, variant ("primary" or "default"), disabled

A Button without property just calls onClick.

Things to show

Item What it draws Props
Progress A bar filled to value out of max. value, max (default 100), tone, label
Badge A small colored label. tone
Stat A big number with a label under it. value, label
Avatar A person’s initials in a circle of their color. person, size

Layout

Item What it does Props
Row Places children side by side. gap, align, justify, wrap, style
Stack Places children one under another. gap, style

Hooks

Hook Returns
useCard() The card’s own handle, with its look (shape, color, fill, border), readOnly, and viewedAs ("original" or "reference").
useProperty(name) [value, setValue] for one property.
usePeople(name) The people a person property names.
useViewer() The person looking at the card, or null.
useCardState(key, initial, options?) [value, setValue], or [mine, setMine, all] with { perPerson: true }.
useNow(options?) The server’s time in milliseconds, updated every every ms.
useSetting(setting) A setting’s value, or its default.
useConnected(filter?) The card’s connections, each with the card at the other end.
useFrames() Handles for the frames holding the card.
useViewport() [viewport, go]: where the viewer is looking, and a function that moves their view.

Each item in properties has name, type, value, display (the value as Pluto shows it), calculated and, for a select, options.

Types

Sandbox and limits

Each custom card runs in its own sandboxed frame, cut off from the rest of Pluto and from the internet. That means:

Other limits:

Pressing anywhere on the card except a control drags or selects it, as on any card. Double-click opens it, and Escape and Delete work as usual.

The card library

The card library holds cards whose code is written once and used on many cards. It has three parts:

To add a library card, choose the card library tool (L) in the toolbar, pick a card, and click where it should go. To turn an existing card into one, expand Code in its panel, or open the code editor, and choose Use a library card. If the card has code of its own, Pluto asks before replacing it. The card keeps its title, properties and document.

A card from the library stays linked to it, so a change to the library card reaches every card that uses it. Each card keeps its own settings and saved state, such as a poll’s votes. To change the code for one card only, choose Customize code: the card gets its own copy and stops following the library.

To save a card you wrote to the library, choose Save to library in its Code section or in the code editor. Give it a name and a description, and choose This workspace or My library. The card then uses the library version. Opening the code editor on a card from a library you can change edits the library card itself, for every card that uses it.

To rename or delete library cards, choose Manage library at the bottom of the card library. Deleting one gives each card that used it its own copy of the code, so nothing on the canvas changes. A card from someone’s own library, used in a shared workspace, gets their changes the next time someone who can edit the workspace opens it.

Library cards use settings for anything that differs from card to card, such as which property a Countdown counts down to. Write your own library cards the same way.

Customize cards with code from an agent, the API or the CLI

The cards.setCode action gives a card code. It takes workspaceId, canvasId, cardId and code, the component’s TSX source. An empty code goes back to the default card. Pluto compiles the code first, and refuses code that doesn’t compile with the line and the reason.

pluto cards set-code --workspace-id YOUR_WORKSPACE_ID --canvas-id root \
  --card-id YOUR_CARD_ID --code "$(cat Task.tsx)"

cards.setSettings fills in a card’s settings by name. Give a card or frame setting the id of a card or frame, or a list of ids; null clears a setting. cards.get returns a card’s code and settings. Cards in other results, and in workspace snapshots, have hasCode set to true when they have code.

library.list lists the card library, Pluto’s cards included, with each card’s ref. cards.useLibraryCard makes a card use one by ref, and cards.create takes a libraryCard ref to make a new card from one. library.save saves code to this workspace’s library or, with to: "mine", to your own; give it a ref to change a library card you can change. Cards that use a library card have libraryCard set to its ref.

pluto cards create --workspace-id YOUR_WORKSPACE_ID --label "Lunch?" --library-card pluto:poll

The cards.setCode description lists all of @pluto/cards, so an assistant connected over MCP can write a card without reading this page. A good prompt names the properties the card should show or set. Controls can’t set a property the canvas doesn’t have yet, so add it with properties.set first.

Calculated properties can be read, though not set. A card can show values that Pluto gathers from connected cards or from its own canvas.

References to a custom card

A reference shows a card on another canvas of the same workspace. It has its own position, size and connections, and everything else, such as the title, properties and code, is the original card’s.

A reference to a card with code is rendered by the same code. Its controls set the original card’s properties, so every copy stays in step.

The code belongs to the original. Editing the code from a reference, in the app or with cards.setCode, changes the original’s code and so every reference to it.

<Card> adds the “From the X canvas” label to a reference by itself. Code that doesn’t use <Card> draws no label.