Skip to main content

Streamlit Ant Design Menu Component

This custom Streamlit component allows you to easily integrate an Ant Design menu into your Streamlit application. The component is built using Ant Design and provides a simple interface for creating a menu with nested items and icons.

Live Demo

Features

  • Hierarchical menu structure
  • Ant Design icons support
  • Light and dark theme support
  • Customizable CSS styling
  • Multiple selection (experimental)
  • Auto-adjusting menu height
  • Click event handling

Installation

To install this component, simply run:

pip install st_ant_menu

Usage

First, import the st_ant_menu function from the package:

from st_ant_menu import st_ant_menu

Then, create a menu data structure, and call st_ant_menu with the data:

menu_data = [
{
    "key": "1",
    "label": "Menu Item 1",
    "icon": "UserOutlined",
},
{
    "key": "2",
    "label": "Menu Item 2",
    "icon": "VideoCameraOutlined",
    "disabled": True
},
{
    "key": "3",
    "label": "Menu Item 3",
    "icon": "UploadOutlined",
    "children": [
        {
            "key": "3-1",
            "label": "Submenu Item 1",
            "icon": "BarChartOutlined",
        },
        {
            "key": "3-2",
            "label": "Submenu Item 2",
            "icon": "CloudOutlined",
        },
    ],
},
]

selected_key = st_ant_menu(menu_data)

API

st_ant_menu(
menu_data: List[Dict],
key: str = "first_menu",
defaultValue: Optional[str] = None,
defaultSelectedKeys: Optional[str] = None,
defaultOpenKeys: Optional[str] = None,
additionalHeight: int = 100,
multiple: bool = False,
css_styling: Optional[Dict] = None,
theme: str = "light",
menu_click: bool = False
) -> Union[str, List[str]]

Parameters

menu_data (List[Dict]): The data to be displayed in the menu. Must be a list of dictionaries that conform to the Ant Design Menu item specification. See https://ant.design/components/menu/#Menu.Item for more information.

key (str, optional): The key associated with the component. This is used to ensure that the component is rendered properly when its value changes. Defaults to "first_menu".

defaultValue (Optional[str], optional): The default value to be displayed in the component. Defaults to None.

defaultSelectedKeys (Optional[str], optional): The default selected keys in the menu. Defaults to None. defaultOpenKeys (Optional[str], optional): The default open keys in the menu. Defaults to None. additionalHeight (int, optional): The additional height of the menu that should be added to the Streamlit iframe height. This is used to ensure that the entire menu is visible in the Streamlit app. Defaults to 100. multiple (bool, optional): Whether the menu allows multiple selections. (Broken) Defaults to False. css_styling (Optional[Dict], optional): A dictionary of CSS styling to be applied to the component. Defaults to None. theme (str, optional): The theme of the menu. Can be either "light" or "dark". Defaults to "light". menu_click (bool, optional): Set this to True to return the list of open keys on menu click, False will only return the selected key. Defaults to False.

Returns

Union[str, List[str]]: The value of the component. If menu_click is set to True, it will return a list of open keys, otherwise it will return the selected key.

Metadata

Release files for st-ant-menu 0.0.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st-ant-menu 0.0.19
File Size Uploaded
st_ant_menu-0.0.19.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for st-ant-menu 0.0.19
File Interpreter ABI Platform
st_ant_menu-0.0.19-py3-none-any.whl Python 3 none any Details

Total release size: 3.2 MB

Release files / st_ant_menu-0.0.19.tar.gz

Download URL st_ant_menu-0.0.19.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
0a818f922263b26ac81598527b3559ee2a54a87b143e2988895a523e74499853
BLAKE2b-256 checksum
How to use checksums
664467e5d968571b26f7958180be1e0f23b3216c9565aef61c1de4a3ad2e9f47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / st_ant_menu-0.0.19-py3-none-any.whl

Download URL st_ant_menu-0.0.19-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1f3f1ce314470b3314a7b10f6ed173337185419164807dff9f120c48b10e9ebc
BLAKE2b-256 checksum
How to use checksums
96b6498e5a09fe34c6b8e41c4fa38bab681ae35dec8da6fa25fc2135b6560bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.19 This release

2 release files

0.0.18

2 release files

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page