# dialog-trigger-pattern

The dialog-trigger-pattern Claude Code rule defines how dialog components receive their trigger. It applies to .tsx files.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1120 repo stars
- Author: rerun-build
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/dialog-trigger-pattern.mdc
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/dialog-trigger-pattern

## What it does

The rule structures React dialogs so the component receives its trigger element through `children` and keeps its open state internally. A parent places the button or another trigger element inside the dialog component.

Do not pass `open` or `onOpenChange` from the parent. In Claude Code, place the rule file at `.claude/rules/dialog-trigger-pattern.md`; for Cursor, use `.cursor/rules/dialog-trigger-pattern.mdc`.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/dialog-trigger-pattern.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/dialog-trigger-pattern.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/dialog-trigger-pattern.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/dialog-trigger-pattern.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/dialog-trigger-pattern.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/rerun-build/rerun/tree/HEAD/apps/ui/.cursor/rules/dialog-trigger-pattern.mdc

## When to use it
- connect a button to a dialog with `DialogTrigger`
- pass a trigger element into a dialog component through `children`
- move dialog state ownership out of the parent component

## Example prompts
- Refactor this dialog so its button comes through `children` and uses `DialogTrigger`.
- Check the `.tsx` files and remove parent-supplied `open` and `onOpenChange` props from dialog components.

## Similar
- [trigger-realtime](https://affpapa.org/en/nevibecode/skills/trigger-realtime.md) — skill · 3000 installs
- [phone_dialog](https://affpapa.org/en/nevibecode/prompts/phone-dialog.md) — prompt · ★ 9488 repo stars
- [presentational-container-pattern](https://affpapa.org/en/nevibecode/skills/presentational-container-pattern.md) — skill · 1200 installs
- [hooks-pattern](https://affpapa.org/en/nevibecode/skills/hooks-pattern.md) — skill · 1200 installs
- [nextjs-client-cookie-pattern](https://affpapa.org/en/nevibecode/skills/nextjs-client-cookie-pattern.md) — skill · 326 installs
- [huawei-cloud-functiongraph-trigger-create](https://affpapa.org/en/nevibecode/skills/huawei-cloud-functiongraph-trigger-create.md) — skill · 18300 installs

From the same set: [rerun-build/rerun](https://affpapa.org/en/nevibecode/by/rerun-build/rerun.md) — 25 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
