Closed SterlingButters closed 4 months ago
Seconded! Right now unless I'm mistaken there are three-ish ways to "hide" something:
div
) with display: none
style
and/or className
) style the component itself with display: none
Having a visibility
attribute in all components would be a nice way to gloss over the differences in component APIs (i.e. style
vs className
) and would allow for very clear callbacks to control visibility, that aren't also enmeshed with other styling.
Rather than introducing a custom Dash attribute that then needs to be mapped onto a CSS style, I think it would be better to use plain CSS to style components to begin with. There is already the visibility
CSS property for this, and the already mentioned display:none
.
The problem as I think @nicolaskruchten alluded to is that not all Dash Core Components support a style
attribute. In particular, the following dcc components are missing them: Dropdown
, Slider
, RangeSlider
, Markdown
.
Further to this, DatePickerSingle
and DatePickerRange
are also missing the className
property, as reported in https://github.com/plotly/dash-core-components/issues/67.
I think the more general solution is to require that Dash Core Components have both style
and className
properties. I've found the lack of support for style by some of these components frustrating in the past.
I think that @ned2's solution would be good in any case (standardizing style
and className
everywhere) but I would still advocate for a broken-out visibility
or hidden
attribute/prop for two reasons:
visibility
and display
and the interactions between different classes, or mixtures of style/class etc) just to hide an element.style
then that same callback has to restore the original style
when unhiding, which mixes concerns. One could of course style with className
and show/hide with style
but then I refer to my point above :)A visibility
attribute could just cause the component to render as an empty span
tag, so it's still in the DOM and callback chains, but has no impact on layout, so it wouldn't touch the component's style
or class
attributes, it would control visibility outside the component itself at the Dash level.
Any update on this? Thank you.
I am also wishing for the ability to hide a RangeSlider. Does anyone know how to get around this, or have an example? Depending on the nature of the data loaded, I want to either show a Dropdown containing all unique integer values, or if there are more than x values (too many), a RangeSlider with min and max integers selected.
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson
Self-explanatory from the title. Would be much easier, I think, than a callback-function that returns an html.Div object.