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

Introduce align_items parameter for ui.row, ui.column and ui.card #3175

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

falkoschindler
Copy link
Contributor

Inspired by question #3174, this PR introduces a parameter to control how items are aligned within common layout elements. It is based on Tailwind's "Align Items" classes.

with ui.row(align_items='center'):
    ui.button('Button')
    ui.label('Label')

with ui.column(align_items='center'):
    ui.button('Button')
    ui.label('Label')

with ui.card(align_items='center'):
    ui.button('Button')
    ui.label('Label')

@falkoschindler falkoschindler added the enhancement New feature or request label Jun 6, 2024
@falkoschindler falkoschindler added this to the 1.4.27 milestone Jun 6, 2024
@falkoschindler falkoschindler requested a review from rodja June 6, 2024 05:28
Copy link
Member

@rodja rodja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. It's really quite common. But so are justify and content alignment. And what about gap, self-alignment, item placement and so on? We either add them step-by-step as parameters or give something like the LayoutBuilder another try.

@rodja
Copy link
Member

rodja commented Jun 7, 2024

Other relevant discussions might be #1806 and #117. Also the recently announced https://github.com/rio-labs/rio Python-UI framework has build it's own layout-mechanism which could be an inspiration.

@falkoschindler
Copy link
Contributor Author

Yes, but because a complete layout system is still out of reach, I think we should improve NiceGUI's layouting options in smaller steps. I agree that gap would also be a useful parameter. But in contrast to the other alignments you mentioned, align_items is by far the one I use most frequently. Simply putting a label next to an input field or a button, you need to vertically center the row. But because we might add other parameters later, I chose the name align_items instead of just align or something.

@falkoschindler falkoschindler merged commit c69f2a7 into main Jun 7, 2024
7 checks passed
@falkoschindler falkoschindler deleted the align-items branch June 7, 2024 07:53
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 this pull request may close these issues.

None yet

2 participants