1
0

column_documentation.py 739 B

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.column)
  4. def main_demo() -> None:
  5. with ui.column():
  6. ui.label('label 1')
  7. ui.label('label 2')
  8. ui.label('label 3')
  9. @doc.demo('Masonry or Pinterest-Style Layout', '''
  10. To create a masonry/Pinterest layout, the normal `ui.column` can not be used.
  11. But it can be achieved with a few TailwindCSS classes.
  12. ''')
  13. def masonry() -> None:
  14. with ui.element('div').classes('columns-3 w-full gap-2'):
  15. for i, height in enumerate([50, 50, 50, 150, 100, 50]):
  16. tailwind = f'mb-2 p-2 h-[{height}px] bg-blue-100 break-inside-avoid'
  17. with ui.card().classes(tailwind):
  18. ui.label(f'Card #{i+1}')
  19. doc.reference(ui.column)