Skip to main content

Meta / SidePanel / Closable

Display a sidePanel having a close button, and detect when it's closed.

from h2o_wave import main, app, Q, ui

@app('/demo')async def serve(q: Q):    if not q.client.initialized:        # Create an empty meta_card to hold the side panel['meta'] = ui.meta_card(box='')        # Display a button to show the side panel['example'] = ui.form_card(box='1 1 11 10', items=[            ui.button(name='show_side_panel', label='Open side panel', primary=True)        ])        q.client.initialized = True
    # Was the show_side_panel button clicked?    if q.args.show_side_panel:        # Create a side panel with a close button['meta'].side_panel = ui.side_panel(            title='Hello!',            name="my_side_panel",            items=[                ui.text('Click the X button to close this side panel.')            ],            # Enable a close button (displayed at the top-right of the side panel)            closable=True,            # Get notified when the side panel is dismissed.            events=['dismissed'],        )
    # Did we get events from the side panel?    if        # Was the side panel dismissed?        if            # Delete the side panel  ['meta'].side_panel = None

Tags: โ€‚meta โ€‚sidepanel