Skip to content

Add sidebarSearchForm #181

@osenan

Description

@osenan

Include a component similar to shinydashboard::sidebarSearchForm using shiny.semantic components

The sidebarSearchForm is a ui component that queries a search and is placed on the sidebar.
https://github.com/rstudio/shinydashboard/blob/main/R/dashboardSidebar.R#L188
It contains as argument a textId for the id of the input text, a buttonId for the created icon button to be reactive in the server, a label for the label of the input and an icon for selecting the icon that will act as a button.

Here an example app of the sidebarSearchForm



library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar(
  sidebarSearchForm(label = "Enter a number", "searchText", "searchButton"),
  sidebarMenu(
    # Setting id makes input$tabs give the tabName of currently-selected tab
    id = "tabs",
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
    menuItem("Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new",
             badgeColor = "green"),
    menuItem("Charts", icon = icon("calendar"),
      menuSubItem("Sub-item 1", tabName = "subitem1"),
      menuSubItem("Sub-item 2", tabName = "subitem2")
    )
  )
)
body <- dashboardBody(
  tabItems(
    tabItem("dashboard",
      div(p("Dashboard tab content"))
    ),
    tabItem("widgets",
      "Widgets tab content"
    ),
    tabItem("subitem1",
      "Sub-item 1 tab content"
    ),
    tabItem("subitem2",
      "Sub-item 2 tab content"
    )
  )
)
shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) { }
)

In our implementation, we could create a function that acts as a wrapper of [shiny semantic search functions](https://github.com/rstudio/shinydashboard/blob/main/R/dashboardSidebar.R#L188) and include - if needed - format to display it nicely on the sidebar. New arguments can be created appart from the current ones avaiable in shiny.dashboard.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions