# Answer form

- **[Atoms](/components/)**

Approve one item or ask for a change, with a short note. A plain form: it works with no JavaScript.

## Preview

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

- **CLI**

  ```
  npx shadcn add https://ui.klarhimmel.com/r/answer-form.json
  ```
- **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.

## Examples

- **Refused**

  ```
  import { AnswerForm } from '@/components/klarhimmel/ui/answer-form';
  import { Card } from '@/components/klarhimmel/ui/card';
  
  export default function AnswerFormRefused() {
    return (
      <Card className="flex w-full max-w-lg flex-col gap-4 p-5">
        <p className="text-kh-heading font-medium text-kh-ink">Price list, first draft</p>
        <AnswerForm action="#" error="Say what should change, then ask again." hidden={{ item: 'price-list-v1' }} />
      </Card>
    );
  }
  ```

## Props

- **action**: Where the answer is posted. A plain form: it works with no JavaScript, and the server decides what happens next.
- **method**: Where the answer is sent.
- **label**: Label of the note.
- **labelHidden**: Keep the label for screen readers only, when the item above already says what to write.
- **hint**: One quiet line under the note, e.g. "Approving needs no note."
- **error**: 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**: The note as it was sent, so a refused answer keeps what was typed.
- **noteName**: Form field names: the note, and the button that was pressed (its value is 'approve' or 'change').
- **answerName**: Form field names.
- **approveLabel**: Pass these translated.
- **changeLabel**: Pass these translated.
- **hidden**: Hidden fields sent with the answer: the item's id, a CSRF token.
- **disabled**: Shows the form without letting it be sent.
- **className**

[Previous](/components/empty-state)

[Next](/components/file-field)
