Skip to content
Klarhimmel UI

Answer form

Approving needs no note.

npx shadcn add https://ui.klarhimmel.com/r/answer-form.json

Examples

  • 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.

Approving needs no note.

answer-form.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { AnswerForm } from '@/components/klarhimmel/ui/answer-form';

export default function Example() {
  return (
    <Theme theme="brand">
      <AnswerForm action="/deliverables/42/answer" hint="Approving needs no note." hidden={{ item: 'd-42' }} />
    </Theme>
  );
}

Import

Import

import { AnswerForm } from '@/components/klarhimmel/ui/answer-form';
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

PropTypeDefaultDescription
actionstring-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.
labelReactNode'What should change?'Label of the note.
labelHiddenboolean-Keep the label for screen readers only, when the item above already says what to write.
hintReactNode-One quiet line under the note, e.g. "Approving needs no note."
errorReactNode-Set by the server when it refused the answer (a change asked for with no note): shown under the note, which is marked invalid.
defaultValuestring-The note as it was sent, so a refused answer keeps what was typed.
noteNamestring'note'Form field names: the note, and the button that was pressed (its value is 'approve' or 'change').
answerNamestring'answer'Form field names.
approveLabelReactNode'Approve'Pass these translated.
changeLabelReactNode'Ask for a change'Pass these translated.
hiddenRecord<string, string>-Hidden fields sent with the answer: the item's id, a CSRF token.
disabledboolean-Shows the form without letting it be sent.
classNamestring-