Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Appsilon/shiny.emptystate
Empty state components for Shiny
https://github.com/Appsilon/shiny.emptystate
empty-state r r-shiny rhinoverse
Last synced: 3 months ago
JSON representation
Empty state components for Shiny
- Host: GitHub
- URL: https://github.com/Appsilon/shiny.emptystate
- Owner: Appsilon
- Created: 2022-09-01T10:24:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T20:06:01.000Z (6 months ago)
- Last Synced: 2024-08-07T08:29:23.893Z (3 months ago)
- Topics: empty-state, r, r-shiny, rhinoverse
- Language: R
- Homepage: https://appsilon.github.io/shiny.emptystate/
- Size: 2.36 MB
- Stars: 26
- Watchers: 16
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-shiny-extensions - shiny.emptystate - Empty state components for Shiny. (UI Components / Loader)
- jimsghstars - Appsilon/shiny.emptystate - Empty state components for Shiny (R)
README
> _Empty state components for Shiny._
[![CRAN status](https://www.r-pkg.org/badges/version/shiny.emptystate)](https://cran.r-project.org/package=shiny.emptystate)
![R-CMD-check](https://github.com/Appsilon/shiny.emptystate/workflows/R-CMD-check/badge.svg)
[![codecov](https://codecov.io/gh/Appsilon/shiny.emptystate/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Appsilon/shiny.emptystate/)[Empty states](https://www.nngroup.com/articles/empty-state-interface-design/) 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:
1. Before displaying any charts a user needs to upload a file containing the required data
2. Users apply different filters to a dataset and there is no row matching the configured filters![](./man/figures/file_upload_empty_state_example.gif)
The goal of this package is to make it easy to handle empty states in your shiny applications.
## How to install?
Stable version:
```r
install.packages("shiny.emptystate")
```Development version:
```r
remotes::install_github("Appsilon/shiny.emptystate")
```## How to use it?
To start using `shiny.emptystate`, you need to:
1. Include `use_empty_state()` in your UI definition
2. Define the content you want to display as an empty state (e.g. a message)
3. Create an instance of the `EmptyStateManager` class where you define by the `id` which element of your app should be covered with the empty state content
4. Use its `show` and `hide` methods to show or hide the empty state content depending on your custom logic (e.g. `nrow(data_to_display) > 0`)```r
library(shiny)
library(shiny.emptystate)
library(reactable)ui <- fluidPage(
use_empty_state(),
actionButton("show", "Show empty state!"),
actionButton("hide", "Hide empty state!"),
reactableOutput("my_table")
)server <- function(input, output, session) {
empty_state_content <- div(
"This is example empty state content"
)empty_state_manager <- EmptyStateManager$new(
id = "my_table",
html_content = empty_state_content
)observeEvent(input$show, {
empty_state_manager$show()
})observeEvent(input$hide, {
empty_state_manager$hide()
})output$my_table <- reactable::renderReactable({
reactable(iris)
})
}shinyApp(ui, server)
```For more examples of empty state components, please see this [demo](https://connect.appsilon.com/shiny-emptystate-demo/).
## How to contribute?
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](https://github.com/Appsilon/shiny.emptystate/issues) and describe your problem as detailed as possible.
## Appsilon
Appsilon is a **Posit (formerly RStudio) Full Service Certified Partner**.
Learn more at [appsilon.com](https://appsilon.com).Get in touch [[email protected]](mailto:[email protected])
Explore the [Rhinoverse](https://rhinoverse.dev) - a family of R packages built around [Rhino](https://appsilon.github.io/rhino/)!