Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ui.tab_panels can work with other components #1897

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions nicegui/elements/tabs.py
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ def __init__(self, name: str, label: Optional[str] = None, icon: Optional[str] =
class TabPanels(ValueElement):

def __init__(self,
tabs: Tabs, *,
tabs: Optional[Tabs] = None, *,
value: Union[Tab, TabPanel, str, None] = None,
on_change: Optional[Callable[..., Any]] = None,
animated: bool = True,
@@ -65,14 +65,15 @@ def __init__(self,
this element uses Vue's `keep-alive <https://vuejs.org/guide/built-ins/keep-alive.html>`_ component.
If client-side performance is an issue, you can disable this feature.

:param tabs: the `ui.tabs` element that controls this element
:param tabs: an optional `ui.tabs` element that controls this element
:param value: `ui.tab`, `ui.tab_panel`, or name of the tab panel to be initially visible
:param on_change: callback to be executed when the visible tab panel changes
:param animated: whether the tab panels should be animated (default: `True`)
:param keep_alive: whether to use Vue's keep-alive component on the content (default: `True`)
"""
super().__init__(tag='q-tab-panels', value=value, on_value_change=on_change)
tabs.bind_value(self, 'value')
if tabs is not None:
tabs.bind_value(self, 'value')
self._props['animated'] = animated
self._props['keep-alive'] = keep_alive