Create a navigation component with multiple pages to create a multipage app.

Call Jt.navigation in your entrypoint app class to define the available pages in your app. Jt.navigation use() returns the current page.

When using Jt.navigation, your entrypoint app class acts like a frame of common elements around each of your pages.

The set of available pages can be updated with each rerun for dynamic navigation. By default, Jt.navigation displays the available pages in the sidebar if there is more than one page. This behavior can be changed using the position builder method.

Method Signatures and Parameters

Jt.navigation(JtPage.Builder[] pages)

pages (io.jeamlit.core.JtPage.Builder[])

The pages to include in the navigation

Returns after .use()

(io.jeamlit.core.NavigationComponent.Builder)

The current io.jeamlit.core.NavigationComponent.Builder value of the component.

Examples

Basic multipage navigation setup

 import tech.catheu.jeamlit.core.Jt;

 public class NavigationApp {
     public static class FirstPage {
         public static void main(String[] args) {
             Jt.title("First Page").use();
         }
     }

     public static class SecondPage {
         public static void main(String[] args) {
             Jt.title("Second Page").use();
         }
     }

     public static void main(String[] args) {
         var page = Jt
                 .navigation(Jt.page(FirstPage.class).title("First page").icon("🔥"),
                             Jt.page(SecondPage.class).title("Second page").icon(":favorite:"))
                 .use();
     }
 }

forum

Still have questions?

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