---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Invite dialog

Send an invite to people by their email addresses, with a role and an optional note, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `InviteDialog`.

## Try it

Open "Invite people": the addresses take the focus. Type an address and press Enter or a comma, or paste a list (commas, semicolons, new lines, "Name <address>"); one that is no address is marked and named under the field, and Backspace twice removes the last tag. Pick a role (Enter opens its list, the arrows move), add a note, then ⌘ Enter or Send: the button is busy for a moment and the people join the pending list. An address invited already is refused in place. The line under the list says while the dialog is open and the addresses it holds.

The send is a timer; nothing is emailed, and the invites live in the page only.

## When to use

- Send an invite to people by their email addresses, with a role and an optional note.
- Use it for every "Invite" on a members page, a team's settings or a share menu: people are invited by address, so the dialog never asks for a name or a form of one field per person. Put the roles a person may join as in `roles`, each with a `description`; give `inviteLink` the theme's CopyButton when the workspace has a link to share. In `onSend`, refuse an address already a member or invited by throwing an Error that names it: the dialog shows it and stays open. Say the invites went with a Toast after it closes.

## When not to use

- For a new record use CreateDialog.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Invite dialog on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-invite-dialog.json --yes
```

```text
Add the Goop Invite dialog to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { InviteDialog } from '@/components/goop/patterns/invite-dialog';
import { useState } from 'react';
import { Button, ButtonIcon, ButtonLabel } from '@/components/ui/goop/button';
import { CopyButton } from '@/components/ui/goop/copy-button';
import { toast } from '@/components/ui/goop/toast';

function InvitePeople() {
  const [invited, setInvited] = useState<string[]>([]);
  return (
    <InviteDialog
      trigger={
        <Button>
          <ButtonIcon icon="plus" />
          <ButtonLabel>Invite</ButtonLabel>
        </Button>
      }
      heading="Invite to Fieldwork"
      description="They get an email with a link to join the workspace."
      roles={[
        { value: 'admin', label: 'Admin', description: 'Can invite people and change their roles' },
        { value: 'member', label: 'Member', description: 'Can see and change every study' },
        { value: 'guest', label: 'Guest', description: 'Can see only the studies shared with them' },
      ]}
      defaultRole="member"
      inviteLink={
        <CopyButton value="https://fieldwork.example/join/7f3a9c" label="Copy invite link" variant="outline" size="md" />
      }
      onSend={async (values) => {
        // your send; throw to keep the dialog open, the message shown in it
        const taken = values.emails.filter((email) => invited.includes(email));
        if (taken.length > 0) throw new Error(`${taken.join(', ')} invited already.`);
        setInvited((now) => [...values.emails, ...now]);
        toast({ title: `${values.emails.length} invites sent` });
      }}
    />
  );
}
```

- Fits: frame: sidebar-foot; settings: overlay.
- Also known as: InviteModal, InviteMembersDialog, InviteForm, ShareDialog.
- height, width, padding, gap, corner, border: add no class for these.

## API reference

### InviteDialog: every option

```tsx
import { InviteDialog } from '@/components/goop/patterns/invite-dialog';
```

### Options

- open?: boolean — Open, held by the caller; pair with `onOpenChange`.
- defaultOpen?: boolean = false — Open at first, when the dialog holds its own open state.
- onOpenChange?: (open: boolean) => void — Called as it opens and closes.
- modal?: boolean = true — The page held behind it while open; `false` for a picture held open beside the page.
- trigger?: ReactNode — The control that opens it (the theme's Button), wrapped as the dialog's trigger.
- heading?: ReactNode = 'Invite people' — The dialog's name, in its header.
- description?: ReactNode — One line under the header saying what happens next.
- emails?: readonly string[] — The addresses, held by the caller; pair with `onEmailsChange`.
- defaultEmails?: readonly string[] — The addresses at first, when the dialog holds them.
- onEmailsChange?: (emails: string[]) => void — Called with the addresses each time one is added or removed.
- roles?: readonly InviteDialogRole[] = [] — The roles a person may join as; none leaves the role's field out.
- defaultRole?: string — The role chosen as it opens and after each send; the first of `roles` by default.
- defaultMessage?: string = '' — The note as it opens and after each send; empty when left out.
- isEmail?: (text: string) => boolean — Whether typed words are an email address; a plain `name@place.tld` check by default.
- invalidEmailsError?: (texts: readonly string[]) => string — The line naming the typed words that are no address.
- onSend?: (values: InviteDialogValues) => unknown — Sends the invites: a promise the dialog waits on; throw or reject to keep it open with the error.
- sendLabel?: (count: number) => string — The main button's words, by the count ("Send 3 invites" by default).
- inviteLink?: ReactNode — The footer's start: the theme's CopyButton with the invite link.
- emailsLabel?: string = 'Email addresses' — The addresses field's label.
- emailsPlaceholder?: string = 'name@example.com, name@example.org' — The addresses field's placeholder.
- roleLabel?: string = 'Role' — The role field's label; "Role" when left out.
- messageLabel?: string = 'Message' — The note's label; "Message" when left out.
- messagePlaceholder?: string | null = 'Add a note to the invite (optional)' — The note's placeholder; `null` leaves the note out.
- container?: HTMLElement | null — Where the layer and the role's list are portalled; the end of `<body>` when left out.
- Takes every prop of DialogContent but children, title, variant, size, onOpenAutoFocus and defaultValue (its page: dialog.md)
- State: open (open / defaultOpen / onOpenChange); emails (emails / defaultEmails / onEmailsChange)
- Types: InviteDialogRole = { value: string; label: string; description?: string }; InviteDialogValues = { emails: readonly string[]; role: string; message: string }

## Keyboard

- Escape: close, keeping what was typed for the next opening
- Enter: in the addresses, make the typed address a tag
- Backspace: in the empty addresses field, select the last tag; again, remove it
- Meta+Enter: send
- Control+Enter: send
- Tab: move to the next field or button

## Accessibility

- The part itself answers the keys above.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Create dialog](/themes/trail/components/create-dialog): A dialog to make a new record, title first.
- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Copy button](/themes/trail/components/copy-button): A button that copies a value such as a link, a key or a command to the clipboard and says it was copied in place.
- [Toast](/themes/trail/components/toast): A short notice at a corner of the app that confirms an action and goes by itself, with an optional action such as Undo.
