Skip to content
Star

Decision prompt

The agent asks a few quick questions before it starts. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.

$npx designme add decision-prompt
$npx shadcn@latest add https://designme.dev/r/shadcn/decision-prompt.json

Need this designed into your product? Book a call

Question 1 of 3

01

Install

Add it to your project with the CLI.

HTML, CSS and JS

$npx designme add decision-prompt

React

$npx designme add decision-prompt --react

Astro

$npx designme add decision-prompt --astro

shadcn, React

$npx shadcn@latest add https://designme.dev/r/shadcn/decision-prompt.json

shadcn, Astro

$npx shadcn@latest add https://designme.dev/r/shadcn/astro/decision-prompt.json

The CLI copies the source into your project, so you own it and can change anything. Where each version lands, what it needs and the shadcn theme bridge: Installation.

02

About

What it is for and what it does.

Decision prompt lets an agent ask a few multiple-choice questions before it starts a task, one question at a time. When the last one is answered it shows a short summary of the choices and a line that says the agent is getting going.

  • When a request is vague and two or three answers would change what the agent does.
  • When you want quick answers by keyboard instead of a long reply in chat.
  • When some questions can be left to the agent and people should be able to skip them.
  • When the person should see a recap of their choices before the work begins.
03

Usage

Import it in React and drive it from your own state, or place it in an Astro page.

React

import { DecisionPrompt } from '@/components/designme/decision-prompt/DecisionPrompt';

React example

The demo above as a React component, 19 lines you can copy.

'use client';
// The animated preview from designme.dev, rebuilt from the React component: an example of driving it from your own state.
import { DecisionPrompt, type DecisionQuestion } from './DecisionPrompt';

/* ---------- Decision prompt: three quick questions before a redesign, then a summary ---------- */
const QUESTIONS: DecisionQuestion[] = [
  { question: 'Which frames should the agent redesign?', label: 'Frames', options: [{ label: 'Pricing only', detail: '1 frame' }, { label: 'Pricing and checkout', detail: '3 frames' }, { label: 'The whole flow', detail: '9 frames' }] },
  { question: 'How bold can the changes be?', label: 'Scope', options: [{ label: 'Polish spacing and type', detail: 'Safe' }, { label: 'Rework the layout', detail: 'Medium' }, { label: 'Fresh direction', detail: 'Bold' }] },
  { question: 'Where should the result go?', label: 'Output', options: [{ label: 'New Figma page', detail: 'Keeps the original' }, { label: 'Branch in the repo', detail: 'Opens a PR' }, { label: 'Both', detail: 'Recommended' }] }
];

export default function DecisionPromptDemo() {
  return (
    <div style={{ width: '100%' }}>
      <DecisionPrompt questions={QUESTIONS} startLabel="Starting the redesign" />
    </div>
  );
}

Astro

In a page in src/pages. It plays the demo above; change its decision-prompt.js to show your own data. Attributes like class go on its root element.

---
import DecisionPrompt from '../components/designme/decision-prompt/DecisionPrompt.astro';
---
<DecisionPrompt />
<DecisionPrompt data-style="soft" class="my-class" />
04

Props

Everything DecisionPrompt takes.

PropTypeWhat it does
questionsrequiredDecisionQuestion[]
answers(number | null)[]The answers so far, an option's index or null for a skipped question. Leave it out to let Continue and Skip fill it
defaultAnswers(number | null)[]
onAnswersChange(answers: (number | null)[]) => void
onComplete(answers: (number | null)[]) => voidCalled once every question is answered, with the picked option's index for each, or null where the person skipped
skippedLabelstringWhat the summary says for a skipped question
startLabelstringThe line that takes the buttons' place, under the summary, while the agent gets going
startedbooleanThe agent has got going: that line settles with a green check
startedLabelstringWhat that line says once started. Defaults to startLabel
barebooleanDraws its own container (the default, as on designme.dev). Set true to sit it flat in a chat thread
classNamestring
05

Code

The full source, as the CLI installs it.

DecisionPrompt.tsxReact · 147 lines
'use client';
import { useRef, useState, type KeyboardEvent } from 'react';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { mxIn, mxOut, Think, useGrow } from '../lib/motion';
import { giveBack } from '../lib/popover';
import '../designme.css';
import './decision-prompt.css';

export interface DecisionOption {
  label: string;
  /** Quiet text at the end of the row, like "3 frames" or "Recommended" */
  detail?: string;
}
export interface DecisionQuestion {
  question: string;
  /** A short name for the question in the summary, like "Scope" */
  label: string;
  options: DecisionOption[];
}

export interface DecisionPromptProps {
  questions: DecisionQuestion[];
  /** The answers so far, an option's index or null for a skipped question. Leave it out to let Continue and Skip fill it */
  answers?: (number | null)[];
  defaultAnswers?: (number | null)[];
  onAnswersChange?: (answers: (number | null)[]) => void;
  /** Called once every question is answered, with the picked option's index for each, or null where the person skipped */
  onComplete?: (answers: (number | null)[]) => void;
  /** What the summary says for a skipped question */
  skippedLabel?: string;
  /** The line that takes the buttons' place, under the summary, while the agent gets going */
  startLabel?: string;
  /** The agent has got going: that line settles with a green check */
  started?: boolean;
  /** What that line says once started. Defaults to startLabel */
  startedLabel?: string;
  /** Draws its own container (the default, as on designme.dev). Set true to sit it flat in a chat thread */
  bare?: boolean;
  className?: string;
}

/** The agent asks a few quick questions before it starts. Number keys pick, Enter continues. */
export function DecisionPrompt({
  questions, answers: value, defaultAnswers = [], onAnswersChange, onComplete, skippedLabel = 'Agent decides', startLabel = 'Starting',
  started = false, startedLabel, bare = false, className
}: DecisionPromptProps) {
  const [answers, setAnswers] = useControllable(value, defaultAnswers, onAnswersChange);
  const [sel, setSel] = useState(0);
  const n = questions.length, at = answers.length, done = at >= n, q = questions[Math.min(at, n - 1)];

  // no room is kept for the next question or the summary: the card grows and shrinks with them
  const [root, inner] = useGrow();
  // the question answered leaves to the side first, quickly, and the next one comes in from the other, piece by piece, as the
  // card eases to its height (motion pieces); after the last, the head, the question and the buttons leave before the summary
  // rises in. A key pressed while it turns waits for it
  const turning = useRef(false);
  const next = (skipped = false) => {
    if (done || turning.current) return;
    const all = [...answers, skipped ? null : sel], el = root.current, last = all.length >= n;
    const commit = () => {
      setAnswers(all); setSel(0);
      if (last) {
        // the buttons give way to the line saying the agent has started: a focus that was on them comes back to the card
        if (root.current?.querySelector('.dm-dpx-f')?.contains(document.activeElement)) giveBack(root.current);
        onComplete?.(all);
      }
    };
    const going = el ? [...(el.querySelector('.dm-dpx-body')?.children ?? []), ...(last ? [el.querySelector('.dm-dpx-k'), ...(el.querySelector('.dm-dpx-f')?.children ?? [])] : [])] : [];
    if (!going.length) return commit();
    turning.current = true;
    mxOut(going, { x: -12 }).then(() => {
      turning.current = false; commit();
      // (anything a held answer leaves in place comes back)
      requestAnimationFrame(() => going.forEach(g => { const m = g as HTMLElement & { _mx?: Animation[] }; if (g?.isConnected && m._mx?.[0]?.playState === 'finished') m._mx.forEach(a => a.cancel()); }));
    });
  };
  const body = useRef<HTMLDivElement>(null), foot = useRef<HTMLDivElement>(null), seen = useRef(at);
  useIsoLayoutEffect(() => {
    if (seen.current === at) return; seen.current = at;
    const b = body.current; if (!b) return;
    if (done) mxIn([...b.querySelectorAll('.dm-dpx-sr'), foot.current?.querySelector('.dm-dpx-run')], { step: 50 });
    else mxIn([b.querySelector('.dm-dpx-q'), ...b.querySelectorAll('.dm-dpx-o')], { x: 12, base: 20 });
  }, [at, done]);
  const key = (e: KeyboardEvent) => {
    if (done || turning.current) return;
    const count = q.options.length;
    if (/^[1-9]$/.test(e.key) && +e.key <= count) { setSel(+e.key - 1); e.preventDefault(); }
    else if (e.key === 'Enter') { next(); e.preventDefault(); }
    else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { setSel((sel + (e.key === 'ArrowDown' ? 1 : count - 1)) % count); e.preventDefault(); }
  };

  return (
    <div data-dm="" ref={root} className={cx('dm-dpx', !bare && 'dm-panel', 'dm-growing dm-mx-grow', done && 'dm-done', className)} tabIndex={0} onKeyDown={key}>
      <div ref={inner} className="dm-grow">
      <div className="dm-dpx-h">
        <span className="dm-dpx-k dm-muted dm-num">{done ? 'All set' : `Question ${at + 1} of ${n}`}</span>
        {/* once every question is answered the steps are over: the dots fade away where they are, keeping their room */}
        <div className={cx('dm-dpx-dots', done && 'dm-gone')} aria-hidden="true">{questions.map((_, i) => <i key={i} className={cx(!done && i === at && 'dm-on', (done || i < at) && 'dm-done')} />)}</div>
      </div>
      {/* keyed by question, so each one is drawn afresh and plays its entrance */}
      <div ref={body} className="dm-dpx-body" key={done ? 'sum' : at} aria-live="polite">
        {done ? (
          <div className="dm-dpx-sum">
            {questions.map((x, i) => (
              <div key={i} className="dm-dpx-sr">
                <span>{x.label}</span>{answers[i] === null ? skippedLabel : x.options[answers[i]!]?.label}
              </div>
            ))}
          </div>
        ) : (
          <>
            {/* the next question plays its entrance (above); the first is drawn from the start, so a frame that doesn't animate yet
                (a small live preview off screen) still shows it */}
            <div className="dm-dpx-q">{q.question}</div>
            <div className="dm-dpx-opts" role="radiogroup" aria-label={q.question}>
              {q.options.map((o, i) => (
                <button key={i} type="button" role="radio" aria-checked={i === sel} className={cx('dm-dpx-o dm-mx-press', i === sel && 'dm-on')}
                  onClick={() => setSel(i)} onDoubleClick={() => next()}>
                  <span className="dm-kbd">{i + 1}</span>{o.label}{o.detail && <span className="dm-d">{o.detail}</span>}
                </button>
              ))}
            </div>
          </>
        )}
      </div>
      {/* once every question is answered, the line saying the agent has started takes the buttons' place */}
      <div ref={foot} className={cx('dm-dpx-f', done && 'dm-run')}>
        {done ? (
          <div className="dm-dpx-run" aria-live="polite">{started
            ? <><span className="dm-dpx-ok"><Icon name="check" size="xs" /></span><span>{startedLabel ?? startLabel}</span></>
            : <><Think /><span className="dm-shim">{startLabel}</span></>}</div>
        ) : (
          <>
            <button type="button" className="dm-pill dm-ghost dm-sm dm-dpx-skip" onClick={() => next(true)}>Skip</button>
            <button type="button" className="dm-pill dm-primary dm-sm dm-dpx-go" onClick={() => next()}>Continue <span className="dm-kbd">↵</span></button>
          </>
        )}
      </div>
      </div>
      {/* the head goes once every question is answered, so this line tells screen readers */}
      <p className="dm-dpx-live" aria-live="polite">{done ? 'All questions answered' : ''}</p>
    </div>
  );
}
decision-prompt.cssReact · 77 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Decision prompt ---------- */
/* the agent asks in the chat: no container; with .panel it becomes a card. Each answer is a tile to pick (a click, its
   number or the arrows): white with a dimmed grey edge, the picked one's edge a step stronger and its number filled. No
   room is kept for what comes next (owner, 18 Nov): the card grows and shrinks with what it shows (grow()), and once every
   question is answered the line saying the agent has started takes the buttons' place */
.dm-dpx{padding:var(--dm-s-4) 0;display:flex;flex-direction:column;gap:var(--dm-s-3);outline:0;border-radius:var(--dm-r-in)}
.dm-dpx.dm-panel{padding:var(--dm-s-4);border-radius:var(--dm-r-card)}
.dm-dpx:focus-visible{outline:2px solid var(--dm-focus);outline-offset:6px}
.dm-dpx-h{display:flex;align-items:center;justify-content:space-between}
/* once every question is answered the head goes, label and dots (owner, 23 Nov: "All set" said what the card already shows):
   the card eases to its new height with its usual grow(), its first summary row 16px from the top, and a hidden line tells
   screen readers that every question is answered. (Agent harness keeps staging's head under its own rules) */
.dm-dpx.dm-done .dm-dpx-h{display:none}
.dm-dpx-live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.dm-dpx-k{font-size:12px;line-height:16px}
.dm-dpx-dots{display:flex;gap:var(--dm-s-1);transition:opacity var(--dm-t-fast) var(--dm-ease),transform var(--dm-t) var(--dm-ease),visibility 0s}
/* the steps are done once every question is answered (owner, 21 Nov): the dots fade and shrink a little where they are, at
   the style's own pace, and keep their room, so nothing else in the head moves; with reduced motion they are simply gone */
.dm-dpx-dots.dm-gone{opacity:0;transform:scale(.8);visibility:hidden;transition:opacity var(--dm-t-fast) var(--dm-ease),transform var(--dm-t) var(--dm-ease),visibility 0s var(--dm-t)}
@media (prefers-reduced-motion:reduce){.dm-dpx-dots,.dm-dpx-dots.dm-gone{transition:none}}
.dm-dpx-dots i{width:6px;height:6px;border-radius:var(--dm-r-tiny,3px);background:var(--dm-line);transition:width .45s var(--dm-ease),background .35s}
.dm-dpx-dots i.dm-on{width:16px;background:var(--dm-accent-mark,var(--dm-accent))}
.dm-dpx-dots i.dm-done{background:var(--dm-accent-mark,var(--dm-accent));opacity:.4}
.dm-dpx-q{font-size:14px;font-weight:500;line-height:20px;margin-bottom:var(--dm-s-3);text-wrap:balance}
.dm-dpx-opts{display:flex;flex-direction:column;gap:6px}
/* (its key chip and its count sit as far in from its two ends) */
.dm-dpx-o{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:6px 10px;border-radius:var(--dm-r-in);font-size:13.5px;text-align:left;color:var(--dm-fg2);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-pick-line) 50%,transparent);transition:background-color .25s,color .25s,box-shadow .25s}
@media (hover:hover) and (pointer:fine){.dm-dpx-o:hover{background:var(--dm-row);color:var(--dm-fg)}}
.dm-dpx-o.dm-on{color:var(--dm-fg);box-shadow:inset 0 0 0 1px var(--dm-pick-on)}
.dm-dpx-o .dm-kbd{width:20px;flex:none;text-align:center;transition:background .25s,color .25s}
.dm-dpx-o.dm-on .dm-kbd{background:var(--dm-accent);color:var(--dm-on-accent)}
.dm-dpx-o .dm-d{margin-left:auto;font-size:12px;color:var(--dm-muted)}
.dm-dpx-f{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-height:28px}
/* the footer, its buttons or the line saying the agent has started, sits under a hairline in Soft and Blueprint (owner, 21 Nov:
   "add a divider line above the loading text"), 16px under the content and 16px over what it holds, as the card's own edges
   are; Studio's foot strip has its own (below) */
.dm-dpx-f{margin-top:var(--dm-s-1);padding-top:var(--dm-s-4);border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
/* Continue's Enter key is a glyph beside its word, with no tile of its own (owner, 21 Nov: "not a fan of a squircle button
   inside a rounded button"): the same gap as an icon's, and the button's padding even at both ends */
.dm-dpx-f .dm-pill.dm-dpx-go .dm-kbd{min-width:0;height:auto;padding:0;margin:0;border-radius:0;background:none;box-shadow:none;color:inherit;font-size:13px;line-height:1}
/* nothing in it grows or shrinks when it is pressed (owner, 18 Nov); Studio's ink primary alone presses */
.dm-dpx .dm-pill:active{transform:none}
.dm-dpx-sum{display:flex;flex-direction:column}
.dm-dpx-sr{display:flex;gap:10px;font-size:13px;line-height:20px;padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.dm-dpx-sr:first-child{padding-top:0}
.dm-dpx-sr:last-child{border:0;padding-bottom:0}
.dm-dpx-sr span{color:var(--dm-muted);width:92px;flex:none}
/* answered: the line saying the agent has started, where the buttons were, its mark on the content's left edge; a tick
   once it has started is the vivid mark green */
.dm-dpx-f.dm-run{justify-content:flex-start}
.dm-dpx-run{display:flex;align-items:center;gap:var(--dm-s-2);min-width:0;font-size:13px;line-height:20px}
.dm-dpx-ok{display:grid;color:var(--dm-ok-mark)}
/* its motion (owner's trial, 26 Nov; the core's motion pieces): a press on an answer shows at once (.mx-press, no scale); the
   question answered leaves to one side and the next comes in from the other, piece by piece, as the card eases to its new
   height on a spring (.mx-grow); the summary's rows rise in 50ms apart */
/* Studio (owner, 19 Nov): its content 16px from every edge, and an off-white foot strip whose buttons sit 16px from the card's
   edges and the strip's hairline (owner, 23 Nov); the strip starts 16px under the answers. The answers are 10px round tiles with a
   hairline, the picked one's a step stronger and its number in ink, and the progress dots are the accent, white in dark mode, as
   every Studio loader is. Continue is the ink button, its Enter key in a quiet chip of its own ink. Once answered, the strip holds the
   line saying the agent has started, its words 16px in */
:root[data-style="studio"] .dm-dpx.dm-panel,:root [data-style="studio"] .dm-dpx.dm-panel,:root [data-style="studio"].dm-dpx.dm-panel{padding:16px 16px 0}
:root[data-style="studio"] .dm-dpx-dots i,:root [data-style="studio"] .dm-dpx-dots i,:root [data-style="studio"].dm-dpx-dots i{background:var(--dm-rail);transition:width var(--dm-t) var(--dm-ease),background-color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-dpx-dots i.dm-on,:root [data-style="studio"] .dm-dpx-dots i.dm-on,:root [data-style="studio"].dm-dpx-dots i.dm-on{background:var(--dm-accent-mark)}
:root[data-style="studio"] .dm-dpx-dots i.dm-done,:root [data-style="studio"] .dm-dpx-dots i.dm-done,:root [data-style="studio"].dm-dpx-dots i.dm-done{background:var(--dm-accent-mark);opacity:.3}
:root[data-style="studio"] .dm-dpx-run .dm-think,:root [data-style="studio"] .dm-dpx-run .dm-think,:root [data-style="studio"].dm-dpx-run .dm-think{color:var(--dm-accent-mark)}
/* (an answer's key chip under the pointer takes the card's surface, so it shows on the hover's fill in both themes) */
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-dpx-o:not(.dm-ahx *):hover:not(.dm-on) .dm-kbd,:root [data-style="studio"] .dm-dpx-o:not(.dm-ahx *):hover:not(.dm-on) .dm-kbd,:root [data-style="studio"].dm-dpx-o:not(.dm-ahx *):hover:not(.dm-on) .dm-kbd{background:var(--dm-surface)}}
:root[data-style="studio"] .dm-dpx-o,:root [data-style="studio"] .dm-dpx-o,:root [data-style="studio"].dm-dpx-o{border-radius:10px;box-shadow:inset 0 0 0 1px var(--dm-hair);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-dpx-o.dm-on,:root [data-style="studio"] .dm-dpx-o.dm-on,:root [data-style="studio"].dm-dpx-o.dm-on{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-fg) 26%,transparent)}
:root[data-style="studio"] .dm-dpx-o .dm-kbd,:root [data-style="studio"] .dm-dpx-o .dm-kbd,:root [data-style="studio"].dm-dpx-o .dm-kbd{transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-dpx-o.dm-on .dm-kbd,:root [data-style="studio"] .dm-dpx-o.dm-on .dm-kbd,:root [data-style="studio"].dm-dpx-o.dm-on .dm-kbd{background:var(--dm-fg);color:var(--dm-surface)}
:root[data-style="studio"] .dm-dpx.dm-panel .dm-dpx-f,:root [data-style="studio"] .dm-dpx.dm-panel .dm-dpx-f,:root [data-style="studio"].dm-dpx.dm-panel .dm-dpx-f{margin:4px -16px 0;padding:var(--dm-strip-y) 16px;gap:4px;min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);border-top:1px solid var(--dm-line);background:var(--dm-strip);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
:root[data-style="studio"] .dm-dpx.dm-panel .dm-dpx-f.dm-run,:root [data-style="studio"] .dm-dpx.dm-panel .dm-dpx-f.dm-run,:root [data-style="studio"].dm-dpx.dm-panel .dm-dpx-f.dm-run{padding-left:16px}
/* (a step of --dm-ok in the vivid green keeps the tick at 3:1 on the off-white strip, as Attachment tray's does) */
:root[data-style="studio"] .dm-dpx.dm-panel .dm-dpx-ok,:root [data-style="studio"] .dm-dpx.dm-panel .dm-dpx-ok,:root [data-style="studio"].dm-dpx.dm-panel .dm-dpx-ok{color:color-mix(in srgb,var(--dm-ok-mark) 80%,var(--dm-ok))}
DecisionPrompt.astroAstro · 29 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Decision prompt: The agent asks a few quick questions before it starts.
// The markup, CSS and script are designme.dev's own, run by the shared core in ../core, which mounts the component when it scrolls
// into view and plays its demo. To show your own data, change decision-prompt.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './decision-prompt.css';

export interface Props extends HTMLAttributes<'div'> {
  /** "soft" or "studio" draws it in that style. Leave it out for Blueprint, or for the style set on <html> (data-style="soft" or "studio") */
  'data-style'?: 'soft' | 'studio';
}
const { class: className, ...rest } = Astro.props;
---
<div class:list={['card', className]} data-c="decision-prompt" {...rest}>
  <div class="stage-in"><Fragment is:raw>
<div class="dpx panel mx-grow" tabindex="0">
  <div class="dpx-h"><span class="dpx-k muted num">Question 1 of 3</span><div class="dpx-dots"><i class="on"></i><i></i><i></i></div></div>
  <div class="dpx-body"></div>
  <div class="dpx-f"><button class="pill ghost sm dpx-skip">Skip</button><button class="pill primary sm dpx-go">Continue <span class="kbd">↵</span></button></div>
  <p class="dpx-live" aria-live="polite"></p>
</div>
  </Fragment></div>
</div>
<script>
  import './decision-prompt.js';
</script>
decision-prompt.htmlHTML · 11 lines
<div class="card" data-c="decision-prompt">
  <div class="stage-in">
    <div class="dpx panel mx-grow" tabindex="0">
      <div class="dpx-h"><span class="dpx-k muted num">Question 1 of 3</span><div class="dpx-dots"><i class="on"></i><i></i><i></i></div></div>
      <div class="dpx-body"></div>
      <div class="dpx-f"><button class="pill ghost sm dpx-skip">Skip</button><button class="pill primary sm dpx-go">Continue <span class="kbd">↵</span></button></div>
      <p class="dpx-live" aria-live="polite"></p>
    </div>
  </div>
</div>
decision-prompt.cssHTML · 76 lines
/* ---------- Decision prompt ---------- */
/* the agent asks in the chat: no container; with .panel it becomes a card. Each answer is a tile to pick (a click, its
   number or the arrows): white with a dimmed grey edge, the picked one's edge a step stronger and its number filled. No
   room is kept for what comes next (owner, 18 Nov): the card grows and shrinks with what it shows (grow()), and once every
   question is answered the line saying the agent has started takes the buttons' place */
.dpx{padding:var(--dm-s-4) 0;display:flex;flex-direction:column;gap:var(--dm-s-3);outline:0;border-radius:var(--dm-r-in)}
.dpx.panel{padding:var(--dm-s-4);border-radius:var(--dm-r-card)}
.dpx:focus-visible{outline:2px solid var(--dm-focus);outline-offset:6px}
.dpx-h{display:flex;align-items:center;justify-content:space-between}
/* once every question is answered the head goes, label and dots (owner, 23 Nov: "All set" said what the card already shows):
   the card eases to its new height with its usual grow(), its first summary row 16px from the top, and a hidden line tells
   screen readers that every question is answered. (Agent harness keeps staging's head under its own rules) */
.dpx.done .dpx-h{display:none}
.dpx-live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.dpx-k{font-size:12px;line-height:16px}
.dpx-dots{display:flex;gap:var(--dm-s-1);transition:opacity var(--dm-t-fast) var(--dm-ease),transform var(--dm-t) var(--dm-ease),visibility 0s}
/* the steps are done once every question is answered (owner, 21 Nov): the dots fade and shrink a little where they are, at
   the style's own pace, and keep their room, so nothing else in the head moves; with reduced motion they are simply gone */
.dpx-dots.gone{opacity:0;transform:scale(.8);visibility:hidden;transition:opacity var(--dm-t-fast) var(--dm-ease),transform var(--dm-t) var(--dm-ease),visibility 0s var(--dm-t)}
@media (prefers-reduced-motion:reduce){.dpx-dots,.dpx-dots.gone{transition:none}}
.dpx-dots i{width:6px;height:6px;border-radius:var(--dm-r-tiny,3px);background:var(--dm-line);transition:width .45s var(--dm-ease),background .35s}
.dpx-dots i.on{width:16px;background:var(--dm-accent-mark,var(--dm-accent))}
.dpx-dots i.done{background:var(--dm-accent-mark,var(--dm-accent));opacity:.4}
.dpx-q{font-size:14px;font-weight:500;line-height:20px;margin-bottom:var(--dm-s-3);text-wrap:balance}
.dpx-opts{display:flex;flex-direction:column;gap:6px}
/* (its key chip and its count sit as far in from its two ends) */
.dpx-o{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:6px 10px;border-radius:var(--dm-r-in);font-size:13.5px;text-align:left;color:var(--dm-fg2);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-pick-line) 50%,transparent);transition:background-color .25s,color .25s,box-shadow .25s}
@media (hover:hover) and (pointer:fine){.dpx-o:hover{background:var(--dm-row);color:var(--dm-fg)}}
.dpx-o.on{color:var(--dm-fg);box-shadow:inset 0 0 0 1px var(--dm-pick-on)}
.dpx-o .kbd{width:20px;flex:none;text-align:center;transition:background .25s,color .25s}
.dpx-o.on .kbd{background:var(--dm-accent);color:var(--dm-on-accent)}
.dpx-o .d{margin-left:auto;font-size:12px;color:var(--dm-muted)}
.dpx-f{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-height:28px}
/* the footer, its buttons or the line saying the agent has started, sits under a hairline in Soft and Blueprint (owner, 21 Nov:
   "add a divider line above the loading text"), 16px under the content and 16px over what it holds, as the card's own edges
   are; Studio's foot strip has its own (below) */
.dpx-f{margin-top:var(--dm-s-1);padding-top:var(--dm-s-4);border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
/* Continue's Enter key is a glyph beside its word, with no tile of its own (owner, 21 Nov: "not a fan of a squircle button
   inside a rounded button"): the same gap as an icon's, and the button's padding even at both ends */
.dpx-f .pill.dpx-go .kbd{min-width:0;height:auto;padding:0;margin:0;border-radius:0;background:none;box-shadow:none;color:inherit;font-size:13px;line-height:1}
/* nothing in it grows or shrinks when it is pressed (owner, 18 Nov); Studio's ink primary alone presses */
.dpx .pill:active{transform:none}
.dpx-sum{display:flex;flex-direction:column}
.dpx-sr{display:flex;gap:10px;font-size:13px;line-height:20px;padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.dpx-sr:first-child{padding-top:0}
.dpx-sr:last-child{border:0;padding-bottom:0}
.dpx-sr span{color:var(--dm-muted);width:92px;flex:none}
/* answered: the line saying the agent has started, where the buttons were, its mark on the content's left edge; a tick
   once it has started is the vivid mark green */
.dpx-f.run{justify-content:flex-start}
.dpx-run{display:flex;align-items:center;gap:var(--dm-s-2);min-width:0;font-size:13px;line-height:20px}
.dpx-ok{display:grid;color:var(--dm-ok-mark)}
/* its motion (owner's trial, 26 Nov; the core's motion pieces): a press on an answer shows at once (.mx-press, no scale); the
   question answered leaves to one side and the next comes in from the other, piece by piece, as the card eases to its new
   height on a spring (.mx-grow); the summary's rows rise in 50ms apart */
/* Studio (owner, 19 Nov): its content 16px from every edge, and an off-white foot strip whose buttons sit 16px from the card's
   edges and the strip's hairline (owner, 23 Nov); the strip starts 16px under the answers. The answers are 10px round tiles with a
   hairline, the picked one's a step stronger and its number in ink, and the progress dots are the accent, white in dark mode, as
   every Studio loader is. Continue is the ink button, its Enter key in a quiet chip of its own ink. Once answered, the strip holds the
   line saying the agent has started, its words 16px in */
:root[data-style="studio"] .dpx.panel,:root [data-style="studio"] .dpx.panel,:root [data-style="studio"].dpx.panel{padding:16px 16px 0}
:root[data-style="studio"] .dpx-dots i,:root [data-style="studio"] .dpx-dots i,:root [data-style="studio"].dpx-dots i{background:var(--dm-rail);transition:width var(--dm-t) var(--dm-ease),background-color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dpx-dots i.on,:root [data-style="studio"] .dpx-dots i.on,:root [data-style="studio"].dpx-dots i.on{background:var(--dm-accent-mark)}
:root[data-style="studio"] .dpx-dots i.done,:root [data-style="studio"] .dpx-dots i.done,:root [data-style="studio"].dpx-dots i.done{background:var(--dm-accent-mark);opacity:.3}
:root[data-style="studio"] .dpx-run .think,:root [data-style="studio"] .dpx-run .think,:root [data-style="studio"].dpx-run .think{color:var(--dm-accent-mark)}
/* (an answer's key chip under the pointer takes the card's surface, so it shows on the hover's fill in both themes) */
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dpx-o:not(.ahx *):hover:not(.on) .kbd,:root [data-style="studio"] .dpx-o:not(.ahx *):hover:not(.on) .kbd,:root [data-style="studio"].dpx-o:not(.ahx *):hover:not(.on) .kbd{background:var(--dm-surface)}}
:root[data-style="studio"] .dpx-o,:root [data-style="studio"] .dpx-o,:root [data-style="studio"].dpx-o{border-radius:10px;box-shadow:inset 0 0 0 1px var(--dm-hair);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dpx-o.on,:root [data-style="studio"] .dpx-o.on,:root [data-style="studio"].dpx-o.on{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-fg) 26%,transparent)}
:root[data-style="studio"] .dpx-o .kbd,:root [data-style="studio"] .dpx-o .kbd,:root [data-style="studio"].dpx-o .kbd{transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dpx-o.on .kbd,:root [data-style="studio"] .dpx-o.on .kbd,:root [data-style="studio"].dpx-o.on .kbd{background:var(--dm-fg);color:var(--dm-surface)}
:root[data-style="studio"] .dpx.panel .dpx-f,:root [data-style="studio"] .dpx.panel .dpx-f,:root [data-style="studio"].dpx.panel .dpx-f{margin:4px -16px 0;padding:var(--dm-strip-y) 16px;gap:4px;min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);border-top:1px solid var(--dm-line);background:var(--dm-strip);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
:root[data-style="studio"] .dpx.panel .dpx-f.run,:root [data-style="studio"] .dpx.panel .dpx-f.run,:root [data-style="studio"].dpx.panel .dpx-f.run{padding-left:16px}
/* (a step of --dm-ok in the vivid green keeps the tick at 3:1 on the off-white strip, as Attachment tray's does) */
:root[data-style="studio"] .dpx.panel .dpx-ok,:root [data-style="studio"] .dpx.panel .dpx-ok,:root [data-style="studio"].dpx.panel .dpx-ok{color:color-mix(in srgb,var(--dm-ok-mark) 80%,var(--dm-ok))}
decision-prompt.jsHTML · 50 lines
DM.def('decision-prompt', (r, c) => {
  const Q = [
    ['Which frames should the agent redesign?', 'Frames', [['Pricing only','1 frame'],['Pricing and checkout','3 frames'],['The whole flow','9 frames']]],
    ['How bold can the changes be?', 'Scope', [['Polish spacing and type','Safe'],['Rework the layout','Medium'],['Fresh direction','Bold']]],
    ['Where should the result go?', 'Output', [['New Figma page','Keeps the original'],['Branch in the repo','Opens a PR'],['Both','Recommended']]]
  ];
  const ans = []; let qi = 0, sel = 0, done = false, turning = false;
  const body = $('.dpx-body', r), k = $('.dpx-k', r), dots = $$('.dpx-dots i', r), go = $('.dpx-go', r), skip = $('.dpx-skip', r), card = $('.dpx', r), foot = $('.dpx-f', r);
  // its motion pieces (owner's trial, 26 Nov): Agent harness, which places it in its chat, keeps it as it was
  const mx = !r.closest('.ahx');
  // no room is kept for the next question or the summary: the card grows and shrinks with them, once its entrance (which
  // scales it from .98 in Studio) has ended, so it measures the card at its real size
  Promise.resolve().then(() => Promise.all(card.getAnimations().map(a => a.finished.catch(() => {})))).then(() => { if (!c.dead && card.isConnected) c.offs.push(grow(card)); });
  function paint(){
    k.textContent = 'Question ' + (qi + 1) + ' of 3';
    dots.forEach((d, i) => { d.classList.toggle('on', i === qi); d.classList.toggle('done', i < qi); });
    const q = Q[qi];
    body.innerHTML = `<div class="dpx-q">${q[0]}</div><div class="dpx-opts" role="radiogroup" aria-label="${q[0]}">` + q[2].map((o, i) => `<button class="dpx-o${i === sel ? ' on' : ''}${mx ? ' mx-press' : ''}" role="radio" aria-checked="${i === sel}" data-i="${i}"><span class="kbd">${i + 1}</span>${o[0]}<span class="d">${o[1]}</span></button>`).join('') + '</div>';
    // the next question plays its entrance; the first comes in with the card's own entrance and is drawn from the start, so a
    // frame that doesn't animate yet (a small live preview off screen, as on the docs' Introduction) still shows it
    // (the motion pieces' next question comes in from the side it moves towards, one piece after another, as the card eases to
    // its height)
    if (qi){ if (mx) mxIn([$('.dpx-q', body), ...$$('.dpx-o', body)], { x:12, base:20 }); else { enter($('.dpx-q', body)); stagger($$('.dpx-o', body), 50, 60); } }
    $$('.dpx-o', body).forEach(b => { b.onclick = () => choose(+b.dataset.i); b.ondblclick = next; });
  }
  function choose(i){ sel = i; $$('.dpx-o', body).forEach((b, j) => { b.classList.toggle('on', j === i); b.setAttribute('aria-checked', j === i); }); }
  // (with the motion pieces, the question answered leaves to the side first, quickly, and the next one comes in from the other;
  // a key pressed while it turns waits for it)
  const turn = (els, then) => { if (!mx || REDUCE){ then(); return; } turning = true; mxOut(els, { x:-12 }).then(() => { turning = false; if (!c.dead) then(); }); };
  function next(skipped){
    if (done || turning) return; ans.push(skipped === true ? 'Agent decides' : Q[qi][2][sel][0]); qi++; sel = 0;
    if (qi < Q.length) return turn([...body.children], paint);
    // the steps are over: the dots fade away where they are (owner, 21 Nov), and the head keeps its place
    done = true; dots.forEach(d => { d.classList.remove('on'); d.classList.add('done'); }); $('.dpx-dots', r).classList.add('gone'); $('.dpx-live', r).textContent = 'All questions answered';
    // the buttons give way to the line saying the agent has started (its words shimmer while it gets going); a focus that
    // was on them comes back to the card. With the motion pieces the head, the last question and the buttons leave first
    const had = foot.contains(document.activeElement);
    turn([$('.dpx-k', r), ...body.children, ...foot.children], () => {
      k.textContent = 'All set'; card.classList.add('done');
      body.innerHTML = `<div class="dpx-sum">${Q.map((q, i) => `<div class="dpx-sr"><span>${q[1]}</span>${ans[i]}</div>`).join('')}</div>`;
      foot.classList.add('run'); foot.innerHTML = `<div class="dpx-run" aria-live="polite"><span class="think on"><i></i><i></i><i></i><i></i></span><span class="shim">Starting the redesign</span></div>`;
      if (had) giveBack(card);
      if (mx) mxIn([...$$('.dpx-sr', body), $('.dpx-run', foot)], { step:50 }); else stagger([...$$('.dpx-sr', body), $('.dpx-run', foot)], 70);
    });
  }
  go.onclick = () => next(); skip.onclick = () => next(true);
  c.on(card, 'keydown', e => { if (done || turning) return; if (/^[1-3]$/.test(e.key)){ choose(+e.key - 1); e.preventDefault(); } else if (e.key === 'Enter'){ next(); e.preventDefault(); } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp'){ choose((sel + (e.key === 'ArrowDown' ? 1 : 2)) % 3); e.preventDefault(); } });
  paint();
});
06

Questions

What people ask about it.

How do I get the answers to my agent?
Use onComplete. It receives an array with the chosen option's index for each question, or null where the person skipped.
Does the keyboard work right away?
The whole prompt is focusable, so the keys work once it has focus, for example after clicking an option. Number keys pick, arrows move and Enter continues.
How do I show that the agent has actually started?
Set started to true. The shimmering startLabel line turns into a check with startedLabel, or the same text if you leave that out.
07

More in Review and approve

Moments where a person checks, steers or signs off on the agent's work.

Plan reviewCheck the agent's plan, edit steps, then let it run.
Permission gateThe agent asks before it touches something new.
Action cardsWhat is waiting on you, each card with its button and a small picture of what it opens.
Inline text diffThe agent's edits to a piece of copy, accepted or rejected one by one.