Insert a multi-element container that can be expanded/collapsed.
Insert a container into your app that can be used to hold multiple elements and can be expanded or collapsed by the user. When collapsed, all that is visible is the provided label.
To add elements to the returned expander:
var expander = Jt.expander("my-expander", "More details").use();
Jt.yourElement().use(expander);
See examples below.
Method Signatures and Parameters | |
Jt.expander(String label) | label (String) The label for the expander header |
Chainable builder methods | |
expanded(boolean expanded) | The initial state of the expander. When set to |
width(String width) | The width of the element. This can be one of the following:
|
width(int widthPixels) | The width of the element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
No description | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
Returns after .use() | |
(JtContainer) | The current JtContainer value of the component. |
Examples
Basic expander with explanation content
import tech.catheu.jeamlit.core.Jt;
public class ExpanderApp {
public static void main(String[] args) {
var expander = Jt.expander("See explanation").use();
Jt.text("""
[A great explanation on the why and how of life.]
""").use(expander);
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.