from nicegui import ui from .tools import main_page_demo def create_intro() -> None: @main_page_demo('Styling', 'While having reasonable defaults, you can still modify the look of your app with CSS as well as Tailwind and Quasar classes.') def formatting_demo(): ui.icon('thumb_up') ui.markdown('This is **Markdown**.') ui.html('This is HTML.') with ui.row(): ui.label('CSS').style('color: #888; font-weight: bold') ui.label('Tailwind').classes('font-serif') ui.label('Quasar').classes('q-ml-xl') ui.link('NiceGUI on GitHub', 'https://github.com/zauberzeug/nicegui') @main_page_demo('Common UI Elements', 'NiceGUI comes with a collection of commonly used UI elements.') def common_elements_demo(): from nicegui.events import ValueChangeEventArguments def show(event: ValueChangeEventArguments): name = type(event.sender).__name__ ui.notify(f'{name}: {event.value}') ui.button('Button', on_click=lambda: ui.notify('Click')) with ui.row(): ui.checkbox('Checkbox', on_change=show) ui.switch('Switch', on_change=show) ui.radio(['A', 'B', 'C'], value='A', on_change=show).props('inline') with ui.row(): ui.input('Text input', on_change=show) ui.select(['One', 'Two'], value='One', on_change=show) ui.link('And many more...', '/documentation').classes('mt-8') @main_page_demo('Value Binding', 'Binding values between UI elements and data models is built into NiceGUI.') def binding_demo(): class Demo: def __init__(self): self.number = 1 demo = Demo() v = ui.checkbox('visible', value=True) with ui.column().bind_visibility_from(v, 'value'): ui.slider(min=1, max=3).bind_value(demo, 'number') ui.toggle({1: 'A', 2: 'B', 3: 'C'}).bind_value(demo, 'number') ui.number().bind_value(demo, 'number')