Dropdown components for Dash
Project description
📦 dash_dropdown_components
Custom dropdown components for Plotly Dash similar to dcc.Dropdown, offering advanced functionality such as nested options and improved multi-select behavior.
📥 Installation
pip install dash-dropdown-components
Showcase
🧩 Components
🔽 Dropdown
A customizable dropdown component that enhances the standard Dash dropdown with additional features.
✅ Features
- Emulates dcc.Dropdown - Drop-in replacement for most use cases.
- Stays open on select – When
multi=True, the dropdown stays open after selection (unlikedcc.Dropdown). You can override this withclose_on_select=False. - Smart multi→single behavior
– When switching
multi=Truetomulti=Falsedynamically, the first selected item is automatically preserved—no need for callbacks. – Clearable formulti=Trueand not clearable formulti=Falseby default, or control usingclearableoption. - Multi-select support – Supports selecting multiple items.
- Searchable – Optionally enable a search term.
⚙️ Properties
| Property | Type | Description |
|---|---|---|
id |
string |
Unique component ID |
options |
list[dict,str] |
List of options with label and value keys, or list with values |
value |
string or list |
Selected value(s) |
multi |
bool |
Enable multiple selections |
searchable |
bool |
Enables search |
clearable |
bool |
Whether or not the dropdown is "clearable", that is, whether or not a small "x" appears on the right of the dropdown that removes the selected value. |
placeholder |
string |
Placeholder text when nothing is selected |
disabled |
bool |
If True, this dropdown is disabled and the selection cannot be changed. |
hide_options_on_select |
bool |
If True, options are removed when selected |
style |
bool |
Whether dropdown closes on selection (default True) |
className |
string |
Optional CSS class for styling |
🌲 MultiLevelDropdown
A hierarchical dropdown component that supports nested options (multilevel structure), allowing for structured category selection.
✅ Features
- Nested options – Supports arbitrarily nested dropdowns.
- Expandable submenus – Submenus open and close interactively.
- Custom labels – Each level supports custom labeling and values.
⚙️ Properties
| Property | Type | Description |
|---|---|---|
id |
string |
Unique component ID |
options |
list[dict,str] |
List of dicts of options with label, value and suboptions keys |
value |
string or list |
Selected value(s) |
multi |
bool |
Enable multiple selections |
clearable |
bool |
Whether or not the dropdown is "clearable", that is, whether or not a small "x" appears on the right of the dropdown that removes the selected value. |
placeholder |
string |
Placeholder text when nothing is selected |
disabled |
bool |
If True, this dropdown is disabled and the selection cannot be changed. |
hide_options_on_select |
bool |
If True, options are removed when selected |
submenu_widths |
list |
Control the width of the submenu for each level. Can be in percentage if the preceding level or fixed widths |
style |
bool |
Whether dropdown closes on selection (default True) |
className |
string |
Optional CSS class for styling |
💡 Usage Example
import dash_dropdown_components as ddc
from dash import Dash, callback, html, Input, Output, dcc
app = Dash(__name__)
options = [
{'value': 'banana', 'label': 'Banana'},
{'value': 'apple', 'label': 'Apple'},
{'value': 'strawberry', 'label': 'Strawberry'},
{'value': 'kiwi', 'label': 'Kiwi'},
{'value': 'orange', 'label': 'Orange'},
{'value': 'blueberry', 'label': 'Blueberry'},
{'value': 'lemon', 'label': 'Lemon'},
{'value': 'lime', 'label': 'Lime'},
{'value': 'mandarin', 'label': 'Mandarin'},
]
multi_level_options = [
{
'label': 'Fruits',
'value': 'fruits',
'suboptions': [
{ 'label': 'Apple', 'value': 'apple' },
{ 'label': 'Banana', 'value': 'banana' },
{ 'label': 'Berries',
'value': 'berries',
'suboptions': [
{ 'label': 'Strawberry', 'value': 'strawberry'},
{ 'label': 'Blueberry', 'value': 'blueberry'}
]
}
]},
{
'label': 'Vegetables',
'value': 'vegetables',
'suboptions': [
{
'label': 'Potato',
'value': 'potato'
},
{
'label': 'Carrot',
'value': 'carrot'
},
]}
];
app.layout = html.Div(
[
html.Div([
html.P('ddc.Dropdown'),
dcc.RadioItems(id='ddc-dd-multi',
options=[{'label': 'Multi: True', 'value': True},
{'label': 'Multi: False', 'value': False}],
value=False),
ddc.Dropdown(
id='ddc-dd',
options=options,
value=options[0]['value'],
multi=False,
disabled=False,
searchable=True,
hide_options_on_select=True
),
html.Div(id='ddc-dd-selection')
], style={'width': '25%', 'display': 'inline-block'}),
html.Div([
html.P('ddc.MultiLevelDropdown'),
dcc.RadioItems(id='ddc-mldd-multi',
options=[{'label': 'Multi: True', 'value': True},
{'label': 'Multi: False', 'value': False}],
value=False),
ddc.MultiLevelDropdown(
id='ddc-mldd',
options=multi_level_options,
value=['fruits', 'banana'],
multi=False,
disabled=False,
hide_options_on_select=True,
submenu_widths=['10vw', '20vw']
),
html.Div(id='ddc-mldd-selection')
], style={'width': '25%', 'display': 'inline-block'}),
],
style={'display': 'flex', 'flexDirection': 'row'})
@callback(Output('ddc-dd-selection', 'children'),
Input('ddc-dd', 'value'))
def display_output(value):
return 'You have entered {}'.format(value)
@callback(Output('ddc-mldd-selection', 'children'),
Input('ddc-mldd', 'value'))
def display_output(value):
return 'You have entered {}'.format(value)
@callback(Output('ddc-dd', 'multi'),
Input('ddc-dd-multi', 'value'))
def set_multi(multi):
return multi
@callback(Output('ddc-mldd', 'multi'),
Input('ddc-mldd-multi', 'value'))
def set_multi(multi):
return multi
if __name__ == '__main__':
app.run(debug=True)
📝 License
This project is licensed under the MIT License. See the LICENSE file for details.
🔗 Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dash_dropdown_components-0.0.15.tar.gz.
File metadata
- Download URL: dash_dropdown_components-0.0.15.tar.gz
- Upload date:
- Size: 628.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e61abacb674de8b2200f6a73278228ce8da17a93e93bbb0c7b3757a71a1cd5
|
|
| MD5 |
027fb4dd037f63edf2ab56222e7e4833
|
|
| BLAKE2b-256 |
9551ed21f3dc8690c28a85db1b253a27e3e9472c30c5faaadc9dc0112df02f42
|
File details
Details for the file dash_dropdown_components-0.0.15-py3-none-any.whl.
File metadata
- Download URL: dash_dropdown_components-0.0.15-py3-none-any.whl
- Upload date:
- Size: 635.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14cff1b90061a981622bab5bcca14875e929edb722892ed7c7e54895e3ffc9a9
|
|
| MD5 |
8c8df4a76aacfc9c274fd0b41115ca1e
|
|
| BLAKE2b-256 |
b50b1eb262a43a0cffe7b6cc15cffa7b5da7ccdf066c2fb8f2337d1ba6207ffd
|