Empty state components for Shiny.
Empty states are situations where there is no data to display to the user. A good example is an empty shopping cart on an e-commerce site.
In the context of dashboards you can encounter empty states when:
The goal of this package is to make it easy to handle empty states in your shiny applications.
::install_github("Appsilon/shiny.emptystate") remotes
To start using shiny.emptystate
, you need to:
use_empty_state()
in your UI definitionEmptyStateManager
class where
you define by the id
which element of your app should be
covered with the empty state contentshow
and hide
methods to show or
hide the empty state content depending on your custom logic
(e.g. nrow(data_to_display) > 0
)library(shiny)
library(shiny.emptystate)
library(reactable)
<- fluidPage(
ui use_empty_state(),
actionButton("show", "Show empty state!"),
actionButton("hide", "Hide empty state!"),
reactableOutput("my_table")
)
<- function(input, output, session) {
server <- div(
empty_state_content "This is example empty state content"
)
<- EmptyStateManager$new(
empty_state_manager id = "my_table",
html_content = empty_state_content
)
observeEvent(input$show, {
$show()
empty_state_manager
})
observeEvent(input$hide, {
$hide()
empty_state_manager
})
$my_table <- reactable::renderReactable({
outputreactable(iris)
})
}
shinyApp(ui, server)
For more examples of empty state components, please see this demo.
If you want to contribute to this project please submit a regular PR, once you’re done with new feature or bug fix.
Reporting a bug is also helpful - please use GitHub issues and describe your problem as detailed as possible.
Appsilon is a Posit (formerly RStudio) Full Service Certified
Partner.
Learn more at appsilon.com.
Get in touch opensource@appsilon.com
Explore the Rhinoverse - a family of R packages built around Rhino!