# Email heading

The title of an `EmailPreview` on an app's page, at the level the page's outline gives it: `headingLevel` when set; else one below the nearest `HeadingScope`; else `fallback`. It is a client part because only a client component can read a `HeadingScope`; `EmailPreview`, `EmailLayout` and `renderEmail` stay free of `"use client"` so a mailer can render the email on the server. It carries the email's own inline style.

- Registry name: `email-heading` (`@candor/email-heading`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/email-heading

## Install

```bash
npx candor-ui add email-heading
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/email-heading`.
It brings in: heading-level, heading-scope, tokens.

## Example

```tsx
"use client"

import { EmailHeading } from "@/components/candor/email-heading"
import { HeadingScope } from "@/lib/candor/heading-scope"

// EmailPreview draws its title with EmailHeading. Used on its own it takes the level from the page's outline: one below
// the nearest HeadingScope, else `fallback`.
export default function Example() {
  return (
    <div className="flex max-w-xl flex-col gap-4 text-sm">
      <h2 className="text-base font-semibold">Notification emails</h2>
      <HeadingScope level={2}>
        <EmailHeading fallback={3} style={{ margin: 0, fontSize: 20, fontWeight: 600 }}>
          An approval is waiting for you
        </EmailHeading>
      </HeadingScope>
      <p className="text-muted-foreground">The title above is an h3, one below the scope's level 2; with no scope it would draw at the fallback, and headingLevel sets it outright.</p>
    </div>
  )
}
```

## <EmailHeading>

Props:

- `headingLevel?: HeadingLevel | undefined`: The title's level, taking the scope's and the fallback's place.
- `fallback: HeadingLevel`: The level outside any `HeadingScope`.
- `style?: React.CSSProperties | undefined`: The email's inline style for the title.
- `children?: React.ReactNode | undefined`: The title.

## Types from other items

The props above take these. Each is defined by another item; import it from the path shown.

### HeadingLevel

Import: `import type { HeadingLevel } from "@/lib/candor/heading-level"` (item `heading-level`, https://candor.themethodic.com/docs/heading-level.md)

A heading's level in the page's outline: `1` is `<h1>`, `6` is `<h6>`. Every Candor item that draws a heading takes its `headingLevel` as this type; the level is where the heading sits in the outline, never how large it looks.

```ts
1 | 2 | 3 | 4 | 5 | 6
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider`: its fixed strings in `strings`, its nouns in `nouns`; entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
