dialog-trigger-pattern — Claude Code rule for dialogs
The dialog-trigger-pattern Claude Code rule defines how dialog components receive their trigger. It applies to .tsx files.
AGPL-3.0 ★ 1,120 updated 2026-11-16
.cursor/rules/dialog-trigger-pattern.mdcWhat dialog-trigger-pattern 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.
What it helps with
- 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 for the agent
- Refactor this dialog so its button comes through
childrenand usesDialogTrigger. - Check the
.tsxfiles and remove parent-suppliedopenandonOpenChangeprops from dialog components.
How to install dialog-trigger-pattern
Manually: put the files in place
.cursor/rules/dialog-trigger-pattern.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/dialog-trigger-pattern.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/dialog-trigger-pattern.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/dialog-trigger-pattern.mdManually: put the files in place
.clinerules/dialog-trigger-pattern.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about dialog-trigger-pattern
How do I install dialog-trigger-pattern in Claude Code?
Add the rule file at .claude/rules/dialog-trigger-pattern.md.
What does dialog-trigger-pattern do?
It sets a pattern for dialog components: the trigger comes through children, while the dialog owns its open state.
Which files does dialog-trigger-pattern apply to?
The rule targets .tsx files.