Instruction file imported from anhtuta/chat-app (
.cursor/rules/react-interactive-titles.instructions.mdc). Copyright stays with the author.
Interactive Control Titles
Every clickable or icon-only control must expose a short, human-readable purpose on hover.
Required
- Add a
titleattribute to buttons, icon buttons, icon-only links, and similar controls when the purpose is not already obvious from visible text alone. - Prefer concise action phrases:
"Add member","Close","Remove from group","Send message". - Icon-only controls always need a
title(and preferablyaria-labelwith the same text). - When using MUI
IconButton,Buttonwith only an icon, or custom clickable icons, settitleon the interactive element.
// ❌ BAD — icon-only, no hover hint
<IconButton onClick={onClose}>
<CloseIcon />
</IconButton>
// ✅ GOOD
<IconButton title="Close" aria-label="Close" onClick={onClose}>
<CloseIcon />
</IconButton>
// ❌ BAD — ambiguous icon action
<span onClick={onAdd}>
<PersonAddIcon />
</span>
// ✅ GOOD
<button type="button" title="Add member" aria-label="Add member" onClick={onAdd}>
<PersonAddIcon />
</button>
Exceptions
- Controls whose visible label already states the action (e.g.
<Button>Save</Button>) do not require a redundanttitle. - Decorative, non-interactive icons do not need a
title. - If a MUI
Tooltipalready wraps the control with the same purpose text, do not duplicate a conflictingtitle; keep one clear hover label.