A sortable list component for Shiny for Python using React and SortableJS.
- Drag-and-drop sorting of list items
- Nested sortable lists
You can install directly from GitHub using pip:
pip install git+https://github.com/bartoszrozek/py-shiny-react-sortable.gitOr add to your requirements.txt:
git+https://github.com/bartoszrozek/py-shiny-react-sortable.git
- Import and use the component in your Shiny app:
from react_sortable import input_react_sortable
from shiny import App, ui, render
# Example usage in a Shiny UI
items_nested = [
{
"id": 1,
"name": "Item 1",
"children": [{"id": 4, "name": "Item 1.1"}, {"id": 5, "name": "Item 1.2"}],
},
{"id": 2, "name": "Item 2"},
{
"id": 3,
"name": "Item 3",
"children": [{"id": 6, "name": "Item 3.1"}, {"id": 7, "name": "Item 3.2"}],
},
]
app_ui = ui.page_fluid(
ui.h2("React Sortable Input"),
input_react_sortable("sortable-list", items=items_nested),
)- Access the sorted list in your server logic using the input id:
@reactive.Effect
def _():
print(input["sortable-list"])Screencast.From.2025-08-25.19-19-01.mp4
MIT