Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Adding Interactivity with Widgets | Section
Building Dashboards with Streamlit

bookAdding Interactivity with Widgets

To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.

  • The st.slider widget lets users select a numeric value or range by moving a slider;
  • The st.selectbox allows users to choose a single option from a dropdown list;
  • The st.text_input widget enables users to enter freeform text.

By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.

In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.

question mark

Which Streamlit widget allows users to select a numeric value or range by moving a slider?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

bookAdding Interactivity with Widgets

Stryg for at vise menuen

To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.

  • The st.slider widget lets users select a numeric value or range by moving a slider;
  • The st.selectbox allows users to choose a single option from a dropdown list;
  • The st.text_input widget enables users to enter freeform text.

By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.

In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.

question mark

Which Streamlit widget allows users to select a numeric value or range by moving a slider?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
some-alt