top of page

3 Streamlit Features for better UX



Streamlit is a great python framework for building reactive apps. It offers alot of components for layout, interaction, charts, data management and many other web app oriented tools. With all this app building material at our disposal, the challenge shifts quickly from app implementation to user experience (UX). At work and for personal projects I have used streamlit on multiple projects for quick utility apps. It is great because it doesn’t eat into time or client budget but allows us to implement better tools to the backend software we write.


Below are 3 features I have found over time help create better user experience with streamlit.



Columns & Metrics

One of the most useful components for apps and dashboards in my opinion are cards to display high level information. In streamlit v1.0.1 this type of component was added, called “Metric” with the ability to set a value, label and even optionally set a delta change that gets display as green or red based on the sign of the value.



Metric components are most valuable when combined with the columns layout component. This allows for cleanly visible yet condensed cards. Columns also auto-spaces contents meaning your metric cards will be reactive from the start!


Rerun

This is an experiment feature that helps ALOT with UX. There are lots of actions that can change state of elements outside the streamlit environment but that need to get displayed after a change in streamlit again. The example below is a automation dashboard that allows the user to check and edit the status of a software agent. without using the rerun function, users would have to manually refresh their browser page to see the changes. Sometimes it is not obvious to a user when a manual refresh is required though. With rerun the user doesn’t have to think about issues like this as much.


example


code used


Session State

Session_State may sound less glamorous than fancy components, but this saves alot of complexity around state management. This becomes especially useful if you have your streamlit app broken out into multiple python modules (ie maybe for separate pages). Rather then passing variables around with controllers or dealing with global variables, the session state object holds variables in memory.



This is the ideal way to handle data that is not static and may need to be referenced across many locations in your streamlit app.



Source: Medium - Robby Boney


The Tech Platform

0 comments

Comments


bottom of page