# Profile form

- **[App UI](/app/)**
- **[Settings](/app/settings/)**
- **Profile form**

A profile form: photo, labelled fields with hints and autofill hints, save and cancel, and four states (idle; saving, which disables every field; saved; error, which…

## Notes

- **When to use it**: An account profile form with a photo and a few fields. For inviting another person use `app-team-invite`; for the irreversible actions that sit below the profile, use `app-settings-danger`.
- **Writing for it**: - Each field needs a label (40) and a kind: text, email or textarea. The sample (300) is the value the input starts with, not placeholder copy.
- Set autocomplete on every field to the matching hint, such as name or email, so browsers can fill the form. Use off for free text like a bio.
- Mark exactly one field invalid: true if the error state should point at it. The fieldError text (120) then appears under that field and in the banner.
- **Watch out for**: Saving is a state you set, not an action the block performs: the form never submits. In the saving state every field is disabled, and in the error state only the first field with invalid set is marked.

## Pairs well with

- **[App, notification preferences](/blocks/app/settings-notifications)**
- **[App, danger zone](/blocks/app/settings-danger)**
- **[App, plan and usage](/blocks/app/billing-plan)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppSettingsProfile from '@/components/klarhimmel/blocks/app-settings-profile';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppSettingsProfile props={{
          "eyebrow": "Settings",
          "title": "Your profile",
          "description": "Say who sees this information and where it appears.",
          "avatar": {
            "name": "Name a person",
            "change": "Change photo"
          },
          "fields": [
            {
              "label": "Full name",
              "kind": "text",
              "sample": "Name a person",
              "autocomplete": "name",
              "invalid": false
            },
            {
              "label": "Email",
              "kind": "email",
              "sample": "name@example.com",
              "hint": "Say what is sent to this address.",
              "autocomplete": "email",
              "invalid": true
            },
            {
              "label": "Role",
              "kind": "text",
              "sample": "Name their role",
              "autocomplete": "organization-title",
              "invalid": false
            }
          ],
          "actions": {
            "save": "Save changes",
            "saving": "Saving…",
            "cancel": "Cancel"
          },
          "state": "idle",
          "messages": {
            "saved": "Say the changes are saved.",
            "error": "Say it was not saved and which field to fix, then retry.",
            "fieldError": "Say what is wrong with that field."
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

- **eyebrow**: Text, up to 60 characters. Optional; empty is not rendered.
- **title**: Text, up to 120 characters.
- **description**: Text, up to 300 characters. Optional; empty is not rendered.
- **avatar**: Fields: name, change.
- **fields**: List of 2 to 6. Each item: label, kind ('text' | 'email' | 'textarea'), sample, hint (optional), autocomplete ('name' | 'given-name' | 'family-name' | 'email' | 'tel' | 'organization' | 'organization-title' | 'url' | 'off'), invalid.
- **actions**: Fields: save, saving, cancel.
- **state**: One of 'idle', 'saving', 'saved', 'error'.
- **messages**: Fields: saved, error, fieldError.
- **headingLevel**: One of '1', '2'. Optional; empty is not rendered.

## Install

- **CLI**

  ```
  npx shadcn add @klarhimmel/app-settings-profile
  ```

Uses

- Avatar
- Banner
- Input
- Textarea
- Button

- **About**: A profile form: photo, labelled fields with hints and autofill hints, save and cancel, and four states (idle; saving, which disables every field; saved; error, which marks and describes the flagged field). Never submits.
- **States**: Idle, saving, saved and error (the field is marked and described). Set with the state prop. New project? Set it up once: /get-started/installation.
