Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions shiny/api-examples/nav_menu/app-core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_card_pill(
Expand All @@ -8,13 +8,17 @@
ui.nav_panel("B", "Panel B content"),
ui.nav_panel("C", "Panel C content"),
),
id="card_pill",
id="selected_card_pill",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_card_pill()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/nav_menu/app-express.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_card_pill(id="card_pill"):
with ui.navset_card_pill(id="selected_card_pill"):
with ui.nav_menu("Nav Menu items"):
with ui.nav_panel("A"):
"Page A content"
with ui.nav_panel("B"):
"Page B content"
with ui.nav_panel("C"):
"Page C content"
ui.h5("Selected:")


@render.code
def _():
return input.selected_card_pill()
16 changes: 0 additions & 16 deletions shiny/api-examples/nav_panel/app-basic.py

This file was deleted.

81 changes: 15 additions & 66 deletions shiny/api-examples/nav_panel/app-core.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,23 @@
from typing import List

from shiny import App, Inputs, Outputs, Session, reactive, ui
from shiny.types import NavSetArg


def nav_controls(prefix: str) -> List[NavSetArg]:
return [
ui.nav_panel("a", prefix + ": tab a content"),
ui.nav_panel("b", prefix + ": tab b content"),
ui.nav_panel("c", prefix + ": tab c content"),
ui.nav_spacer(),
ui.nav_menu(
"Links",
ui.nav_control(
ui.a(
"Shiny",
href="https://shiny.posit.co/py/",
target="_blank",
)
),
"----",
"Plain text",
"----",
ui.nav_control(
ui.a(
"Posit",
href="https://posit.co",
target="_blank",
)
from shiny import App, Inputs, ui

app_ui = ui.page_fluid(
ui.navset_bar(
ui.nav_panel("Page 1", "Page 1 content"),
ui.nav_panel(
"Page 2",
ui.navset_card_underline(
ui.nav_panel("Tab 1", "Tab 1 content"),
ui.nav_panel("Tab 2", "Tab 2 content"),
ui.nav_panel("Tab 3", "Tab 3 content"),
),
align="right",
),
]


app_ui = ui.page_navbar(
*nav_controls("page_navbar"),
title="page_navbar()",
id="navbar_id",
footer=ui.div(
{"style": "width:80%;margin: 0 auto"},
ui.tags.style(
"""
h4 {
margin-top: 3em;
}
"""
),
ui.h4("navset_tab()"),
ui.navset_tab(*nav_controls("navset_tab()")),
ui.h4("navset_pill()"),
ui.navset_pill(*nav_controls("navset_pill()")),
ui.h4("navset_underline()"),
ui.navset_underline(*nav_controls("navset_underline()")),
ui.h4("navset_card_tab()"),
ui.navset_card_tab(*nav_controls("navset_card_tab()")),
ui.h4("navset_card_pill()"),
ui.navset_card_pill(*nav_controls("navset_card_pill()")),
ui.h4("navset_card_underline()"),
ui.navset_card_underline(*nav_controls("navset_card_underline()")),
ui.h4("navset_pill_list()"),
ui.navset_pill_list(*nav_controls("navset_pill_list()")),
)
title="Nav Panel Example",
),
)


def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
def _():
print("Current navbar page: ", input.navbar_id())
def server(input: Inputs):
pass


app = App(app_ui, server)
11 changes: 0 additions & 11 deletions shiny/api-examples/nav_panel/app-express.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,3 @@
"Tab 2 content"
with ui.nav_panel("Tab 3"):
"Tab 3 content"

ui.nav_spacer()

with ui.nav_menu("Links", align="right"):
with ui.nav_control():
ui.a("Shiny", href="https://shiny.posit.co/py/", target="_blank")
"----"
"Plain text"
"----"
with ui.nav_control():
ui.a("Posit", href="https://posit.co", target="_blank")
12 changes: 8 additions & 4 deletions shiny/api-examples/nav_spacer/app-core.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_underline(
ui.nav_panel("A", "Panel A content"),
ui.nav_spacer(),
ui.nav_panel("B", "Panel B content"),
ui.nav_panel("C", "Panel C content"),
id="navset_underline",
)
id="selected_navset_underline",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_navset_underline()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/nav_spacer/app-express.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_underline():
with ui.navset_underline(id="selected_navset_underline"):
with ui.nav_panel("Tab 1"):
"Tab 1 content"
ui.nav_spacer()
with ui.nav_panel("Tab 2"):
"Tab 2 content"
with ui.nav_panel("Tab 3"):
"Tab 3 content"
ui.h5("Selected:")


@render.code
def _():
return input.selected_navset_underline()
12 changes: 8 additions & 4 deletions shiny/api-examples/navset_bar/app-core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_bar(
Expand All @@ -14,14 +14,18 @@
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
),
),
id="tab",
id="selected_navset_bar",
title="Navset Bar",
)
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_navset_bar()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/navset_bar/app-express.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_bar(title="Navset Bar", id="tab"):
with ui.navset_bar(title="Navset Bar", id="selected_navset_bar"):
with ui.nav_panel("A"):
"Panel A content"

Expand All @@ -18,3 +18,9 @@
"Description:"
with ui.nav_control():
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
ui.h5("Selected:")


@render.code
def _():
return input.selected_navset_bar()
12 changes: 8 additions & 4 deletions shiny/api-examples/navset_card_pill/app-core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_card_pill(
Expand All @@ -14,13 +14,17 @@
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
),
),
id="tab",
)
id="selected_navset_card_pill",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_navset_card_pill()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/navset_card_pill/app-express.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_card_pill(id="tab"):
with ui.navset_card_pill(id="selected_navset_card_pill"):
with ui.nav_panel("A"):
"Panel A content"

Expand All @@ -18,3 +18,9 @@
"Description:"
with ui.nav_control():
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
ui.h5("Selected:")


@render.code
def _():
return input.selected_navset_card_pill()
12 changes: 8 additions & 4 deletions shiny/api-examples/navset_card_tab/app-core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_card_tab(
Expand All @@ -14,13 +14,17 @@
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
),
),
id="tab",
)
id="selected_navset_card_tab",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_navset_card_tab()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/navset_card_tab/app-express.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_card_tab(id="tab"):
with ui.navset_card_tab(id="selected_navset_card_tab"):
with ui.nav_panel("A"):
"Panel A content"

Expand All @@ -18,3 +18,9 @@
"Description:"
with ui.nav_control():
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
ui.h5("Selected:")


@render.code
def _():
return input.selected_navset_card_tab()
12 changes: 8 additions & 4 deletions shiny/api-examples/navset_card_underline/app-core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny import App, ui
from shiny import App, render, ui

app_ui = ui.page_fluid(
ui.navset_card_underline(
Expand All @@ -14,13 +14,17 @@
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
),
),
id="tab",
)
id="selected_navset_card_underline",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)


def server(input, output, session):
pass
@render.code
def selected():
return input.selected_navset_card_underline()


app = App(app_ui, server)
10 changes: 8 additions & 2 deletions shiny/api-examples/navset_card_underline/app-express.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from shiny.express import ui
from shiny.express import input, render, ui

with ui.navset_card_underline(id="tab"):
with ui.navset_card_underline(id="selected_navset_card_underline"):
with ui.nav_panel("A"):
"Panel A content"

Expand All @@ -18,3 +18,9 @@
"Description:"
with ui.nav_control():
ui.a("Shiny", href="https://shiny.posit.co", target="_blank")
ui.h5("Selected:")


@render.code
def _():
return input.selected_navset_card_underline()
Loading