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

UI doesn't look good inside a tab panel #1614

Closed
youyou015 opened this issue Sep 13, 2023 · 6 comments · Fixed by #1796
Closed

UI doesn't look good inside a tab panel #1614

youyou015 opened this issue Sep 13, 2023 · 6 comments · Fixed by #1796
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@youyou015
Copy link
Contributor

youyou015 commented Sep 13, 2023

Description

Test code:

from nicegui import app, ui, native_mode

app.native.start_args["debug"] = True

# Normal
ui.label("First tab")
ui.label("First tab")
ui.separator()
ui.label("First tab")
ui.button("test1")
ui.button("test2")
ui.separator()
ui.button("test3")

# Not looks good in tabs
with ui.tabs().classes("w-full") as tabs:
    one = ui.tab("One")
    two = ui.tab("Two")
with ui.tab_panels(tabs, value=one).classes("w-full"):
    with ui.tab_panel(one):
        ui.label("First tab")
        ui.label("First tab")
        ui.separator()
        ui.label("First tab")
        ui.button("test1")
        ui.button("test2")
        ui.separator()
        ui.button("test3")
    with ui.tab_panel(two):
        ui.label("Second tab")

ui.run(
    native=True,
    reload=True,
    title="test",
    host="127.0.0.1",
    port=native_mode.find_open_port(),
)

Running result:
image

Btw, really love this UI framework! 👍

@natankeddem
Copy link
Contributor

Is using ui.column an acceptable solution?

from nicegui import app, native_mode, ui

app.native.start_args["debug"] = True

# Normal
ui.label("First tab")
ui.label("First tab")
ui.separator()
ui.label("First tab")
ui.button("test1")
ui.button("test2")
ui.separator()
ui.button("test3")

# Not looks good in tabs
with ui.tabs().classes("w-full") as tabs:
    one = ui.tab("One")
    two = ui.tab("Two")
with ui.tab_panels(tabs, value=one).classes("w-full"):
    with ui.tab_panel(one):
        with ui.column():
            ui.label("First tab")
            ui.label("First tab")
            ui.separator()
            ui.label("First tab")
            ui.button("test1")
            ui.button("test2")
            ui.separator()
            ui.button("test3")
    with ui.tab_panel(two):
        with ui.column():
            ui.label("Second tab")

ui.run()

@rodja rodja added the bug Something isn't working label Sep 14, 2023
@rodja rodja added this to the 1.3.14 milestone Sep 14, 2023
@rodja
Copy link
Member

rodja commented Sep 14, 2023

@natankeddem thanks for pointing out the work around. I think we should still fix the underlying issue in the next release.

@youyou015
Copy link
Contributor Author

Is using ui.column an acceptable solution?

from nicegui import app, native_mode, ui

app.native.start_args["debug"] = True

# Normal
ui.label("First tab")
ui.label("First tab")
ui.separator()
ui.label("First tab")
ui.button("test1")
ui.button("test2")
ui.separator()
ui.button("test3")

# Not looks good in tabs
with ui.tabs().classes("w-full") as tabs:
    one = ui.tab("One")
    two = ui.tab("Two")
with ui.tab_panels(tabs, value=one).classes("w-full"):
    with ui.tab_panel(one):
        with ui.column():
            ui.label("First tab")
            ui.label("First tab")
            ui.separator()
            ui.label("First tab")
            ui.button("test1")
            ui.button("test2")
            ui.separator()
            ui.button("test3")
    with ui.tab_panel(two):
        with ui.column():
            ui.label("Second tab")

ui.run()

@natankeddem That works, thanks a lot!

@natankeddem
Copy link
Contributor

@natankeddem thanks for pointing out the work around. I think we should still fix the underlying issue in the next release.

I wasn't sure if this was a bug. When I saw this behavior assumed using a ui.tab_panel should give undefined layout? The standard page container without a wrapper acts similarly a ui.column by default. I guess ui.tab_panel acting the same makes sense.

@falkoschindler
Copy link
Contributor

In my point of view this is not a bug.

Not every element opens a flexbox container with gaps and padding, see ui.dialog or ui.tooltip for example. We chose to do it for the main page container and - of course - for layout elements like ui.row and ui.column. A bit more controversial was ui.card (#726), where we do add gaps and padding, but which deviates from QCard's default dehavior. And we introduced ui.query to simplify the removal of the page padding for everyone who doesn't want it.

So I don't think it is reasonable to make every container a flexbox. But sure, it might be better for ui.tab_panel. Since a tab is very similar to the page container, it indeed makes sense to render it equally by default.

While thinking about elements that should render similar to a plain page, I noticed that ui.left_drawer and ui.right_drawer are no flexboxes, even though ui.header and ui.footer are. But I think drawers should render like columns as well.

Long story short, my proposal:

  1. Change the default layout of ui.tab_panel to be equal to ui.column.
  2. Change the default layout of left and right drawers as well.

But since these are breaking changes, we should schedule it for 1.4.

@falkoschindler falkoschindler modified the milestones: 1.3.14, 1.4 Sep 15, 2023
@falkoschindler falkoschindler added enhancement New feature or request and removed bug Something isn't working labels Sep 15, 2023
@falkoschindler falkoschindler self-assigned this Sep 15, 2023
@falkoschindler
Copy link
Contributor

We should also think about using flex layout in ui.stepper: #1788

@falkoschindler falkoschindler linked a pull request Oct 13, 2023 that will close this issue
@falkoschindler falkoschindler changed the title ui not looks good inside tab panel UI doesn't look good inside a tab panel Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants