Giter VIP home page Giter VIP logo

shiny.emptystate's Introduction

shiny.emptystate

Empty state components for Shiny.

R-CMD-check

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:

  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

The goal of this package is to make it easy to handle empty states in your shiny applications.

How to install?

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)
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.

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 and describe your problem as detailed as possible.

Appsilon

Appsilon is a Posit (formerly RStudio) Full Service Certified Partner.
Learn more at appsilon.com.

Get in touch [email protected]

Explore the Rhinoverse - a family of R packages built around Rhino!

We are hiring!

shiny.emptystate's People

Contributors

jakubnowicki avatar vibalre avatar rszymanski avatar vedhav avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.