Display a link to another page in a multipage app or to an external page.
If another page in a multipage app is specified, clicking the Jt.pageLink
element stops the current page execution
and runs the specified page as if the user clicked on it in the sidebar navigation.
If an external page is specified, clicking the Jt.pageLink
element opens a new tab to the specified page.
The current script run will continue if not complete.
Method Signatures and Parameters | |
Jt.pageLink(Class<?> pageClass) | pageClass (Class<?>) The class of the page to link to in a multipage app. If null, target the home page. |
Jt.pageLink(String url, String label) | url (String) The URL to link to label (String) The text to display for the link. Markdown is supported, see |
Chainable builder methods | |
label(String label) | The text to display for the link. Markdown is supported, see |
icon(String icon) | An icon to display with the error message. The following values are valid:
null (default), no icon is displayed.
|
help(String help) | A tooltip that gets displayed next to the text. If this is |
disabled(boolean disabled) | Disable the link if set to true. |
width(String width) | The width of the link element. Use |
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. |
Examples
A multipage app with the sidebar hidden. A footer replaces the sidebar. The footer contains links to all pages of the app and an external link.
import tech.catheu.jeamlit.core.Jt;
public class ToDelete {
public static class FirstPage {
public static void main(String[] args) {
Jt.title("First Page").use();
Jt.text("first page content").use();
}
}
public static class SecondPage {
public static void main(String[] args) {
Jt.title("Second Page").use();
Jt.text("Second page content").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:"))
.hidden()
.use();
Jt.divider().use();
Jt.pageLink(FirstPage.class).use();
Jt.pageLink(SecondPage.class).use();
Jt.pageLink("https://github.com/jeamlit/jeamlit", "Github project").icon(":link:").use();
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.