import dash
import dash_mantine_components as dmc
from dash import Dash, Input, Output, State, callback
from dash_iconify import DashIconify
app = Dash()
logo = "https://github.com/user-attachments/assets/c1ff143b-4365-4fd1-880f-3e97aab5c302"
main = dmc.Box([
dmc.Select(data=["A", "B", "C"], value="B", label="select"),
dmc.Slider(
id="slider-callback",
value=26,
marks=[
{"value": 20, "label": "20%"},
{"value": 50, "label": "50%"},
{"value": 80, "label": "80%"},
],
mt=35,
),
], p="xl")
layout = dmc.AppShell(
[
dmc.AppShellHeader(
dmc.Group(
[
dmc.Burger(id="burger", size="sm", hiddenFrom="sm", opened=False),
dmc.Image(src=logo, h=40, flex=0),
dmc.Title("Demo App", c="blue"),
dmc.ActionIcon(DashIconify(icon="tabler:text-direction-ltr", width=18),id="rtl-toggle", variant="outline", color="gray")
],
h="100%",
px="md",
)
),
dmc.AppShellNavbar(
id="navbar",
children=[
"Navbar",
*[dmc.Skeleton(height=28, mt="sm", animate=False) for _ in range(15)],
],
p="md",
),
dmc.AppShellMain(main),
],
header={"height": 60},
padding="md",
navbar={
"width": 300,
"breakpoint": "sm",
"collapsed": {"mobile": True},
},
id="appshell",
)
#
app.layout = dmc.DirectionProvider(dmc.MantineProvider(layout), id="direction", persistence=True, direction="ltr")
@callback(
Output("appshell", "navbar"),
Input("burger", "opened"),
State("appshell", "navbar"),
prevent_initial_call=True
)
def navbar_is_open(opened, navbar):
navbar["collapsed"] = {"mobile": not opened}
return navbar
@callback(
Output("rtl-toggle", "children"),
Output("direction", "direction"),
Input("rtl-toggle", "n_clicks"),
State("direction", "direction")
)
def toggle_direction(n, d):
if n is None:
return dash.no_update
new_dir = "ltr" if d == "rtl" else "rtl"
return DashIconify(icon=f"tabler:text-direction-{d}", width=18), new_dir
if __name__ == "__main__":
app.run(debug=True)