Insert a multi-element container.

Insert an invisible container into your app that can be used to hold multiple elements. This allows you to, for example, insert multiple elements into your app out of order.

To add elements to the returned container:

 
 var container = Jt.container("container-1").use();
 Jt.yourElement().use(container);
 
 
See examples below.

Method Signatures and Parameters

Jt.container()

Chainable builder methods

height(Integer height)

The height of the container in pixels. When a fixed height is specified, the container will enable scrolling if content exceeds the specified height. It is recommended to use scrolling containers sparingly and avoid heights that exceed 500 pixels for optimal mobile experience.

border(Boolean border)

Whether to show a border around the container. If not specified (null), the border is automatically shown when the container has a fixed height, and hidden when height adapts to content.

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 MAIN container.

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 container usage and adding elements out of order

 import tech.catheu.jeamlit.core.Jt;

 public class ContainerApp {
     public static void main(String[] args) {
         var container = Jt.container().use();

         Jt.text("This is inside the container").use(container);
         Jt.text("This is outside the container").use();
         Jt.text("This is inside too").use(container);
     }
 }

forum

Still have questions?

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