Use infoBox from shinydashboard to shiny

I use shinyto create an application in my office, and I would like to use features like infoBoxbuild in shinydashboard.

Can i use infoBox()in navbarPage?

shinyUI(fluidPage(  
  navbarPage(title="my title",collapsible=T,
  tabPanel("Update",icon=icon("refresh","fa-2x",lib="font-awesome"),
            dashboardBody(
            fluidRow(infoBox("New Orders", 10 * 2, icon = icon("credit-card"))
             )))

I know that this is definitely a story css style, but I could not figure out how to do it.

Here's what it looks like in shinydashboard:
enter image description here

this is how it looks in my application using shiny:
enter image description here

And here is the code htmlcreated infoBox():

<div class="col-sm-4">
  <div class="info-box bg-purple">
    <span class="info-box-icon">
      <i class="fa fa-download"></i>
    </span>
    <div class="info-box-content">
      <span class="info-box-text">Progress</span>
      <span class="info-box-number">25%</span>
    </div>
  </div>
</div>

Is it possible to create a css file to make the output shinylook like output shinydashboard?

## EDIT:

@Victorp @MrFlick / css style frome shinydashboard.css adminLTE.css boostrap.css, . css infobox.

+4
1

, AdminLTE.css ( shinydashboard):

### ui
library("shiny")
fluidPage(
  tags$h1("Example of an infoBox with shiny"),
  # Add CSS files
  includeCSS(path = "AdminLTE.css"),
  includeCSS(path = "shinydashboard.css"),
  br(),
  fluidRow(
    infoBox("New Orders", 10 * 2, icon = icon("credit-card"), fill = TRUE),
    infoBoxOutput("progressBox2"),
    infoBoxOutput("approvalBox2")
  ),
  fluidRow(
    # Clicking this will increment the progress amount
    box(width = 4, actionButton("count", "Increment progress"))
  )
)
### server
library("shiny")
function(input, output) {
  output$progressBox2 <- renderInfoBox({
    infoBox(
      "Progress", paste0(25 + input$count, "%"), icon = icon("list"),
      color = "purple", fill = TRUE
    )
  })
  output$approvalBox2 <- renderInfoBox({
    infoBox(
      "Approval", "80%", icon = icon("thumbs-up", lib = "glyphicon"),
      color = "yellow", fill = TRUE
    )
  })
}

, , :

# Function for adding dependencies
library("htmltools")
addDeps <- function(x) {
  if (getOption("shiny.minified", TRUE)) {
    adminLTE_js <- "app.min.js"
    adminLTE_css <- c("AdminLTE.min.css", "_all-skins.min.css")
  } else {
    adminLTE_js <- "app.js"
    adminLTE_css <- c("AdminLTE.css", "_all-skins.css")
  }

  dashboardDeps <- list(
    htmlDependency("AdminLTE", "2.0.6",
                   c(file = system.file("AdminLTE", package = "shinydashboard")),
                   script = adminLTE_js,
                   stylesheet = adminLTE_css
    ),
    htmlDependency("shinydashboard",
                   as.character(utils::packageVersion("shinydashboard")),
                   c(file = system.file(package = "shinydashboard")),
                   script = "shinydashboard.js",
                   stylesheet = "shinydashboard.css"
    )
  )

  shinydashboard:::appendDependencies(x, dashboardDeps)
}

library("shiny")
# ui 
ui <- fluidPage(
  tags$h1("Example of an infoBox with shiny"),
  br(),
  fluidRow(
    infoBox("New Orders", 10 * 2, icon = icon("credit-card"), fill = TRUE),
    infoBoxOutput("progressBox2"),
    infoBoxOutput("approvalBox2")
  ),
  fluidRow(
    # Clicking this will increment the progress amount
    box(width = 4, actionButton("count", "Increment progress"))
  )
)
# Attach dependencies
ui <- addDeps(
  tags$body(shiny::fluidPage(ui)
  )
)
# server
server <- function(input, output) {
  output$progressBox2 <- renderInfoBox({
    infoBox(
      "Progress", paste0(25 + input$count, "%"), icon = icon("list"),
      color = "purple", fill = TRUE
    )
  })
  output$approvalBox2 <- renderInfoBox({
    infoBox(
      "Approval", "80%", icon = icon("thumbs-up", lib = "glyphicon"),
      color = "yellow", fill = TRUE
    )
  })
}
# app
shinyApp(ui = ui, server = server)
+6

Source: https://habr.com/ru/post/1614299/


All Articles