samedi 7 janvier 2023

How to disable checkboxes in a Checkbox Group imported from dash mantine components (e.g. dmc)?

Dear Stackoverflow Members

I am currently looking for advice on how to disable a Checkbox from the CheckboxGroup so as to prevent multiple selection.

As an illustration, please find below a sample code built:

  dmc.CheckboxGroup(
                      id="checkbox-group",
                      orientation="horizontal",
                      offset="md",
                      mb=10,
                      children=[
                                 dmc.Checkbox(label="LABEL_A", value="lbl_a"),
                                 dmc.Checkbox(label="LABEL_B", value="lbl_b"),
                                 dmc.Checkbox(label="LABEL_C", value="lbl_c"),
                               ],
                   ),

 @app.callback(
                Output("checkbox-group", "children"), Input("checkbox-group", "value"),
              )

 def select(checkbox):

       if "lbl_a" in checkbox:
                return [
                         dmc.Checkbox(label="LABEL_A", value="lbl_a", checked= True),
                         dmc.Checkbox(label="LABEL_B", value="lbl_b", disabled= True),
                         dmc.Checkbox(label="LABEL_C", value="lbl_c", disabled= True),
                       ] 

Thanks in advance.

Best wishes.




Aucun commentaire:

Enregistrer un commentaire