Py.Cafe

michaelw88/

dash-app-editable-text-toggle

Dash App with Editable Text and Toggle Button

DocsPricing
  • app.py
  • dash_mantine_components-0.14.6-py3-none-any.whl
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from dash import callback, Input, Output, MATCH, Dash, _dash_renderer,  no_update, State
import dash_mantine_components as dmc

_dash_renderer._set_react_version("18.2.0")

app = Dash(external_stylesheets=dmc.styles.ALL)
app.layout = dmc.MantineProvider(
     children=[
         dmc.EditableText("test",id="new"),
         dmc.Button("Toggle mode", id="button", n_clicks=0),
     ],
 )


@callback(
    Output("new", "isEditting"),
    Input("button", "n_clicks"),
    State("new", "isEditting"),
    prevent_initial_call=True
)
def toggle(n_clicks, isEditting):
    if n_clicks == 0:
        return no_update
    else:
        return not isEditting


app.run(debug=True)