Last active
November 3, 2023 23:12
-
-
Save knowsuchagency/a8aa293cd3e4892e02219682988234eb to your computer and use it in GitHub Desktop.
refreshable header issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nicegui import ui | |
@ui.refreshable | |
def app(): | |
username, set_username = ui.state("") | |
with ui.header(): | |
with ui.tabs().classes("w-full") as tabs: | |
app_tab = ui.tab("App") | |
settings_tab = ui.tab("Settings") | |
with ui.tab_panels(tabs, value=app_tab if username else settings_tab).classes("w-full"): | |
with ui.tab_panel(app_tab): | |
ui.label(f"Hello {username}!").classes("text-2xl") | |
with ui.tab_panel(settings_tab): | |
field = ui.input("Username", value=username) | |
ui.button("Submit", on_click=lambda e: set_username(field.value)) | |
app() | |
ui.run(show=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment