See https://getbootstrap.com/docs/4.0/components/pagination/.
Insert inside pagination.
pagination(
...,
id = NULL,
selected = NULL,
align = c("center", "left", "right"),
size = c("md", "sm", "lg"),
previousBtn = "«",
nextBtn = "»",
.list = NULL
)
paginationItem(title, ..., value = title, icon = NULL, disabled = FALSE)
updatePagination(
id,
selected = NULL,
disabled = NULL,
session = shiny::getDefaultReactiveDomain()
)
Slot for paginationItem.
Unique widget id. For programmatic update. See updatePagination.
Which element to select at start.
Alignment.
Buttons size.
Previous button text.
Next button text.
Programmatically generated paginationItem.
Display title for tab
The value that should be sent when tabsetPanel
reports
that this tab is selected. If omitted and tabsetPanel
has an
id
, then the title will be used.
Optional icon to appear on the tab. This attribute is only
valid when using a tabPanel
within a navbarPage()
.
Whether to disable the item. Default to FALSE.
Shiny session object.
An HTML pagination container
An HTML tag.
Send a message from R to JS so as to update the pagination widget on the client.
if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
pagination(
paginationItem("page1", box(title = "This is a box!")),
paginationItem("page2", "This is page 2", disabled = TRUE),
paginationItem("page3", "This is page 3", disabled = TRUE),
paginationItem(
"page4",
sliderInput(
"obs",
"Number of observations:",
min = 0,
max = 1000,
value = 500
),
plotOutput("distPlot"),
icon = icon("cog")
)
)
)
),
server = function(input, output, session) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
)
}
if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
fluidRow(
actionButton("update", "Select page 4", class = "mx-2"),
actionButton("disable", "Disable page 1", class = "mx-2"),
actionButton("enable", "Enable page 1", class = "mx-2"),
textOutput("selected_page")
),
br(),
pagination(
id = "mypagination",
paginationItem("page1", box(title = "This is a box!")),
paginationItem("page2", "This is page 2", disabled = TRUE),
paginationItem("page3", "This is page 3"),
paginationItem(
"page4",
sliderInput(
"obs",
"Number of observations:",
min = 0,
max = 1000,
value = 500
),
plotOutput("distPlot"),
icon = icon("cog")
)
)
)
),
server = function(input, output, session) {
observeEvent(input$update,{
updatePagination("mypagination", selected = "page4")
})
observeEvent(input$disable,{
updatePagination("mypagination", disabled = "page1")
})
observeEvent(input$enable,{
updatePagination("mypagination", selected = "page1")
})
output$selected_page <- renderText({
sprintf("Currently selected page: %s", input$mypagination)
})
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
)
}