Answer form
npx shadcn add https://ui.klarhimmel.com/r/answer-form.jsonCopy for AIExamples
Basic
Refused
DetailsAbout, usage, props and more
Approve one item or ask for a change, with a short note. A plain form: it works with no JavaScript.
Preview
Home page, second draft
Delivered Tuesday. Look it over and approve it, or say what should change.
Import
Import
- Files
- answer-form.tsx, in components/klarhimmel/ui/. With it: button, input, theme, utils.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
action | string | - | Where the answer is posted. A plain form: it works with no JavaScript, and the server decides what happens next. |
method | 'post' | 'get' | 'post' | Where the answer is sent. |
label | ReactNode | 'What should change?' | Label of the note. |
labelHidden | boolean | - | Keep the label for screen readers only, when the item above already says what to write. |
hint | ReactNode | - | One quiet line under the note, e.g. "Approving needs no note." |
error | ReactNode | - | Set by the server when it refused the answer (a change asked for with no note): shown under the note, which is marked invalid. |
defaultValue | string | - | The note as it was sent, so a refused answer keeps what was typed. |
noteName | string | 'note' | Form field names: the note, and the button that was pressed (its value is 'approve' or 'change'). |
answerName | string | 'answer' | Form field names. |
approveLabel | ReactNode | 'Approve' | Pass these translated. |
changeLabel | ReactNode | 'Ask for a change' | Pass these translated. |
hidden | Record<string, string> | - | Hidden fields sent with the answer: the item's id, a CSRF token. |
disabled | boolean | - | Shows the form without letting it be sent. |
className | string | - |