Insert a popover container.

Inserts a multi-element container as a popover. It consists of a button-like element and a container that opens when the button is clicked.

Opening and closing the popover will not trigger a rerun. Interacting with widgets inside of an open popover will rerun the app while keeping the popover open. Clicking outside of the popover will close it.

To add elements to the returned popover:

 var popover = Jt.popover("my-popover", "Advanced configuration").use();
 Jt.yourElement().use(popover);
See examples below.

Method Signatures and Parameters

Jt.popover(String label)

label (String)

The label for the popover button. Markdown is supported, see Jt#markdown(String) for more details.

Chainable builder methods

help(String help)

A tooltip that gets displayed next to the text. If this is null (default), no tooltip is displayed.

disabled(boolean disabled)

Disables the popover button if set to True. When disabled, users cannot interact with the widget.

useContainerWidth(boolean useContainerWidth)

Controls the button width. If True, the button width matches the parent container width. If False (default), the button width matches its content width. This parameter is deprecated - use width() instead.

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

Settings popover

 import tech.catheu.jeamlit.core.Jt;

 import java.util.List;

 public class PopoverApp {
     public static void main(String[] args) {
         var settings = Jt.popover("⚙️ Settings").use();

         Jt.text("Configure your preferences:").use(settings);
         boolean notifications = Jt.checkbox("Enable notifications").use(settings);
         String theme = Jt.selectbox("Theme", List.of("Light", "Dark")).use(settings);

         if (notifications) {
             Jt.text("Notifications are enabled").use();
         }
         Jt.text("The selected theme is " + theme).use();
     }
 }

Help popover with information

 import tech.catheu.jeamlit.core.Jt;

 public class HelpPopoverApp {
     public static void main(String[] args) {
         Jt.text("Username:").use();
         Jt.textInput("Enter username").use();

         var help = Jt.popover("❓ Help").use();
         Jt.text("**Username requirements:**").use(help);
         Jt.text("- Must be 3-20 characters long").use(help);
         Jt.text("- Only letters and numbers allowed").use(help);
         Jt.text("- Case sensitive").use(help);
     }
 }

forum

Still have questions?

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