Skip to content

Commit

Permalink
add demo about toggling dark theme with ui.aggrid
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Aug 27, 2024
1 parent 43121d3 commit c6a92df
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion website/documentation/content/aggrid_documentation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nicegui import ui
from nicegui import ui, ElementFilter

from . import doc

Expand Down Expand Up @@ -243,4 +243,23 @@ async def get_first_name() -> None:
page() # HIDE


@doc.demo('Handle theme change', '''
You can change the theme of the AG Grid by adding or removing classes.
This demo shows how to change the theme using a switch binding to the dark mode.
''')
def aggrid_handle_theme_change():
from nicegui import events

grid = ui.aggrid({})

def handle_theme_change(e: events.ValueChangeEventArguments):
grid.classes(add='ag-theme-balham-dark' if e.value else 'ag-theme-balham',
remove='ag-theme-balham ag-theme-balham-dark')

switch = ui.switch('Dark', on_change=handle_theme_change)
# ui.dark_mode().bind_value(switch)
# END OF DEMO
next(iter(ElementFilter(kind=ui.dark_mode))).bind_value(switch)


doc.reference(ui.aggrid)

0 comments on commit c6a92df

Please sign in to comment.