star

Tip

This page only contains information on the Jt.componentsState API. For a deeper dive into Components State and how to use it, check out Session State.

Return the components state of the session. A session corresponds to an opened tab of the app.

The current value of any component can be obtained from this map. When putting a component in the app, us the .key() method to define a specific key that will be easy to access from this map.

Method Signatures and Parameters

Jt.componentsState()

Returns after .use()

(io.jeamlit.datastructure.TypedMap)

The current io.jeamlit.datastructure.TypedMap value of the component.

Examples

Accessing component values by key

 import io.jeamlit.core.Jt;

 public class ComponentsStateApp {
     public static void main(String[] args) {
         double volumeFromUse = Jt.slider("Volume").key("volume").min(0).max(100).value(50).use();
         double volumeFromState = Jt.componentsState().getDouble("volume");

         Jt.text("Volume from slider return value: " + volumeFromUse).use();
         Jt.text("Value from components state map: " + volumeFromState).use();
     }
 }

forum

Still have questions?

Go to our discussions forum for helpful information and advice from Jeamlit experts.