# Form

Labeled form groups for PDF inputs.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any docs URL. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## Installation

```bash
npx shadcn@latest add @angular-pdfcn/takumi/form
```

To install manually, add the dependencies:

```bash
npm install takumi-pdf @takumi-rs/helpers
```

Then copy these files into your project and update the import paths to match your setup:

- `components/pdf/form/form.styles.ts`
- `components/pdf/form/form.ts`
- `components/pdf/form/form.types.ts`
- `lib/resolve-color.ts`
- `components/pdf/theme-provider.ts`
- `lib/pdf-renderer.ts`
- `lib/pdf-primitives.ts`
- `lib/render.ts`
- `lib/pdf-themes/professional.ts`
- `lib/pdf-themes/primitives.ts`
- `types/pdf-themes.ts`
- `types/pdf-components.ts`

## Usage

```ts
import { Component } from "@angular/core";

import { PdfForm } from "@/components/pdf/form/form";
import type { PdfFormGroup } from "@/components/pdf/form/form.types";
import { PdfcnThemeProvider } from "@/components/pdf/theme-provider";
import {
  TakumiDocument,
  TakumiPage,
} from "@/lib/pdf-primitives";

@Component({
  imports: [TakumiDocument, TakumiPage, PdfcnThemeProvider, PdfForm],
  template: `
    <takumi-document>
      <takumi-page size="A4">
        <pdf-theme-provider>
          <pdf-form
            title="Job Application"
            subtitle="Please complete all fields clearly in block capitals."
            variant="underline"
            [groups]="groups"
          />
        </pdf-theme-provider>
      </takumi-page>
    </takumi-document>
  `,
})
export class FormDemo {
  protected readonly groups: PdfFormGroup[] = [
    {
      fields: [
        { hint: "First and last name", label: "Full Name" },
        { hint: "DD / MM / YYYY", label: "Date of Birth" },
        { label: "Email Address" },
        { hint: "+1 (555) 000-0000", label: "Phone Number" },
      ],
      title: "Personal Information",
    },
    {
      fields: [
        { label: "Street Address", width: "100%" },
        { label: "City" },
        { label: "State / Province" },
        { label: "Postal Code" },
      ],
      layout: "two-column",
      title: "Address",
    },
    {
      fields: [{ height: 60, label: "Cover Letter" }],
      title: "Additional Information",
    },
  ];
}
```

### Variants

```angular-html
<pdf-form
  variant="outlined"
  labelPosition="left"
  [groups]="[{ title: 'Contact', layout: 'two-column', fields }]"
/>
```

## API Reference

### PdfForm

| Input           | Type                                            | Default       |
| --------------- | ----------------------------------------------- | ------------- |
| `title`         | `string`                                        | -             |
| `subtitle`      | `string`                                        | -             |
| `groups`        | `PdfFormGroup[]`                                | -             |
| `variant`       | `'underline' \| 'box' \| 'outlined' \| 'ghost'` | `'underline'` |
| `labelPosition` | `'above' \| 'left'`                             | `'above'`     |
| `noWrap`        | `boolean`                                       | `false`       |
| `style`         | `Style`                                         | -             |

Groups support `single`, `two-column`, and `three-column` layouts.