1
0

card_documentation.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.card)
  4. def main_demo() -> None:
  5. with ui.card().tight():
  6. ui.image('https://picsum.photos/id/684/640/360')
  7. with ui.card_section():
  8. ui.label('Lorem ipsum dolor sit amet, consectetur adipiscing elit, ...')
  9. @doc.demo('Card without shadow', '''
  10. You can remove the shadow from a card by adding the `no-shadow` class.
  11. The following demo shows a 1 pixel wide border instead.
  12. Alternatively, you can use Quasar's "flat" and "bordered" props to achieve the same effect.
  13. ''')
  14. def card_without_shadow() -> None:
  15. with ui.card().classes('no-shadow border-[1px]'):
  16. ui.label('See, no shadow!')
  17. with ui.card().props('flat bordered'):
  18. ui.label('Also no shadow!')
  19. @doc.demo('Tight card layout', '''
  20. By default, cards have a padding.
  21. You can remove the padding and gaps between nested elements by using the `tight` method.
  22. This also hides outer borders and shadows of nested elements, like in an original QCard.
  23. ''')
  24. def custom_context_menu() -> None:
  25. rows = [{'age': '16'}, {'age': '18'}, {'age': '21'}]
  26. with ui.row():
  27. with ui.card():
  28. ui.table(rows=rows).props('flat bordered')
  29. with ui.card().tight():
  30. ui.table(rows=rows).props('flat bordered')
  31. doc.reference(ui.card)