| name | nicegui-development |
| description | Use when building UI with NiceGUI, creating components, fixing styling issues, or when user mentions "nicegui", "quasar", "tailwind", "ui.row", "ui.column", "gap spacing", "state management", "controller", "dialog", "modal", "ui component", "ui layout". |
NiceGUI Development Best Practices
Core Philosophy
Understand the user workflow before building. Same data MUST look the same everywhere. Extract business logic from UI into testable controllers.
Quick Start
grep -r "ui.card" src/ | head -20
grep -r "ui.dialog" src/ | head -20
ls src/*/ui/components/
Critical Rules - NiceGUI Styling
with ui.row().classes("items-center").style("gap: 0.75rem"):
ui.icon("info")
ui.label("Message")
with ui.row().classes("items-center gap-3"):
with ui.card().style("height: 80vh"):
with ui.scroll_area().style("height: 100%"):
ui.label("Content")
with ui.card().style("max-height: 80vh"):
with ui.scroll_area().style("height: 100%"):
with ui.element("div").style("display: flex; width: 100%; gap: 24px"):
with ui.element("div").style("flex: 1; min-width: 0"):
ui.highchart(options)
Critical Rules - Product Thinking
class ItemReference:
def __init__(self, item, mode: Literal["LIBRARY", "REFERENCE", "PREVIEW"]):
if mode == "LIBRARY":
elif mode == "REFERENCE":
Critical Rules - UI Architecture
class PageController:
async def handle_task_change(self, new_task: str) -> PageUpdate:
data = await self.fetcher.fetch_data(new_task)
return PageUpdate.refresh_all(data)
async def on_task_change(e):
logger.info(f"User selected task: {e.value}")
update = await controller.handle_task_change(e.value)
apply_ui_update(update)
async def on_task_change(e):
overview = await service.get_overview()
if overview.tasks:
selected = overview.tasks[0]
chart.refresh(...)
Modal/Dialog Button Docking
with ui.dialog() as dialog, ui.card().style(
"height: 85vh; display: flex; flex-direction: column;"
):
with ui.scroll_area().style("flex: 1; overflow-y: auto;"):
with ui.element("div").style(
"position: sticky; bottom: 0; padding: 1rem; "
"border-top: 1px solid var(--border-color);"
):
with ui.row().classes("justify-end"):
ui.button("Cancel", on_click=dialog.close)
ui.button("Save", on_click=save_handler)
Checklists
Data Display Component Checklist
UI Architecture Checklist
NiceGUI Styling Checklist
Reference Files
Remember: Ask "where else does this data appear?" before building any UI component.