Skip to content
Star

Feedback sheet

Rate an answer and tell the agent what missed. 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 feedback-sheet
$npx shadcn@latest add https://designme.dev/r/shadcn/feedback-sheet.json

Need this designed into your product? Book a call

I tightened the hero spacing to 24px and swapped the CTA to the accent blue. The card grid now wraps at 720px.

What went wrong?
Shared with the agent for this project
01

Install

Add it to your project with the CLI.

HTML, CSS and JS

$npx designme add feedback-sheet

React

$npx designme add feedback-sheet --react

Astro

$npx designme add feedback-sheet --astro

shadcn, React

$npx shadcn@latest add https://designme.dev/r/shadcn/feedback-sheet.json

shadcn, Astro

$npx shadcn@latest add https://designme.dev/r/shadcn/astro/feedback-sheet.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.

Feedback sheet puts thumbs up and thumbs down under an agent's answer. A thumbs down opens a short sheet where the person picks what went wrong from quick reasons, adds a note, and sends it, so the agent can do better next time.

  • When you want ratings on agent answers and the reasons behind the bad ones.
  • When feedback should be stored per project, like a memory of what the agent should avoid.
  • When a rating should cost one click and the longer form should only appear when something went wrong.
03

Usage

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

React

import { FeedbackSheet } from '@/components/designme/feedback-sheet/FeedbackSheet';

React example

The demo above as a React component, 44 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 { useRef, useState } from 'react';
import { useStory, useWait } from '../lib/useScript';
import { FeedbackSheet, type Feedback, type FeedbackRating } from './FeedbackSheet';

/* ---------- Feedback sheet: thumbs under an answer; thumbs down opens a short sheet. It plays a thumbs down by itself,
   and clicking, focusing or typing inside it takes over ---------- */
const NOTE = 'Keep our 8px spacing scale';

export default function FeedbackSheetDemo() {
  const [rating, setRating] = useState<FeedbackRating>(null);
  const [open, setOpen] = useState(false);
  const [selected, setSelected] = useState<string[]>([]);
  const [comment, setComment] = useState('');
  const [sending, setSending] = useState(false);
  const [sent, setSent] = useState<Feedback | null>(null);
  const ref = useRef<HTMLDivElement>(null), later = useWait();

  useStory(ref, async ({ wait, taken }) => {
    // taking over while it types takes its note back
    let writing = false;
    taken(() => { if (writing) setComment(''); });
    await wait(1500); setRating('down'); setOpen(true);
    await wait(1000); setSelected(['Ignored my tokens']);
    await wait(700); writing = true;
    for (let i = 1; i <= NOTE.length; i++) { setComment(NOTE.slice(0, i)); await wait(34 + Math.random() * 40); }
    await wait(650); writing = false; setSending(true);
    // once sent, it goes through whatever happens next
    await later(800); setSending(false); setOpen(false);
    await later(300); setSent({ reasons: ['Ignored my tokens'], comment: NOTE });
  });

  return (
    <div ref={ref} style={{ width: '100%' }}>
      <FeedbackSheet rating={rating} onRatingChange={setRating} open={open} onOpenChange={setOpen} selected={selected} onSelectedChange={setSelected}
        comment={comment} onCommentChange={setComment} sending={sending || undefined} sent={sent} onSentChange={setSent}
        onSubmit={() => new Promise(res => setTimeout(res, 800))}>
        I tightened the hero spacing to 24px and swapped the CTA to the accent blue. The card grid now wraps at 720px.
      </FeedbackSheet>
    </div>
  );
}

Astro

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

---
import FeedbackSheet from '../components/designme/feedback-sheet/FeedbackSheet.astro';
---
<FeedbackSheet />
<FeedbackSheet data-style="soft" class="my-class" />
04

Props

Everything FeedbackSheet takes.

PropTypeWhat it does
childrenReactNodeThe answer being rated, shown above the thumbs
ratingFeedbackRatingWhether the answer was rated good or bad. Leave it out to let the thumbs set it
defaultRatingFeedbackRating
onRatingChange(rating: FeedbackRating) => void
openbooleanWhether the reasons sheet is open. Leave it out and thumbs down opens it
defaultOpenboolean
onOpenChange(open: boolean) => void
selectedstring[]The reasons picked. Leave it out to let the chips keep it
defaultSelectedstring[]
onSelectedChange(selected: string[]) => void
commentstringWhat is written in the box. Leave it out to let the box keep it
defaultCommentstring
onCommentChange(comment: string) => void
sendingbooleanShows the spinner on Send, for a scripted demo. A promise from onSubmit shows it by itself
sentFeedback | nullWhat was sent, which shows the thank-you line. Leave it out and Send sets it
onSentChange(sent: Feedback | null) => void
questionstringThe heading of the sheet that opens on thumbs down
reasonsstring[]Quick reasons to pick from
placeholderstring
notestringA quiet note beside the buttons, like who sees the feedback
onSubmit(feedback: Feedback) => void | Promise<void>Called with what the person picked and wrote. Return a promise to show a spinner until it settles
thanks(feedback: Feedback) => ReactNodeWhat to say once it is sent. Defaults to a line about what the agent will do next time
barebooleanSits flat under a message in a chat thread (the default, as on designme.dev). Set false to give it a card of its own
classNamestring
05

Code

The full source, as the CLI installs it.

FeedbackSheet.tsxReact · 139 lines
'use client';
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect, useReducedMotion } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { Fold, growFit, mxIn, mxT, Spin, Swap, Tip } from '../lib/motion';
import '../designme.css';
import './feedback-sheet.css';

export type FeedbackRating = 'up' | 'down' | null;
export interface Feedback { reasons: string[]; comment: string }

export interface FeedbackSheetProps {
  /** The answer being rated, shown above the thumbs */
  children?: ReactNode;
  /** Whether the answer was rated good or bad. Leave it out to let the thumbs set it */
  rating?: FeedbackRating;
  defaultRating?: FeedbackRating;
  onRatingChange?: (rating: FeedbackRating) => void;
  /** Whether the reasons sheet is open. Leave it out and thumbs down opens it */
  open?: boolean;
  defaultOpen?: boolean;
  onOpenChange?: (open: boolean) => void;
  /** The reasons picked. Leave it out to let the chips keep it */
  selected?: string[];
  defaultSelected?: string[];
  onSelectedChange?: (selected: string[]) => void;
  /** What is written in the box. Leave it out to let the box keep it */
  comment?: string;
  defaultComment?: string;
  onCommentChange?: (comment: string) => void;
  /** Shows the spinner on Send, for a scripted demo. A promise from onSubmit shows it by itself */
  sending?: boolean;
  /** What was sent, which shows the thank-you line. Leave it out and Send sets it */
  sent?: Feedback | null;
  onSentChange?: (sent: Feedback | null) => void;
  /** The heading of the sheet that opens on thumbs down */
  question?: string;
  /** Quick reasons to pick from */
  reasons?: string[];
  placeholder?: string;
  /** A quiet note beside the buttons, like who sees the feedback */
  note?: string;
  /** Called with what the person picked and wrote. Return a promise to show a spinner until it settles */
  onSubmit?: (feedback: Feedback) => void | Promise<void>;
  /** What to say once it is sent. Defaults to a line about what the agent will do next time */
  thanks?: (feedback: Feedback) => ReactNode;
  /** Sits flat under a message in a chat thread (the default, as on designme.dev). Set false to give it a card of its own */
  bare?: boolean;
  className?: string;
}

const REASONS = ['Wrong spacing', 'Ignored my tokens', 'Too many changes', 'Broke the layout'];
const THANKS = (f: Feedback) => `Thanks. The agent will ${f.reasons.length ? 'avoid this' : 'use this'} next time in this project.`;

/** Rate an answer, and say what missed when it was wrong. */
export function FeedbackSheet({ children, rating, defaultRating = null, onRatingChange, open: openProp, defaultOpen = false, onOpenChange,
  selected, defaultSelected = [], onSelectedChange, comment: commentProp, defaultComment = '', onCommentChange, sending: sendingProp, sent: sentProp, onSentChange, question = 'What went wrong?', reasons = REASONS, placeholder = 'Anything else the agent should know', note = 'Shared with the agent for this project', onSubmit, thanks = THANKS, bare = true, className }: FeedbackSheetProps) {
  const [rate, setRate] = useControllable<FeedbackRating>(rating, defaultRating, onRatingChange);
  const [open, setOpen] = useControllable(openProp, defaultOpen, onOpenChange);
  const [picked, setPicked] = useControllable(selected, defaultSelected, onSelectedChange);
  const [comment, setComment] = useControllable(commentProp, defaultComment, onCommentChange);
  const [busy, setBusy] = useState(false);
  const sending = sendingProp ?? busy;
  const [sent, setSent] = useControllable<Feedback | null>(sentProp, null, onSentChange);
  // the container grows with what it holds, in one smooth motion (growFit, grow() on the site), and stays centred wherever it
  // is centred, in every style (owner, 18 Nov; 26 Nov: no jitter)
  const root = useRef<HTMLDivElement>(null), inner = useRef<HTMLDivElement>(null);
  useIsoLayoutEffect(() => { const el = root.current, w = inner.current; if (el && w) return growFit(el, w); }, []);
  // sent, it says so once: the thank-you line under the bar, nothing beside the thumbs
  const status = sent ? '' : rate === 'up' ? 'Thanks, noted' : '';
  const box = useRef<HTMLTextAreaElement>(null);
  // Send is as wide as what it shows (its word, or the spinner while it sends) and eases between the two
  const go = useRef<HTMLButtonElement>(null), goW = useRef(0), reduce = useReducedMotion();
  useIsoLayoutEffect(() => {
    const b = go.current; if (!b) return; const w = b.offsetWidth;
    if (goW.current && w && goW.current !== w && !reduce) b.animate([{ width: goW.current + 'px' }, { width: w + 'px' }], { duration: mxT(b, 't-in', 360), easing: mxT(b, 'ease-spring', 'ease') });
    goW.current = w;
  }, [sending]);
  // as the sheet opens, its question, its reasons and the box rise in one after another (motion pieces)
  const sheet = useRef<HTMLDivElement>(null), wasOpen = useRef(open);
  useIsoLayoutEffect(() => {
    const el = sheet.current, was = wasOpen.current; wasOpen.current = open; if (!open || was || !el) return;
    mxIn([el.querySelector('.dm-fbx-q'), ...el.querySelectorAll('.dm-fbx-ch .dm-chip'), el.querySelector('.dm-fbx-ta')], { base: 60 });
  }, [open]);
  const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
  const later = (ms: number, fn: () => void) => { timers.current.push(setTimeout(fn, ms)); };
  useEffect(() => () => timers.current.forEach(clearTimeout), []);

  const up = () => { const on = rate !== 'up'; setRate(on ? 'up' : null); setOpen(false); };
  const down = () => {
    const on = rate !== 'down'; setRate(on ? 'down' : null); setOpen(on);
    // the sheet opens first, then the cursor goes to the box
    if (on) later(350, () => box.current?.focus({ preventScroll: true }));
  };
  const send = async () => {
    if (sending) return;
    const f = { reasons: picked, comment: comment.trim() };
    setBusy(true);
    // if sending fails the sheet stays open so the person can try again
    try { await onSubmit?.(f); } catch (e) { setBusy(false); throw e; }
    setBusy(false); setOpen(false);
    later(300, () => setSent(f));
  };

  return (
    <div data-dm="" ref={root} className={cx('dm-fbx', !bare && 'dm-panel', 'dm-growing dm-mx-grow', className)} style={bare ? undefined : { padding: 16 }}>
      <div ref={inner} className="dm-grow">
      {children && <div className="dm-msg">{children}</div>}
      <div className="dm-fbx-bar">
        <Tip label="Good answer"><button type="button" className={cx('dm-ib dm-fbx-up dm-mx-press', rate === 'up' && 'dm-on')} aria-label="Good answer" aria-pressed={rate === 'up'} onClick={up}><Icon name="up-thumb" /></button></Tip>
        <Tip label="Bad answer"><button type="button" className={cx('dm-ib dm-fbx-dn dm-mx-press', rate === 'down' && 'dm-on')} aria-label="Bad answer" aria-pressed={rate === 'down'} onClick={down}><Icon name="down-thumb" /></button></Tip>
        <Swap className="dm-fbx-st dm-muted">{status}</Swap>
      </div>
      <Fold open={open} className="dm-fbx-box">
        <div ref={sheet} className="dm-fbx-in dm-panel">
          <div className="dm-fbx-q">{question}</div>
          {reasons.length > 0 && (
            <div className="dm-fbx-ch">
              {reasons.map(r => {
                const on = picked.includes(r);
                return <button key={r} type="button" className={cx('dm-chip dm-sm', on && 'dm-on')} aria-pressed={on} onClick={() => setPicked(on ? picked.filter(x => x !== r) : [...picked, r])}>{r}</button>;
              })}
            </div>
          )}
          <textarea ref={box} className="dm-fbx-ta" rows={2} placeholder={placeholder} value={comment} onChange={e => setComment(e.target.value)} />
          <div className="dm-fbx-f">
            <span className="dm-muted dm-fbx-n">{note}</span>
            <button type="button" className="dm-pill dm-ghost dm-sm dm-fbx-x dm-mx-press" onClick={() => { setOpen(false); setRate(null); }}>Cancel</button>
            <button ref={go} type="button" className="dm-pill dm-primary dm-sm dm-fbx-go" disabled={!(picked.length || comment.trim())} aria-busy={sending} onClick={send}>{sending ? <Spin /> : 'Send'}</button>
          </div>
        </div>
      </Fold>
      {sent && <div className="dm-fbx-thx dm-enter" role="status"><Icon name="ok" /><span>{thanks(sent)}</span></div>}
      </div>
    </div>
  );
}
feedback-sheet.cssReact · 65 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Feedback sheet ---------- */
.dm-fbx{display:flex;flex-direction:column;gap:var(--dm-s-2)}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on a thumb or Cancel shows at once (.mx-press); as the sheet
   opens, its question, its reasons and the box rise in one after another (mxIn()); Send eases to the spinner's width on the
   spring (mxWidth()); and it grows on the spring as the sheet opens and the thanks line comes in (.mx-grow) */
/* the first thumb's icon starts where the answer does */
.dm-fbx-bar{display:flex;align-items:center;gap:2px;margin-left:-8px}
.dm-fbx-bar .dm-ib svg{transition:transform .45s var(--dm-ease)}
.dm-fbx-bar .dm-ib.dm-on svg{transform:rotate(-8deg)}
/* nothing in the row shrinks or swells on a click (owner, 18 Nov): a rated thumb only tilts */
.dm-fbx-bar .dm-ib:active,.dm-fbx-f .dm-pill.dm-ghost:active{transform:none}
/* the thumbs sit on the stage, where --dm-row is the stage's own colour: the bar sets --dm-row to a quiet 5% of the text colour, as
   the other cards on the stage do, so the thumbs keep the one shared hover */
.dm-fbx-bar{--dm-row:color-mix(in srgb,var(--dm-fg) 5%,transparent)}
:root[data-style="studio"] .dm-fbx-bar .dm-ib:active,:root [data-style="studio"] .dm-fbx-bar .dm-ib:active,:root [data-style="studio"].dm-fbx-bar .dm-ib:active{transform:none}
.dm-fbx-dn.dm-on{background:var(--dm-bad-bg);color:var(--dm-bad)}
.dm-fbx-st{font-size:12.5px;margin-left:6px}
.dm-fbx-box>div{margin-inline:-16px;padding-inline:var(--dm-s-4)}
.dm-fbx-in{padding:var(--dm-s-4);display:flex;flex-direction:column;gap:10px;margin:var(--dm-s-1) 0 0}
/* the component grows with what it shows in every style (grow(), owner's notes 18 Nov), and keeps no room under the sheet:
   its shadow shows past the fold and the growing box instead. The fold's own gap goes with it when it is shut */
.dm-fbx.dm-growing,.dm-fbx-box>div{overflow-clip-margin:32px}
.dm-fbx-box{transition:grid-template-rows var(--dm-t) var(--dm-ease),opacity var(--dm-t) var(--dm-ease),margin-top var(--dm-t) var(--dm-ease)}
.dm-fbx-box.dm-shut{margin-top:calc(-1 * var(--dm-s-2));transition:grid-template-rows var(--dm-t) var(--dm-ease),opacity var(--dm-t) var(--dm-ease),margin-top var(--dm-t) var(--dm-ease),visibility 0s var(--dm-t)}
.dm-fbx-q{font-size:13.5px;font-weight:500}
.dm-fbx-ch{display:flex;flex-wrap:wrap;gap:6px}
/* the reasons sit on the sheet: unpicked, they take the grey a step above the chip's own, so they read against what is
   behind them (owner, 23 Nov: "could these be a bit darker?"), and a step more under the pointer; a picked one is the accent
   tint with the accent's text colour. Answer action bar's reasons do the same; Studio keeps its own (below) */
.dm-fbx-ch .dm-chip{background:var(--dm-hover)}
@media (hover:hover) and (pointer:fine){.dm-fbx-ch .dm-chip:hover{background:var(--dm-press)}}
.dm-fbx-ch .dm-chip.dm-on{background:var(--dm-accent-bg);color:var(--dm-accent-fg,var(--dm-accent));box-shadow:none}
.dm-fbx-ta{display:block;width:100%;resize:none;border:0;outline:0;border-radius:var(--dm-r-field);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line) 50%,transparent);padding:10px var(--dm-s-3);font:inherit;font-size:13.5px;line-height:1.5;color:var(--dm-fg);transition:box-shadow var(--dm-t-fast)}
@supports (corner-shape:squircle){.dm-fbx-ta{corner-shape:squircle;border-radius:var(--dm-r-field-sq)}}
.dm-fbx-ta:focus{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line-strong) 50%,transparent)}
.dm-fbx-ta::placeholder{color:var(--dm-muted)}
/* the footer sits under a hairline in Soft and Blueprint (owner, 21 Nov), 12px from it on each side; Studio's is a foot strip */
.dm-fbx-f{display:flex;align-items:center;gap:6px;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)}
.dm-fbx-n{font-size:12px;flex:1;min-width:0}
/* sent: a neutral line with the green tick, no green fill (owner, 18 Nov: a finished state) */
.dm-fbx-thx{display:flex;align-items:center;gap:var(--dm-s-2);font-size:13px;line-height:20px;color:var(--dm-fg2)}
.dm-fbx-thx svg{flex:none;color:var(--dm-ok-mark)}
@media (max-width:480px){.dm-fbx-n{display:none}}
/* Studio (owner, 18 Nov): the sheet's content sits 16px in from its edges, and its foot is an off-white strip: the note
   starts where the question does, and Cancel and Send are 28px pills 16px from the card's edges and the strip's hairline (owner, 23 Nov).
   The first thumb's icon starts where the answer and the sheet do. The chrome is monochrome: a rated
   thumb fills in ink on the selected fill in its round shape (owner, 23 Nov), with no red and no tilt and a picked reason is an ink chip like a toggle that is on */
:root[data-style="studio"] .dm-fbx-bar .dm-ib.dm-on svg,:root [data-style="studio"] .dm-fbx-bar .dm-ib.dm-on svg,:root [data-style="studio"].dm-fbx-bar .dm-ib.dm-on svg{transform:none}
:root[data-style="studio"] .dm-fbx-bar .dm-ib.dm-on,:root [data-style="studio"] .dm-fbx-bar .dm-ib.dm-on,:root [data-style="studio"].dm-fbx-bar .dm-ib.dm-on{background:var(--dm-row-on);color:var(--dm-fg)}
:root[data-style="studio"] .dm-fbx-bar .dm-ib.dm-on svg,:root [data-style="studio"] .dm-fbx-bar .dm-ib.dm-on svg,:root [data-style="studio"].dm-fbx-bar .dm-ib.dm-on svg{fill:currentColor}
:root[data-style="studio"] .dm-fbx-in.dm-panel,:root [data-style="studio"] .dm-fbx-in.dm-panel,:root [data-style="studio"].dm-fbx-in.dm-panel{gap:12px;margin:4px 0 0;padding:16px 16px 0;overflow:clip}
:root[data-style="studio"] .dm-fbx-q,:root [data-style="studio"] .dm-fbx-q,:root [data-style="studio"].dm-fbx-q{font-size:14px;line-height:20px}
:root[data-style="studio"] .dm-fbx-ch .dm-chip.dm-on,:root [data-style="studio"] .dm-fbx-ch .dm-chip.dm-on,:root [data-style="studio"].dm-fbx-ch .dm-chip.dm-on{background:var(--dm-btn-2);color:var(--dm-on-btn);box-shadow:inset 0 0 0 1px var(--dm-btn-2)}
/* a reason not picked takes the one hover over its fill, easing over 220ms (owner, 21 Nov) */
:root[data-style="studio"] .dm-fbx-ch .dm-chip:not(.dm-on),:root [data-style="studio"] .dm-fbx-ch .dm-chip:not(.dm-on),:root [data-style="studio"].dm-fbx-ch .dm-chip:not(.dm-on){background:var(--dm-chip)}
:root[data-style="studio"] .dm-fbx-ch .dm-chip,:root [data-style="studio"] .dm-fbx-ch .dm-chip,:root [data-style="studio"].dm-fbx-ch .dm-chip{transition:background-color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-fbx-ch .dm-chip:not(.dm-on):hover,:root [data-style="studio"] .dm-fbx-ch .dm-chip:not(.dm-on):hover,:root [data-style="studio"].dm-fbx-ch .dm-chip:not(.dm-on):hover{background:var(--dm-chip);box-shadow:inset 0 0 0 99px var(--dm-row)}}
:root[data-style="studio"] .dm-fbx-f,:root [data-style="studio"] .dm-fbx-f,:root [data-style="studio"].dm-fbx-f{gap:8px;margin:4px -16px 0;padding:var(--dm-strip-y) 16px;background:var(--dm-strip);border-top:1px solid var(--dm-line)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-fbx-f .dm-pill.dm-ghost:hover,:root [data-style="studio"] .dm-fbx-f .dm-pill.dm-ghost:hover,:root [data-style="studio"].dm-fbx-f .dm-pill.dm-ghost:hover{background:var(--dm-row)}}
/* the note keeps to one line, so the strip stays one control tall */
:root[data-style="studio"] .dm-fbx-n,:root [data-style="studio"] .dm-fbx-n,:root [data-style="studio"].dm-fbx-n{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* on a phone the note gives way, and Cancel and Send keep to the right edge */
:root[data-style="studio"] .dm-fbx-x,:root [data-style="studio"] .dm-fbx-x,:root [data-style="studio"].dm-fbx-x{margin-left:auto}
FeedbackSheet.astroAstro · 37 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Feedback sheet: Rate an answer and tell the agent what missed.
// 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 feedback-sheet.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './feedback-sheet.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', 'bare', className]} data-c="feedback-sheet" {...rest}>
  <div class="stage-in"><Fragment is:raw>
<div class="fbx mx-grow">
  <p class="msg">I tightened the hero spacing to 24px and swapped the CTA to the accent blue. The card grid now wraps at 720px.</p>
  <div class="fbx-bar">
    <button class="ib fbx-up mx-press" aria-label="Good answer" data-tip="Good answer"><svg class="i s"><use href="#i-up-thumb"/></svg></button>
    <button class="ib fbx-dn mx-press" aria-label="Bad answer" data-tip="Bad answer"><svg class="i s"><use href="#i-down-thumb"/></svg></button>
    <span class="fbx-st muted"></span>
  </div>
  <div class="fold shut fbx-box"><div><div class="fbx-in panel keep">
    <div class="fbx-q">What went wrong?</div>
    <div class="fbx-ch"><button class="chip sm">Wrong spacing</button><button class="chip sm">Ignored my tokens</button><button class="chip sm">Too many changes</button><button class="chip sm">Broke the layout</button></div>
    <textarea class="fbx-ta" rows="2" placeholder="Anything else the agent should know"></textarea>
    <div class="fbx-f"><span class="muted fbx-n">Shared with the agent for this project</span><button class="pill ghost sm fbx-x mx-press">Cancel</button><button class="pill primary sm fbx-go" disabled>Send</button></div>
  </div></div></div>
</div>
  </Fragment></div>
</div>
<script>
  import './feedback-sheet.js';
</script>
feedback-sheet.htmlHTML · 19 lines
<div class="card bare" data-c="feedback-sheet">
  <div class="stage-in">
    <div class="fbx mx-grow">
      <p class="msg">I tightened the hero spacing to 24px and swapped the CTA to the accent blue. The card grid now wraps at 720px.</p>
      <div class="fbx-bar">
        <button class="ib fbx-up mx-press" aria-label="Good answer" data-tip="Good answer"><svg class="i s"><use href="#i-up-thumb"/></svg></button>
        <button class="ib fbx-dn mx-press" aria-label="Bad answer" data-tip="Bad answer"><svg class="i s"><use href="#i-down-thumb"/></svg></button>
        <span class="fbx-st muted"></span>
      </div>
      <div class="fold shut fbx-box"><div><div class="fbx-in panel keep">
        <div class="fbx-q">What went wrong?</div>
        <div class="fbx-ch"><button class="chip sm">Wrong spacing</button><button class="chip sm">Ignored my tokens</button><button class="chip sm">Too many changes</button><button class="chip sm">Broke the layout</button></div>
        <textarea class="fbx-ta" rows="2" placeholder="Anything else the agent should know"></textarea>
        <div class="fbx-f"><span class="muted fbx-n">Shared with the agent for this project</span><button class="pill ghost sm fbx-x mx-press">Cancel</button><button class="pill primary sm fbx-go" disabled>Send</button></div>
      </div></div></div>
    </div>
  </div>
</div>
feedback-sheet.cssHTML · 64 lines
/* ---------- Feedback sheet ---------- */
.fbx{display:flex;flex-direction:column;gap:var(--dm-s-2)}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on a thumb or Cancel shows at once (.mx-press); as the sheet
   opens, its question, its reasons and the box rise in one after another (mxIn()); Send eases to the spinner's width on the
   spring (mxWidth()); and it grows on the spring as the sheet opens and the thanks line comes in (.mx-grow) */
/* the first thumb's icon starts where the answer does */
.fbx-bar{display:flex;align-items:center;gap:2px;margin-left:-8px}
.fbx-bar .ib svg{transition:transform .45s var(--dm-ease)}
.fbx-bar .ib.on svg{transform:rotate(-8deg)}
/* nothing in the row shrinks or swells on a click (owner, 18 Nov): a rated thumb only tilts */
.fbx-bar .ib:active,.fbx-f .pill.ghost:active{transform:none}
/* the thumbs sit on the stage, where --dm-row is the stage's own colour: the bar sets --dm-row to a quiet 5% of the text colour, as
   the other cards on the stage do, so the thumbs keep the one shared hover */
.fbx-bar{--dm-row:color-mix(in srgb,var(--dm-fg) 5%,transparent)}
:root[data-style="studio"] .fbx-bar .ib:active,:root [data-style="studio"] .fbx-bar .ib:active,:root [data-style="studio"].fbx-bar .ib:active{transform:none}
.fbx-dn.on{background:var(--dm-bad-bg);color:var(--dm-bad)}
.fbx-st{font-size:12.5px;margin-left:6px}
.fbx-box>div{margin-inline:-16px;padding-inline:var(--dm-s-4)}
.fbx-in{padding:var(--dm-s-4);display:flex;flex-direction:column;gap:10px;margin:var(--dm-s-1) 0 0}
/* the component grows with what it shows in every style (grow(), owner's notes 18 Nov), and keeps no room under the sheet:
   its shadow shows past the fold and the growing box instead. The fold's own gap goes with it when it is shut */
.fbx.growing,.fbx-box>div{overflow-clip-margin:32px}
.fbx-box{transition:grid-template-rows var(--dm-t) var(--dm-ease),opacity var(--dm-t) var(--dm-ease),margin-top var(--dm-t) var(--dm-ease)}
.fbx-box.shut{margin-top:calc(-1 * var(--dm-s-2));transition:grid-template-rows var(--dm-t) var(--dm-ease),opacity var(--dm-t) var(--dm-ease),margin-top var(--dm-t) var(--dm-ease),visibility 0s var(--dm-t)}
.fbx-q{font-size:13.5px;font-weight:500}
.fbx-ch{display:flex;flex-wrap:wrap;gap:6px}
/* the reasons sit on the sheet: unpicked, they take the grey a step above the chip's own, so they read against what is
   behind them (owner, 23 Nov: "could these be a bit darker?"), and a step more under the pointer; a picked one is the accent
   tint with the accent's text colour. Answer action bar's reasons do the same; Studio keeps its own (below) */
.fbx-ch .chip{background:var(--dm-hover)}
@media (hover:hover) and (pointer:fine){.fbx-ch .chip:hover{background:var(--dm-press)}}
.fbx-ch .chip.on{background:var(--dm-accent-bg);color:var(--dm-accent-fg,var(--dm-accent));box-shadow:none}
.fbx-ta{display:block;width:100%;resize:none;border:0;outline:0;border-radius:var(--dm-r-field);background:var(--dm-surface);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line) 50%,transparent);padding:10px var(--dm-s-3);font:inherit;font-size:13.5px;line-height:1.5;color:var(--dm-fg);transition:box-shadow var(--dm-t-fast)}
@supports (corner-shape:squircle){.fbx-ta{corner-shape:squircle;border-radius:var(--dm-r-field-sq)}}
.fbx-ta:focus{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dm-field-line-strong) 50%,transparent)}
.fbx-ta::placeholder{color:var(--dm-muted)}
/* the footer sits under a hairline in Soft and Blueprint (owner, 21 Nov), 12px from it on each side; Studio's is a foot strip */
.fbx-f{display:flex;align-items:center;gap:6px;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)}
.fbx-n{font-size:12px;flex:1;min-width:0}
/* sent: a neutral line with the green tick, no green fill (owner, 18 Nov: a finished state) */
.fbx-thx{display:flex;align-items:center;gap:var(--dm-s-2);font-size:13px;line-height:20px;color:var(--dm-fg2)}
.fbx-thx svg{flex:none;color:var(--dm-ok-mark)}
@media (max-width:480px){.fbx-n{display:none}}
/* Studio (owner, 18 Nov): the sheet's content sits 16px in from its edges, and its foot is an off-white strip: the note
   starts where the question does, and Cancel and Send are 28px pills 16px from the card's edges and the strip's hairline (owner, 23 Nov).
   The first thumb's icon starts where the answer and the sheet do. The chrome is monochrome: a rated
   thumb fills in ink on the selected fill in its round shape (owner, 23 Nov), with no red and no tilt and a picked reason is an ink chip like a toggle that is on */
:root[data-style="studio"] .fbx-bar .ib.on svg,:root [data-style="studio"] .fbx-bar .ib.on svg,:root [data-style="studio"].fbx-bar .ib.on svg{transform:none}
:root[data-style="studio"] .fbx-bar .ib.on,:root [data-style="studio"] .fbx-bar .ib.on,:root [data-style="studio"].fbx-bar .ib.on{background:var(--dm-row-on);color:var(--dm-fg)}
:root[data-style="studio"] .fbx-bar .ib.on svg,:root [data-style="studio"] .fbx-bar .ib.on svg,:root [data-style="studio"].fbx-bar .ib.on svg{fill:currentColor}
:root[data-style="studio"] .fbx-in.panel,:root [data-style="studio"] .fbx-in.panel,:root [data-style="studio"].fbx-in.panel{gap:12px;margin:4px 0 0;padding:16px 16px 0;overflow:clip}
:root[data-style="studio"] .fbx-q,:root [data-style="studio"] .fbx-q,:root [data-style="studio"].fbx-q{font-size:14px;line-height:20px}
:root[data-style="studio"] .fbx-ch .chip.on,:root [data-style="studio"] .fbx-ch .chip.on,:root [data-style="studio"].fbx-ch .chip.on{background:var(--dm-btn-2);color:var(--dm-on-btn);box-shadow:inset 0 0 0 1px var(--dm-btn-2)}
/* a reason not picked takes the one hover over its fill, easing over 220ms (owner, 21 Nov) */
:root[data-style="studio"] .fbx-ch .chip:not(.on),:root [data-style="studio"] .fbx-ch .chip:not(.on),:root [data-style="studio"].fbx-ch .chip:not(.on){background:var(--dm-chip)}
:root[data-style="studio"] .fbx-ch .chip,:root [data-style="studio"] .fbx-ch .chip,:root [data-style="studio"].fbx-ch .chip{transition:background-color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .fbx-ch .chip:not(.on):hover,:root [data-style="studio"] .fbx-ch .chip:not(.on):hover,:root [data-style="studio"].fbx-ch .chip:not(.on):hover{background:var(--dm-chip);box-shadow:inset 0 0 0 99px var(--dm-row)}}
:root[data-style="studio"] .fbx-f,:root [data-style="studio"] .fbx-f,:root [data-style="studio"].fbx-f{gap:8px;margin:4px -16px 0;padding:var(--dm-strip-y) 16px;background:var(--dm-strip);border-top:1px solid var(--dm-line)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .fbx-f .pill.ghost:hover,:root [data-style="studio"] .fbx-f .pill.ghost:hover,:root [data-style="studio"].fbx-f .pill.ghost:hover{background:var(--dm-row)}}
/* the note keeps to one line, so the strip stays one control tall */
:root[data-style="studio"] .fbx-n,:root [data-style="studio"] .fbx-n,:root [data-style="studio"].fbx-n{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* on a phone the note gives way, and Cancel and Send keep to the right edge */
:root[data-style="studio"] .fbx-x,:root [data-style="studio"] .fbx-x,:root [data-style="studio"].fbx-x{margin-left:auto}
feedback-sheet.jsHTML · 36 lines
DM.def('feedback-sheet', (r, c) => {
  r.innerHTML = r.innerHTML.replace('{up}', I('up-thumb')).replace('{dn}', I('down-thumb'));
  const up = $('.fbx-up', r), dn = $('.fbx-dn', r), box = $('.fbx-box', r), st = $('.fbx-st', r), go = $('.fbx-go', r), ta = $('.fbx-ta', r), chips = $$('.fbx-ch .chip', r);
  // the component grows with what it shows in every style (grow(), once its entrance has settled), so the thanks line
  // eases in as the sheet folds away
  const fbx = $('.fbx', r);
  Promise.resolve().then(() => Promise.all(fbx.getAnimations().map(a => a.finished.catch(() => {})))).then(() => { if (!c.dead && fbx.isConnected) c.offs.push(grow(fbx)); });
  const ready = () => go.disabled = !(chips.some(x => x.classList.contains('on')) || ta.value.trim());
  chips.forEach(ch => ch.onclick = () => { ch.classList.toggle('on'); ready(); });
  ta.oninput = ready;
  up.onclick = () => { const on = !up.classList.contains('on'); up.classList.toggle('on', on); dn.classList.remove('on'); box.classList.add('shut'); swap(st, on ? 'Thanks, noted' : ''); };
  // the demo opens the sheet without taking the focus from wherever you are on the page
  // (as the sheet opens, its question, its reasons and the box rise in one after another: mxIn(), motion pieces)
  const down = focus => { const on = !dn.classList.contains('on'); dn.classList.toggle('on', on); up.classList.remove('on'); box.classList.toggle('shut', !on); swap(st, ''); if (on) mxIn([$('.fbx-q', r), ...chips, ta], { base:60 }); if (on && focus) c.later(350, () => ta.focus({ preventScroll:true })); };
  dn.onclick = e => down(e.isTrusted);
  $('.fbx-x', r).onclick = () => { box.classList.add('shut'); dn.classList.remove('on'); };
  go.onclick = () => c.run(async () => {
    // the button is as wide as what it shows, and eases to the spinner's width
    const w0 = go.offsetWidth; go.innerHTML = '<span class="spin"></span>'; if (!REDUCE) mxWidth(go, w0);
    await c.wait(800);
    box.classList.add('shut'); await c.wait(300);
    const n = chips.filter(x => x.classList.contains('on')).length;
    const thx = html(`<div class="fbx-thx">${I('ok')}<span>Thanks. The agent will ${n ? 'avoid this' : 'use this'} next time in this project.</span></div>`);
    ($(':scope>.dm-grow', fbx) || fbx).appendChild(thx); enter(thx); swap(st, '');
  });
  /* once it has entered, it rates the answer down and fills in the sheet by itself. Clicking, focusing or typing in it
     takes over, and what it had typed goes */
  c.run(async () => {
    await c.step(1500); down(false);
    await c.step(1000); chips[1].click();
    await c.step(700);
    await c.type(ta, 'Keep our 8px spacing scale', { ms:() => 34 + Math.random() * 40, each:ready, keep:true });
    await c.step(650); go.click();
  });
});
06

Questions

What people ask about it.

How do I save the feedback to my backend?
Pass an async onSubmit. The component shows a spinner while the promise is pending and closes the sheet only when it resolves. If it rejects, the sheet stays open.
Can I use my own reasons?
Yes. Pass reasons as a list of strings. Pass an empty list to hide the chips and keep only the comment box.
Does thumbs up open the sheet too?
No. Thumbs up closes the sheet if it was open and shows a short thanks. Only thumbs down opens it, unless you control open yourself.
07

More in Conversation

Everything for asking, answering and replying, by text or by voice.

Live answerAnswers that stream in with numbered sources and next steps.
ComposerMessage input with attachments, what to work on, a mode and dictation.
Answer action barCopy, regenerate, rate and listen to an answer from one row under it.
Response versionsRegenerate an answer and flip between versions.
Model pickerPick a model by speed, quality and cost, and how hard it thinks.
Attachment trayDrop files for the agent and watch each one upload.