# Party

One party of a declared role, with the organization, address, and contact fields beside it, as a block or inline, through the shared formatter.

Canonical URL: https://docs.asterdoc.com/components/party/

`Party` prints one party of an artifact-declared role as one kept-together
block: its name from the party record, then the organization, address, and
contact lines from the fields you name, each through the same shared
formatter a [`Field`](/components/field) reads through. A line with no path,
or whose field is blank, is left out, so nothing prints empty.

## Preview


```tsx
import { Document } from "@/components/asterdoc/document";
import { Party } from "@/components/asterdoc/party";
import { partyDemoForm } from "@/examples/party-artifact";
import { partyDemoData } from "@/examples/party-demo-data";

export function PartyDemo() {
  return (
    <Document artifact={partyDemoForm} data={partyDemoData} id="party-demo">
      <Party role="buyer" organization="buyerOrganization" address="buyerAddress" contact="buyerPhone" />
    </Document>
  );
}
```


## Installation


```bash
npx shadcn@4 add @asterdoc/party
```


```bash
asterdoc add party
```


Installs to components/asterdoc/party.tsx.


## Usage


```tsx
import { Party } from "@/components/asterdoc/party";

<Party role="buyer" organization="buyerOrganization" address="buyerAddress" contact="buyerPhone" />
```

| Prop | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| `role` | `string` | No |  | Party role declared by the artifact, such as `"buyer"`. |
| `index` | `number` | Yes | 0 | 0-based index, for a role admitting several parties. |
| `organization` | `string` | Yes |  | Path of the field naming the organization the party acts for, such as `"buyerOrganization"`. |
| `address` | `string` | Yes |  | Path of the party's address field, such as `"buyerAddress"`, or `"tenants.1.address"` for a list item. |
| `contact` | `string \| readonly string[]` | Yes |  | Path of the party's contact field, or several (a phone and an email) printed on one line. |
| `variant` | `"block" \| "inline"` | Yes | "block" | `"block"` stacks the name, organization, address, and contact each on
their own line; `"inline"` joins them into one run for a sentence. |
| `label` | `string \| false` | Yes |  | Overrides the role heading: a string replaces it, `false` hides it, omitted uses the artifact's own label. |
| `keepId` | `string` | Yes | "party:<role>" or "party:<role>:<index>" past the first | Stable keep id. |
| `className` | `string` | Yes |  | Classes for the party's wrapping element. |


## Composition

`Party` needs the same `Document` context every other component here does:
`role` names a role the artifact declares, and `index` selects which one for
a role a document may fill more than once. `Party` is a `Keep Together`, so
it is never split across a page break, and it carries `data-party-role` and
`data-party-index` the way a `Field` carries `data-field-path`.

A party record carries only name-shaped person or organization members.
Where a party is, how to reach it, and whom it acts for are fields the
artifact declares beside the role, each with its own label, requiredness,
and layer binding. `organization`, `address`, and `contact` name those
fields by path; `contact` takes one path or several (a phone and an email),
printed on one line. For a role filled more than once, bind each index to
its own list item, such as `address="tenants.1.address"`.

```tsx
<Party role="buyer" organization="buyerOrganization" address="buyerAddress" contact={["buyerPhone", "buyerEmail"]} />
```

`role` names an undeclared role, `index` a party past how many the role was
actually filled with, and a path a field the artifact does not declare. A
finished render fails by name in each case, the same way an unknown
[`Field`](/components/field) path does. That includes an optional role
(`min: 0`) a document has not filled at all, where index `0` is already past
the parties it carries. A partial document prints its configured placeholder
for the missing party, while check mode reports the missing path.

Every size in the block — the role heading and every line beneath it —
follows the document's [typography](/components/typography) token.

## Variants

### Inline

`variant="inline"` joins the same values into one run, for a sentence,
instead of stacking them as a block.


```tsx
import { Document } from "@/components/asterdoc/document";
import { Party } from "@/components/asterdoc/party";
import { partyDemoForm } from "@/examples/party-artifact";
import { partyDemoData } from "@/examples/party-demo-data";

export function PartyVariantInline() {
  return (
    <Document artifact={partyDemoForm} data={partyDemoData} id="party-variant-inline">
      <Party
        role="buyer"
        organization="buyerOrganization"
        address="buyerAddress"
        contact="buyerPhone"
        variant="inline"
        label={false}
      />
    </Document>
  );
}
```


### Multiple parties

A role a document may fill more than once — `witness` here admits two —
selects which party this block prints with `index`.


```tsx
import { Document } from "@/components/asterdoc/document";
import { Party } from "@/components/asterdoc/party";
import { partyDemoForm } from "@/examples/party-artifact";
import { partyDemoData } from "@/examples/party-demo-data";

export function PartyVariantMultiple() {
  return (
    <Document artifact={partyDemoForm} data={partyDemoData} id="party-variant-multiple">
      <div className="flex flex-col gap-4">
        <Party role="witness" index={0} />
        <Party role="witness" index={1} />
      </div>
    </Document>
  );
}
```
