state-based dropdown trigger styling
when a dropdown opens, its trigger should visually reflect that state. this gives users immediate feedback that the interaction is active, creating a clear spatial relationship between the trigger and content.
without state-based styling
with state-based styling
bind trigger styling to the dropdown's open state:
const [isOpen, setIsOpen] = useState(false);
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
<DropdownMenuTrigger asChild>
<button
className={`base-styles ${isOpen ? "opacity-80 bg-neutral-800/30" : ""}`}
>
trigger
</button>
</DropdownMenuTrigger>
<DropdownMenuContent>{/* content */}</DropdownMenuContent>
</DropdownMenu>;common patterns: reduce opacity (opacity-80), add background (bg-neutral-800/30), or combine both. use transitions for smooth state changes.