Skip to content

๐ŸŽฏย ย Radial Menu

Submitted by Debbie Matthews

Summary

A circular menu component that displays options in a ring around a central button.

Functions

radial_menu

Display a radial menu with the given options.

Parameters:

Name Type Description Default
options dict[str, str]

A dictionary mapping option values to their display icons/emojis. Example: {"home": "๐Ÿ ", "search": "๐Ÿ”", "settings": "โš™๏ธ"}

required
default str | None

The default selected option. If None, uses the first option.

None
key str

A unique key for this component instance.

'radial_menu'

Returns:

Type Description
RadialMenuState

A TypedDict with a "selection" key containing the currently selected option value.

Example:

```python
result = radial_menu({"home": "๐Ÿ ", "search": "๐Ÿ”", "settings": "โš™๏ธ"})
st.write(f"Selected: {result['selection']}")
```
Source code in src/streamlit_extras/radial_menu/__init__.py
@extra
def radial_menu(
    options: dict[str, str],
    *,
    default: str | None = None,
    key: str = "radial_menu",
) -> RadialMenuState:
    """Display a radial menu with the given options.

    Args:
        options: A dictionary mapping option values to their display icons/emojis.
            Example: {"home": "๐Ÿ ", "search": "๐Ÿ”", "settings": "โš™๏ธ"}
        default: The default selected option. If None, uses the first option.
        key: A unique key for this component instance.

    Returns:
        A TypedDict with a "selection" key containing the currently selected option value.

    Example:

        ```python
        result = radial_menu({"home": "๐Ÿ ", "search": "๐Ÿ”", "settings": "โš™๏ธ"})
        st.write(f"Selected: {result['selection']}")
        ```
    """
    if default is None:
        default = next(iter(options.keys()), None)

    return _COMPONENT(
        key=key,
        data={"options": options, "selection": default},
        default={"selection": default},
        on_selection_change=lambda: None,
    )

Import:

from streamlit_extras.radial_menu import radial_menu # (1)!
  1. You should add this to the top of your .py file ๐Ÿ› 

Examples

example

def example() -> None:
    """Example usage of the radial menu component."""
    import streamlit as st

    st.write("Click the button below to open the radial menu:")

    result = radial_menu(
        options={
            "home": "๐Ÿ ",
            "search": "๐Ÿ”",
            "settings": "โš™๏ธ",
            "profile": "๐Ÿ‘ค",
            "help": "โ“",
        },
        key="demo_menu",
    )

    st.write(f"**Selected:** `{result['selection']}`")