-
-
Notifications
You must be signed in to change notification settings - Fork 143
Improved Tabs component #213
Conversation
kyleabeauchamp
commented
Jun 21, 2018
I noticed that the changes to test_integration.py
from #74 (e.g.,
dash-core-components/test/test_integration.py
Line 219 in 7b6b5ff
@kyleabeauchamp Good point - although the old integration tests aren't applicable here because I've changed the component API a bit, some integration testing with the new components would be nice!
kyleabeauchamp
commented
Jun 21, 2018
I have an open PR as well that attempts this, FWIW.
freshwuzhere
commented
Jun 21, 2018
This looks AWESOME! Thanks
@kyleabeauchamp Whoops, sorry, didn't see your PR in time :)
kyleabeauchamp
commented
Jun 21, 2018
One more naive question: is rebuilding and committing bundle.js part of the PR process? I suspect that would facilitate testing this branch (for those of us too lazy to get a fully working dev environment).
@kyleabeauchamp Good question - I wasn't sure about this (couldn't find any documentation about it) but I think you're right, looking back at older PR's it looks like the build is included, and I forgot to update the version as well, so I've now done that. Thanks for your help! :)
ZeroCool2u
commented
Jun 22, 2018
This is beautiful. I'm a big fan of the dual component design. Great work!
kyleabeauchamp
commented
Jun 22, 2018
Thanks, with the latest commits I can now import the dcc.Tabs
component. This will help folks test this out.
lilianeolmos
commented
Jul 24, 2018
Hi @valentijnnieman ! I'm having an issue: when I select the tab for the first time, the layout is correct , but when I switch tabs and then return to it, the layout has been messed up:
tabs
Custom styles like selected_style are being appended, not replaced, otherwise it would mean that you'd have to style everything yourself, even if you just wanted to update a color or something. My guess is that this is why you have a double border somewhere.
@valentijnnieman - I'm OK with these styles being merged into the defaults, but what I'm concerned about is that the selected styles seem to be mutated after I've clicked on them. Here is the same GIF but annotated:
Step 1 - Initial state. Note how there are no borders on any of the tabs. This is expected as the stab styles have been overriden.
image
Step 2 - Click on Tab #3.
image
Step 3 - Click on Tab #1. Note how Tab #3 now has a left and top border. It shouldn't have any borders, it should appear the same way as it appears in Step 1. It seems like the style is getting mutated rather than copied.
image
Similarly, note how in Step 2, Tab #1 has left and top borders. This is unexpected, it shouldn't have any borders.
Does that make sense or am I missing something here?
@chriddyp Sorry, I missed that completely when watching your gif :) I'll take a look at it!
@chriddyp I made a mistake where I copied the styles over - thus leaving styles that were being appended (from selected_style
). Good catch! It should work now - note though that you set width: inherit
as tab_style
, and selected_style
will still have the width: calc(25%)
on it, which will look weird.
@lilianeolmos Hmm that's odd! I've just published prerelease version 0.24.0rc6
, could you use that (run pip install dash_core_components==0.24.0rc6
) and see if that fixes anything?
lilianeolmos
commented
Jul 25, 2018
@valentijnnieman thanks for your answer. I've just tried and I'm still having the same problem. When I use the previous versions of dash_core_components this problem doesn't happen.
@lilianeolmos Hmm! Would you perhaps create a post on our forums, here with a short reproducible example code of the bug? Would help us out a lot!
Thanks for making this changes! Let's do this 😸
💃 💃 💃
danigallo
commented
Jul 27, 2018
@valentijnnieman is there a way to change the tab sizes/length? I have 4 and one is carrying over to a new row
@danigallo You could specify the style
of a Tab
component and define it's own width
. So dcc.Tab(style={'width': '25%'}, children=[])
for example.
ghost
commented
Jul 31, 2018
Thanks for all your work on the new Tabs functionality. My apps still use the old one from the 0.21.rc1 release and was wondering if it would be safe to switch over for my use case. Typically, each tab's content takes 20 seconds or so to load because of internal data fetching, computation and rendering of a complicated plotly Figure. Additionally, most tabs are never used during a given session, so the content never needs to be generated. Would the new component slow down the app?
Additionally, most tabs are never used during a given session, so the content never needs to be generated. Would the new component slow down the app?
It will not, you can still use the previous method "generate content through a callback" with the new tabs component. This is what I recommend for most use cases. See the second example here: https://dash.plot.ly/dash-core-components/tabs
Hi
Fairly new to Plotly and Dash but loving what I can do with it so far! Have started experimenting with tabs and I have two tabs, but when I load my dashboard it opens my "second" tab as the first tab you see.
Is there a way to set tab1 as the "default" tab that should be displayed first? Have done a fair bit of searching but can't see it covered anywhere.
Thanks
Chris
robfraz
commented
Aug 2, 2018
@Chris3691 Yes there is. Look at the code example in this earlier comment where a bug (now resolved) was spotted with this default tab functionality.
You'll see each Tab
object has a value specified (value='tab-1'
, value='tab-2'
, etc), and there is also a value specified in the Tabs
object, which is set to 'tab-3'
in that example, thus making the Tab
object with the value 'tab-3'
the default choice.
We have published the documentation for this component online here: https://dash.plot.ly/dash-core-components/tabs. Many thanks to everyone who has contributed to this effort!
If you have any other questions or issues with this component, please create a new issue or discuss in the community forum https://community.plot.ly/c/dash
Uh oh!
There was an error while loading. Please reload this page.
Hello there!
Here is the improved Tabs component I've been working on, branched off the current master branch. It supports className's and inline style's for the multiple containers (parent, tabs, tab, tab-content, tab--selected) which appends classes to the base classes (let me know if it should overwrite the default classes instead of appending) and has a
vertical
bool for rendering vertically.screen shot 2018年06月21日 at 11 37 40
screen shot 2018年06月21日 at 11 36 40
It's also more responsive:
screen shot 2018年06月21日 at 11 38 31
It's basically 2 components: a
dcc.Tabs
component which is the container, where you can specifyvertical
and set some classes and styles, and adcc.Tab
component, which renders a tab with alabel
, and renders it'schildren
(which can be anything in Dash) when that tab isselected
! Thanks to @T4rk1n for his work and ideas!Here's an example of how to use Tabs:
(削除) I haven't included any builds yet, because I'm not sure if I should - CircleCI etc will handle that stuff, right? (削除ここまで)edit:
Please be aware that the component API has changed a bit - it now uses 2 components:
children
as tabs, complete with selection logic - you no longer have to set this up yourself in Dash, it's handled internally, which I hope is more easy to use. Would love to hear some feedback on this, especially if this is giving you trouble or prevents a certain use case for you.label
prop that holds the label of the tab's button, and renders it'schildren
as the content that will be visible when this tab is selected