Feedback Form
Collapsed pill that morphs into an expanded feedback panel with a send button and a textarea.
Feedback Form
Collapsed pill that morphs into an expanded feedback panel with a send button and a textarea.
Try it: type a message and hit Send (or Cmd/Ctrl+Enter) — the Send button holds a loading state for the demo's 900ms wait, then the panel springs back down into the pill. Clicking outside or pressing Escape closes it too.
Installation
Install the component with the Craft-UI Blocks CLI — it drops feedback-form.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add feedback-formpnpm dlx mvpblocks add feedback-formyarn dlx mvpblocks add feedback-formbunx mvpblocks add feedback-formFile Structure
The CLI saves the component to your project's components/ui folder:
Import it from @/components/ui/feedback-form.
Usage
FeedbackForm is a client component — pass your own copy as label and placeholder, and wire onSubmit to your endpoint:
"use client";
import { FeedbackForm } from "@/components/ui/feedback-form";
export function FeedbackFormPreview() {
return (
<FeedbackForm
label="Craft-UI Blocks"
placeholder="What's on your mind?"
onSubmit={async (value) => {
await fetch("/api/feedback", {
method: "POST",
body: JSON.stringify({ value }),
});
}}
/>
);
}Theming
The block ships with exact light and dark stops so it reads as a designed surface in either mode, no configuration needed. The shell is a crisp white in light mode and flips to zinc-950 in dark mode, sitting on the theme canvas through border-border and a soft 0 10px 30px -18px shadow. The indicator dot pulls your app's --color-brand token (falling back to #3b82f6). Body copy uses text-foreground, while the tagline, the "to send" hint, and the loading state use text-muted-foreground; the divider and ⌘/Enter keycaps are bg-border and bg-muted. The pill itself is a true pill: border-radius animates to exactly half its height when collapsed — not an oversized clamp — so it never reads as a blob mid-shrink. The Send button inverts per theme (bg-foreground text-background, dimmed while disabled) and tracks your tokens automatically.
Props
Prop
Type
Animations
- Morph: open is a snappy spring (
stiffness 380, damping 34); the collapse back down is a slower, even tween (0.55swith[0.65, 0, 0.35, 1]) so it never feels like a snap. Realwidth/height/border-radiusare animated directly — not Motion's scale trick — so the border, shadow, and corners never stretch mid-transition. - Shared elements: the dot and the "Feedback" label travel between the pill and the panel header through a shared
layoutIdon one symmetric spring, so both directions trace the exact same path. - Content fade: the pill↔panel crossfade runs in
AnimatePresence; the textarea and the hint + Send row fade in on staggered delays so the layout builds rather than flashing. - Pill fit: the collapsed pill measures its real content width with a
ResizeObserverand hugs "label | Feedback" exactly; the first correction applies instantly so there's no shrink-on-load. - Submit flow: Send or Cmd/Ctrl+Enter swaps the button to a "Sending" spinner that holds until your promise resolves — only then does the panel collapse and clear. Throwing keeps the panel open for a retry.
- Dismiss: clicking outside or pressing Escape closes the panel; the textarea autofocuses on open.
- Reduced motion:
useReducedMotionswaps every transition for an instant state change.
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: motion, lucide-react.
Inspired by the inline testimonial layout from Rauno Freiberg.
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on