column_documentation.py 920 B

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