-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(navset): Add server function to navset docs (#1596)
- Loading branch information
1 parent
9f1f751
commit 1651445
Showing
23 changed files
with
174 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.