Skip to content

ohtaman/streamlit-sortables

Repository files navigation

Streamlit Sortables

A Streamlit component to provide sortable list. You can sort the list of strings on the UI as follows.

streamlit-sortables.mp4

Installation

$ pip install streamlit-sortables

Usage

Call sorted_items method with a list of string. Return value is the sorted items.

import streamlit as st
from streamlit_sortables import sort_items


original_items = ['A', 'B', 'C']
sorted_items = sort_items(original_items)

st.write(f'original_items: {original_items}')
st.write(f'sorted_items: {sorted_items}')

You can pass list of dicts with multi_containers=True.

import streamlit as st
from streamlit_sortables import sort_items

original_items = [
    {'header': 'first container',  'items': ['A', 'B', 'C']},
    {'header': 'second container', 'items': ['D', 'E', 'F']}
]

sorted_items = sort_items(original_items, multi_containers=True)

st.write(f'original_items: {original_items}')
st.write(f'sorted_items: {sorted_items}')