Dropdown Sub Category List

Hello. Is it possible adding sub categories to dropdown? You can see an example in the picture. Is there any feature for that? If there is no feature like that, do you have any idea how to make a drop down like that? Thank you.

sub

Hi @outlier

You can make groups with the dash-mantine-components dmc.Select or dmc.MultiSelect components. Here is an example:

image


from dash import  Dash, html
import dash_mantine_components as dmc

app = Dash(__name__)

app.layout = html.Div(
    [
        dmc.Select(
            label="Select category",
            placeholder="Select one",
            value="sub-1",
            data=[
                {"value": "sub-1", "label": "Sub Category 1", "group": "Main Category"},
                {"value": "sub-3", "label": "Sub Category 3",  "group": "Secondary Category"},
                {"value": "sub-2", "label": "Sub Category 2", "group": "Main Category"},
                {"value": "sub-4", "label": "Sub Category 4", "group": "Secondary Category"},
            ],
        ),
    ]
)


if __name__ == '__main__':
     app.run_server(debug=True)



1 Like

This is so cool answer! I have never heard dash_mantine_components. This is a new information for me. Thank you so much.

1 Like