Repository navigation
[FEATURE]: Clickable Legend Titles #7687
Description
Activity
@alexshoe Sounds like a plan.
The name
titleclickparallels nicely with the existinggroupclick,itemclick, anditemdoubleclickattributes for legends.Question: Rather than
trueandfalse, should the accepted values be'toggle'(or similar) andfalseto match the pattern of those other attributes more closely?I'll admit that in isolation, that feels like a much clunkier API. But worth thinking about if you haven't already.
Second question: What would be the downside to having
titleclickdefault totruein all situations? I suppose it's simply not useful when there is only one legend.Plan looks good on my end! API seems intuitive, and I'm generally behind Emily's comments. Though as someone who initially supported the single-
false, multi-truedefault (and probably still does), one benefit of havingtruebe default in all situations is that it enables default, easy-access toggling of all the traces when they are foreground data to some background (like a Layout Image).Reacted by Alex HsuReacted by Emily KL@emilykl Regarding values of
titleclick, I thought about that initially but for the other attributes likeitemclickanditemdoubleclick, the values are['toggle', 'toggleothers', false]. Since a'toggleothers'mode wouldn't make sense fortitleclickI decided a boolean would be alright, but I'm not really that opinionated on this.As for the defaults, I got those details from the SOW of the project but I agree that setting default to
truemakes more sense.@alexcjohnson what do you think?
@emilykl Regarding values of titleclick, I thought about that initially but for the other attributes like itemclick and itemdoubleclick, the values are ['toggle', 'toggleothers', false]. Since a 'toggleothers' mode wouldn't make sense for titleclick I decided a boolean would be alright, but I'm not really that opinionated on this.
Ah interesting, I had not thought about
'toggleothers'. I can't see a reason I would use it in lieu of'toggle'fortitleclick. But if we madetitledoubleclickavailable,toggleotherswould be the ideal behavior for that parameter.Thinking about this more, it'd be great to include
titledoubleclickas a parameter, and['toggle', 'toggleothers', false]as options for bothtitleclickandtitledoubleclick. This would make legend title behavior mirror other legend elements (items and groups). The benefit would not be just consistency between these elements — I can think of a clear use case for us! Our "striplog" figures will have multiple legends (in some cases, one for each "strip", which can consist of multiple traces and multiple legend items). We would make use oftitledoubleclick='toggleothers'to toggle off the visibility of the other strips, much the way plotly users do this with individual legend items.If
titledoubleclick+'toggleothers'are not too challenging or out of scope to include, I think we should!@robertcollar-kobold that's a good idea, and I like keeping it similar to
itemclickanditemdoubleclickReacted by Robert Collar@robertcollar-kobold @alexcjohnson
A point I forgot to mention under visual feedback: do we want the legend titles to toggle in opacity along with the legend items/traces?Yes, I think it would make sense to toggle opacity of legend titles and their legend groups/items!
- linked a pull request that will close this issueClickable Legend Titles #7698
on Jan 28, 2026
Summary
As part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to click on legend titles to toggle the visibility of all traces in that legend.
This feature enhancement would be useful for situations where multiple legends are used to organize different categories of data. Clicking a legend title would provide a quick way to show/hide entire categories of traces without clicking each item individually.
Problem Statement
Legend titles are currently non-interactive text elements. When working with multiple legends, users might want to quickly toggle all traces on/off. Currently, this requires clicking each item individually, which can be tedious.
Key Decision: How should we implement clickable legend titles, and what should the default behavior be?
Proposed Solution
API
Add a
titleclickattribute to control whether the legend title is clickable:The
titleclickattribute is a boolean:true: Clicking the title toggles all traces in that legendfalse: Title is not clickableThe default value for
titleclickdepends on the number of legends in the plot:falsetrueVisual Feedback
Clickable titles will show a pointer cursor on hover, matching the existing legend item behavior.
Implementation Plan (with rough timeline)
Add attributes and defaults (Week 1)
titleclickattribute tosrc/components/legend/attributes.jssrc/components/legend/defaults.jsto set defaults based on legend countImplement click handling (Week 1-2)
rectoverlay to legend titlesTesting (Week 2)