Title: | Extra Twitter Bootstrap Components for Shiny |
---|---|
Description: | Adds easy access to additional Twitter Bootstrap components to Shiny. |
Authors: | Eric Bailey |
Maintainer: | Eric Bailey <[email protected]> |
License: | GPL-3 |
Version: | 0.62 |
Built: | 2025-02-12 05:41:31 UTC |
Source: | https://github.com/ebailey78/shinybs |
addPopover
is used within the Server logic of an app to add a popover to a Shiny
input or output.
addPopover(session, id, title, content, placement = "bottom", trigger = "hover", options = NULL)
addPopover(session, id, title, content, placement = "bottom", trigger = "hover", options = NULL)
session |
The session object passed to function given to shinyServer. |
id |
The id of the element to attach the popover to. |
title |
The title of the popover. |
content |
The main content of the popover. |
placement |
Where the popover should appear relative to its target
( |
trigger |
What action should cause the popover to appear? ( |
options |
A named list of additional options to be set on the popover. |
See Tooltips_and_Popovers for more information about how to use addPopover
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of addPopover
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addTooltip
; bsPopover
;
bsTooltip
; popify
;
removePopover
; removeTooltip
;
tipify
addTooltip
is used within the Server logic of an app to add a tooltip to a Shiny
input or output.
addTooltip(session, id, title, placement = "bottom", trigger = "hover", options = NULL)
addTooltip(session, id, title, placement = "bottom", trigger = "hover", options = NULL)
session |
The session object passed to function given to shinyServer. |
id |
The id of the element to attach the tooltip to. |
title |
The content of the tooltip. |
placement |
Where the tooltip should appear relative to its target
( |
trigger |
What action should cause the tooltip to appear? ( |
options |
A named list of additional options to be set on the tooltip. |
See Tooltips_and_Popovers for more information about how to use addTooltip
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of addTooltip
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; bsPopover
;
bsTooltip
; popify
;
removePopover
; removeTooltip
;
tipify
Alerts allow you to communicate information to the user on the fly. Standard Bootstrap styling options give the user a hint at the type of information contained in the Alert.
To create alerts in your Shiny app you must place bsAlert
in your ui.
This serves as an anchor that tells shinyBS where to place the alerts created
with createAlert
.
Use createAlert
in your server script to add alerts to the anchor
you created with bsAlert
in your ui. You can place createAlert
in observers, reactives, or outputs. A common usage may be to have logic that
validates a user's inputs. If they are valid produce the requested output, if
not use createAlert
to give the user info about what they need to
change.
There are three functions in the Alerts family:
bsAlert
Used in the UI to create an anchor where your Alerts will be displayed.
createAlert
Used in the Server logic to create alerts. This would be used within a reactive context to display error or success messages to the user based on the status of that context.
closeAlert
Used in the Server logic to close an alert that is already open. By default, Alerts are dismissable by the user, but this offers you a way to close them programmatically.
style
was called type
in previous versions of shinyBS.
anchorId
was called inputId
in previous versions of shinyBS.
content
was called message
in previous versions of shinyBS.
Run bsExample("Alerts")
for an example
of Alerts
functionality.
Other Alerts: bsAlert
;
closeAlert
; createAlert
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel(textInput("num1", NULL, value = 100), "divided by", textInput("num2", NULL, value = 20), "equals", textOutput("exampleOutput")), mainPanel( bsAlert("alert") ) ) ), server = function(input, output, session) { output$exampleOutput <- renderText({ num1 <- as.numeric(input$num1) num2 <- as.numeric(input$num2) if(is.na(num1) | is.na(num2)) { createAlert(session, "alert", "exampleAlert", title = "Oops", content = "Both inputs should be numeric.", append = FALSE) } else if(num2 == 0) { createAlert(session, "alert", "exampleAlert", title = "Oops", content = "You cannot divide by 0.", append = FALSE) } else { closeAlert(session, "exampleAlert") return(num1/num2) } }) } ) ## Not run: runApp(app) ## End(Not run)
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel(textInput("num1", NULL, value = 100), "divided by", textInput("num2", NULL, value = 20), "equals", textOutput("exampleOutput")), mainPanel( bsAlert("alert") ) ) ), server = function(input, output, session) { output$exampleOutput <- renderText({ num1 <- as.numeric(input$num1) num2 <- as.numeric(input$num2) if(is.na(num1) | is.na(num2)) { createAlert(session, "alert", "exampleAlert", title = "Oops", content = "Both inputs should be numeric.", append = FALSE) } else if(num2 == 0) { createAlert(session, "alert", "exampleAlert", title = "Oops", content = "You cannot divide by 0.", append = FALSE) } else { closeAlert(session, "exampleAlert") return(num1/num2) } }) } ) ## Not run: runApp(app) ## End(Not run)
bsAlert
creates an anchor point in your UI definition. This anchor point
is where alerts created in your Server logic will be displayed.
bsAlert(anchorId)
bsAlert(anchorId)
anchorId |
A unique id the identifies the anchor. |
See Alerts for more information about how to use bsAlert
with the
rest of the Alerts family.
Run bsExample("Alerts")
for an example
of bsAlert
functionality.
Other Alerts: Alerts
;
closeAlert
; createAlert
bsButton
is used in your UI script to create customizable action and toggle
buttons.
bsButton(inputId, label, icon = NULL, ..., style = "default", size = "default", type = "action", block = FALSE, disabled = FALSE, value = FALSE)
bsButton(inputId, label, icon = NULL, ..., style = "default", size = "default", type = "action", block = FALSE, disabled = FALSE, value = FALSE)
inputId |
Specifies the input slot that will be used to access the value. |
label |
The contents of the button or link–usually a text label, but you could also use any other HTML, like an image. |
icon |
An optional |
... |
Named attributes to be applied to the button or link. |
style |
A Bootstrap style to apply to the button. ( |
size |
The size of the button ( |
type |
The type of button to create. ( |
block |
logical Should the button take the full width of the parent element? |
disabled |
logical Should the button be disabled (un-clickable)? |
value |
logical If |
See Buttons for more information about how to use bsButton
with the
rest of the Buttons family.
Run bsExample("Buttons")
for an example
of bsButton
functionality.
Other Buttons: Buttons
;
updateButton
bsCollapse
is used in your UI to create a collapse panel group. Use
bsCollapsePanel
to populate this object with panels.
bsCollapse(..., id = NULL, multiple = FALSE, open = NULL)
bsCollapse(..., id = NULL, multiple = FALSE, open = NULL)
id |
Optional You can use |
multiple |
Can more than one panel be open at a time? Defaults to |
open |
The |
... |
|
See Collapses for more information about how to use bsCollapse
with the
rest of the Collapses family.
Run bsExample("Collapses")
for an example
of bsCollapse
functionality.
Other Collapses: Collapses
;
bsCollapsePanel
;
updateCollapse
bsCollapsePanel
creates individual panels within a bsCollapse
object.
bsCollapsePanel(title, ..., value = title, style = NULL)
bsCollapsePanel(title, ..., value = title, style = NULL)
title |
The title to display at the top of the panel. |
value |
Optional The value to return when this panel is open. Defaults to |
style |
Optional A Bootstrap style to apply to the panel. ( |
... |
UI elements to include within the panel. |
See Collapses for more information about how to use bsCollapsePanel
with the
rest of the Collapses family.
Run bsExample("Collapses")
for an example
of bsCollapsePanel
functionality.
Other Collapses: Collapses
;
bsCollapse
; updateCollapse
A function to view examples of shinyBS functionality. Will run the examples
found in the examples sections of shinyBS documentation. Use this instead of
example
.
bsExample(family, display.mode = "showcase", ...)
bsExample(family, display.mode = "showcase", ...)
family |
A shinyBS family name |
display.mode |
The display mode to use when running the example. See
|
... |
Other parameters to pass to |
This function is just a wrapper for runApp
that runs copies of the
examples found in the family documention pages of shinyBS
. By default,
display.mode
is set to showcase
so you can see the code while
the app is running.
## Not run: bsExample("Alerts") ## End(Not run)
## Not run: bsExample("Alerts") ## End(Not run)
bsModal
is used within the UI to create a modal window.
bsModal(id, title, trigger, ..., size)
bsModal(id, title, trigger, ..., size)
id |
A unique identifier for the modal window |
title |
The title to appear at the top of the modal |
trigger |
The id of a button or link that will open the modal. |
size |
Optional What size should the modal be? ( |
... |
UI elements to include within the modal |
See Modals for more information about how to use bsModal
with the
rest of the Modals family.
Run bsExample("Modals")
for an example
of bsModal
functionality.
Other Modals: Modals
;
toggleModal
bsPopover
is used within the UI of an app to add a popover to a Shiny
input or output.
bsPopover(id, title, content, placement = "bottom", trigger = "hover", options = NULL)
bsPopover(id, title, content, placement = "bottom", trigger = "hover", options = NULL)
id |
The id of the element to attach the popover to. |
title |
The title of the popover. |
content |
The main content of the popover. |
placement |
Where the popover should appear relative to its target
( |
trigger |
What action should cause the popover to appear? ( |
options |
A named list of additional options to be set on the popover. |
See Tooltips_and_Popovers for more information about how to use bsPopover
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of bsPopover
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsTooltip
; popify
;
removePopover
; removeTooltip
;
tipify
bsTooltip
is used within the UI of an app to add a tooltip to a Shiny
input or output.
bsTooltip(id, title, placement = "bottom", trigger = "hover", options = NULL)
bsTooltip(id, title, placement = "bottom", trigger = "hover", options = NULL)
id |
The id of the element to attach the tooltip to. |
title |
The content of the tooltip. |
placement |
Where the tooltip should appear relative to its target
( |
trigger |
What action should cause the tooltip to appear? ( |
options |
A named list of additional options to be set on the tooltip. |
See Tooltips_and_Popovers for more information about how to use bsTooltip
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of bsTooltip
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsPopover
; popify
;
removePopover
; removeTooltip
;
tipify
typeaheadInput
creates a textinput with type ahead function buttons.
bsTypeahead(inputId, label, value = "", choices, items = 8, minLength = 1)
bsTypeahead(inputId, label, value = "", choices, items = 8, minLength = 1)
inputId |
Input variable to assign the control's value to |
label |
Display label for the control |
value |
Initial value |
choices |
Array of strings to match against. Can also be JavaScript
function. Use htmlwidgets::JS() to indicate JavaScript. The length of |
items |
The max number of items to display in the dropdown. Can also be set to 'all' |
minLength |
The minimum character length needed before triggering autocomplete suggestions. You can set it to 0 so suggestion are shown even when there is no text when lookup function is called. |
updateTypeaheadInput
Twitter Bootstrap gives many options for styling buttons that aren't made available by standard Shiny. Use shinyBS to create buttons of different sizes, shapes, and colors.
Create a button in the UI with bsButton
. If type = "action"
the button will behave like the standard actionButton
in shiny.
If type = "toggle"
the button will behave like a checkboxInput
with an on and off state. It will return TRUE
or FALSE
to the Server
depending on its state.
You can update the style and state of a bsButton
from the Server
logic with updateButton
. For example, a button could be set to
disabled = TRUE
until the user has made some other selections, then once
those selections have been made, an observer on the Server could use updateButton
to enable the button allowing the user to proceed. Alternatively, you could set
the button to style = "success"
to let them know that the button is ready
to be clicked.
There are two functions in the Buttons family:
bsButton
Used in the UI to create a button. Buttons
can be of the type action
or toggle
.
updateButton
Used in the Server logic to modify the
state of a button created with bsButton
bsActionButton
and bsToggleButton
were replaced with just
bsButton
with a type
argument.
icon
was added to allow placing an icon in the button.
Run bsExample("Buttons")
for an example
of Buttons
functionality.
Other Buttons: bsButton
;
updateButton
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Move the slider to see its effect on the button below:", min = 1, max = 50, value = 1), bsButton("actTwo", label = "Click me if you dare!", icon = icon("ban")), tags$p("Clicking the first button below changes the disabled state of the second button."), bsButton("togOne", label = "Toggle button disabled status", block = TRUE, type = "toggle", value = TRUE), bsButton("actOne", label = "Block Action Button", block = TRUE) ), mainPanel( textOutput("exampleText") ) ) ), server = function(input, output, session) { observeEvent(input$togOne, ({ updateButton(session, "actOne", disabled = !input$togOne) })) observeEvent(input$bins, ({ b <- input$bins disabled = NULL style = "default" icon = "" if(b < 5) { disabled = TRUE icon <- icon("ban") } else { disabled = FALSE } if(b < 15 | b > 35) { style = "danger" } else if(b < 20 | b > 30) { style = "warning" } else { style = "default" icon = icon("check") } updateButton(session, "actTwo", disabled = disabled, style = style, icon = icon) })) output$exampleText <- renderText({ input$actTwo b <- isolate(input$bins) txt = "" if((b > 5 & b < 15) | b > 35) { txt = "That was dangerous." } else if((b > 5 & b < 20) | b > 30) { txt = "I warned you about that." } else if(b >= 20 & b <= 30) { txt = "You have chosen... wisely." } return(txt) }) } ) ## Not run: runApp(app) ## End(Not run)
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Move the slider to see its effect on the button below:", min = 1, max = 50, value = 1), bsButton("actTwo", label = "Click me if you dare!", icon = icon("ban")), tags$p("Clicking the first button below changes the disabled state of the second button."), bsButton("togOne", label = "Toggle button disabled status", block = TRUE, type = "toggle", value = TRUE), bsButton("actOne", label = "Block Action Button", block = TRUE) ), mainPanel( textOutput("exampleText") ) ) ), server = function(input, output, session) { observeEvent(input$togOne, ({ updateButton(session, "actOne", disabled = !input$togOne) })) observeEvent(input$bins, ({ b <- input$bins disabled = NULL style = "default" icon = "" if(b < 5) { disabled = TRUE icon <- icon("ban") } else { disabled = FALSE } if(b < 15 | b > 35) { style = "danger" } else if(b < 20 | b > 30) { style = "warning" } else { style = "default" icon = icon("check") } updateButton(session, "actTwo", disabled = disabled, style = style, icon = icon) })) output$exampleText <- renderText({ input$actTwo b <- isolate(input$bins) txt = "" if((b > 5 & b < 15) | b > 35) { txt = "That was dangerous." } else if((b > 5 & b < 20) | b > 30) { txt = "I warned you about that." } else if(b >= 20 & b <= 30) { txt = "You have chosen... wisely." } return(txt) }) } ) ## Not run: runApp(app) ## End(Not run)
closeAlert
is used within your Server logic to close an alert that you
created with createAlert
.
closeAlert(session, alertId)
closeAlert(session, alertId)
session |
The session object passed to function given to shinyServer. |
alertId |
The id of the alert to be dismissed. |
See Alerts for more information about how to use closeAlert
with the
rest of the Alerts family.
Run bsExample("Alerts")
for an example
of closeAlert
functionality.
Other Alerts: Alerts
; bsAlert
;
createAlert
Collapse panels allow you to reduce clutter in your Shiny app by making panels of information that open and close with a user's click. Any type of content can go in a collapse panel. Standard Bootstrap styling options are available.
Collapses are designed to mimic tabsetPanel
in their implementation.
Start with bsCollapse
to create a panel group, then fill it with panels
using bsCollapsePanel
.
bsCollapse
acts as an input, so you can retrieve which panels are open
from the input object passed to the function in shinyServer
.
updateCollapse
can be used within your server logic to open/close
collapse panels or to change their style.
bsCollapse
A container for holder the individual panels created by bsCollapsePanel
.
bsCollapsePanel
Creates an individual Collapse Panel that resides within a bsCollapse
.
updateCollapse
Used within your server logic to open/close collapse panels or change their style.
style
is a new option that wasn't available in previous versions of
shinyBS.
Run bsExample("Collapses")
for an example
of Collapses
functionality.
Other Collapses: bsCollapsePanel
;
bsCollapse
; updateCollapse
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel(HTML("This button will open Panel 1 using <code>updateCollapse</code>."), actionButton("p1Button", "Push Me!"), selectInput("styleSelect", "Select style for Panel 1", c("default", "primary", "danger", "warning", "info", "success")) ), mainPanel( bsCollapse(id = "collapseExample", open = "Panel 2", bsCollapsePanel("Panel 1", "This is a panel with just text ", "and has the default style. You can change the style in ", "the sidebar.", style = "info"), bsCollapsePanel("Panel 2", "This panel has a generic plot. ", "and a 'success' style.", plotOutput("genericPlot"), style = "success") ) ) ) ), server = function(input, output, session) { output$genericPlot <- renderPlot(plot(rnorm(100))) observeEvent(input$p1Button, ({ updateCollapse(session, "collapseExample", open = "Panel 1") })) observeEvent(input$styleSelect, ({ updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect)) })) } ) ## Not run: runApp(app) ## End(Not run)
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel(HTML("This button will open Panel 1 using <code>updateCollapse</code>."), actionButton("p1Button", "Push Me!"), selectInput("styleSelect", "Select style for Panel 1", c("default", "primary", "danger", "warning", "info", "success")) ), mainPanel( bsCollapse(id = "collapseExample", open = "Panel 2", bsCollapsePanel("Panel 1", "This is a panel with just text ", "and has the default style. You can change the style in ", "the sidebar.", style = "info"), bsCollapsePanel("Panel 2", "This panel has a generic plot. ", "and a 'success' style.", plotOutput("genericPlot"), style = "success") ) ) ) ), server = function(input, output, session) { output$genericPlot <- renderPlot(plot(rnorm(100))) observeEvent(input$p1Button, ({ updateCollapse(session, "collapseExample", open = "Panel 1") })) observeEvent(input$styleSelect, ({ updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect)) })) } ) ## Not run: runApp(app) ## End(Not run)
createAlert
is used within the Server logic of your Shiny app to display
an alert to the user.
createAlert(session, anchorId, alertId = NULL, title = NULL, content = NULL, style = NULL, dismiss = TRUE, append = TRUE)
createAlert(session, anchorId, alertId = NULL, title = NULL, content = NULL, style = NULL, dismiss = TRUE, append = TRUE)
session |
The session object passed to function given to shinyServer. |
anchorId |
The unique identifier of the anchor where the alert should be displayed. |
alertId |
Optional A unique identifier for the Alert. |
title |
Optional A title for the Alert. |
content |
The main body of the Alert. HTML tags are allowed. |
style |
A bootstrap style to apply. Defaults to |
dismiss |
|
append |
|
See Alerts for more information about how to use createAlert
with the
rest of the Alerts family.
Run bsExample("Alerts")
for an example
of createAlert
functionality.
Other Alerts: Alerts
; bsAlert
;
closeAlert
Modal windows are similar to popups but are rendered within the original window. They can contain any combination of shiny inputs, shiny outputs, and html. Possible uses include extra controls that you don't want cluttering up the main app display or help pages to explain your apps operation.
Use bsModal
in your UI to create a modal window. It works
like Collapses
or tabPanel
, any non-named arguments
will be passed as content for the modal.
Create a button or link and assign its inputId
as the trigger
in bsModal
.
There are only two functions in the Modals family:
bsModal
Used in the UI to create a modal window.
toggleModal
Used in the Server logic to open or close a modal window programmatically.
There is now a toggle
argument in toggleModal
that allows
you to specify whether you want the modal to open or close.
The size
argument in bsModal
allows you to specify the
size of the modal window. Either small
or large
.
Run bsExample("Modals")
for an example
of Modals
functionality.
Other Modals: bsModal
;
toggleModal
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30), actionButton("tabBut", "View Table") ), mainPanel( plotOutput("distPlot"), bsModal("modalExample", "Data Table", "tabBut", size = "large", dataTableOutput("distTable")) ) ) ), server = function(input, output, session) { output$distPlot <- renderPlot({ x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$distTable <- renderDataTable({ x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins tab <- hist(x, breaks = bins, plot = FALSE) tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) { paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3)) }) tab <- as.data.frame(do.call(cbind, tab)) colnames(tab) <- c("Bins", "Counts", "Density") return(tab[, 1:3]) }, options = list(pageLength=10)) } ) ## Not run: runApp(app) ## End(Not run)
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30), actionButton("tabBut", "View Table") ), mainPanel( plotOutput("distPlot"), bsModal("modalExample", "Data Table", "tabBut", size = "large", dataTableOutput("distTable")) ) ) ), server = function(input, output, session) { output$distPlot <- renderPlot({ x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$distTable <- renderDataTable({ x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins tab <- hist(x, breaks = bins, plot = FALSE) tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) { paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3)) }) tab <- as.data.frame(do.call(cbind, tab)) colnames(tab) <- c("Bins", "Counts", "Density") return(tab[, 1:3]) }, options = list(pageLength=10)) } ) ## Not run: runApp(app) ## End(Not run)
popify
can be wrapped around any shiny UI element to add a popover to the
wrapped element. This should be a safer way to add popovers to elements created with
renderUI
.
popify(el, title, content, placement = "bottom", trigger = "hover", options = NULL)
popify(el, title, content, placement = "bottom", trigger = "hover", options = NULL)
el |
A shiny UI element. |
title |
The title of the popover. |
content |
The main content of the popover. |
placement |
Where the popover should appear relative to its target
( |
trigger |
What action should cause the popover to appear? ( |
options |
A named list of additional options to be set on the popover. |
See Tooltips_and_Popovers for more information about how to use popify
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of popify
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsPopover
; bsTooltip
;
removePopover
; removeTooltip
;
tipify
removePopover
is used within the Server logic of an app to remove an
existing popover from a Shiny input or output.
removePopover(session, id)
removePopover(session, id)
session |
The session object passed to function given to shinyServer. |
id |
The id of the element to remove the popover from. |
See Tooltips_and_Popovers for more information about how to use removePopover
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of removePopover
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsPopover
; bsTooltip
;
popify
; removeTooltip
;
tipify
removeTooltip
is used within the Server logic of an app to remove an
existing tooltip from a Shiny input or output.
removeTooltip(session, id)
removeTooltip(session, id)
session |
The session object passed to function given to shinyServer. |
id |
The id of the element to remove the tooltip from. |
See Tooltips_and_Popovers for more information about how to use removeTooltip
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of removeTooltip
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsPopover
; bsTooltip
;
popify
; removePopover
;
tipify
tipify
can be wrapped around any shiny UI element to add a tooltip to the
wrapped element. This should be a safer way to add tooltips to elements created with
renderUI
.
tipify(el, title, placement = "bottom", trigger = "hover", options = NULL)
tipify(el, title, placement = "bottom", trigger = "hover", options = NULL)
el |
A shiny UI element. |
title |
The content of the tooltip. |
placement |
Where the tooltip should appear relative to its target
( |
trigger |
What action should cause the tooltip to appear? ( |
options |
A named list of additional options to be set on the tooltip. |
See Tooltips_and_Popovers for more information about how to use tipify
with the
rest of the Tooltips_and_Popovers family.
Run bsExample("Tooltips_and_Popovers")
for an example
of tipify
functionality.
Other Tooltips_and_Popovers: Tooltips_and_Popovers
;
addPopover
; addTooltip
;
bsPopover
; bsTooltip
;
popify
; removePopover
;
removeTooltip
toggleModal
is used within your Server logic to open or close a modal
window.
toggleModal(session, modalId, toggle = "toggle")
toggleModal(session, modalId, toggle = "toggle")
session |
The session object passed to function given to shinyServer. |
modalId |
The id of the modal window you want to open/close |
toggle |
Should the modal window |
See Modals for more information about how to use toggleModal
with the
rest of the Modals family.
Run bsExample("Modals")
for an example
of toggleModal
functionality.
Tooltips and Popovers allow you to add additional information about controls or outputs without cluttering up your user interface. You can add a tooltip to a button that displays on hover and better explains what the button will do, or you could add a popover to an output providing further analysis of that output.
You can create tooltips and popovers from either the UI script or within the
Server logic. bsTooltip
and bsPopover
are used in
the UI, and addTooltip
and addPopover
are used in
the Server logic. tipify
and popify
can be used
within the UI or from within a renderUI
in the Server logic. They
also have the added advantage of not requiring that the UI element have an ID
attribute.
There are eight functions in the Tooltips and Popovers family:
bsTooltip
Used in the UI to add a tooltip to an element in your UI.
bsPopover
Used in the UI to add a popover to an element in your UI.
tipify
Wrap any UI element in tipify
to add a
tooltip to the wrapped element. Preferred for elemented created with
renderUI
.
popify
Wrap any UI element in popify
to add a
popover to the wrapped element. Preferred for elements created with
renderUI
.
addTooltip
Used in the Server logic to add a tooltip to an element in your UI.
addPopover
Used in the Server logic to add a popover to an element in your UI.
removeTooltip
Used in the Server logic to remove a tooltip from an element in your UI.
removePopover
Used in the Server logic to remove a popover from an element in your UI.
An options
argument has been added to the creation functions to allow
advanced users more control over how the tooltips and popovers appear. See
the Twitter Bootstrap 3 documentation for more
details.
Tooltips and Popovers cannot contain shiny inputs or outputs.
There must be at least one shinyBS
component in the UI of your
app in order for the necessary dependencies to be loaded. Because of this,
addTooltip
and addPopover
will not work if they
are the only shinyBS components in your app.
Tooltips and popovers may not work on some of the more complex shiny inputs or outputs. If you encounter a problem with tooltips or popovers not appearing please file a issue on the github page so I can fix it.
Run bsExample("Tooltips_and_Popovers")
for an example
of Tooltips_and_Popovers
functionality.
Other Tooltips_and_Popovers: addPopover
;
addTooltip
; bsPopover
;
bsTooltip
; popify
;
removePopover
; removeTooltip
;
tipify
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30), bsTooltip("bins", "The wait times will be broken into this many equally spaced bins", "right", options = list(container = "body")) ), mainPanel( plotOutput("distPlot"), uiOutput("uiExample") ) ) ), server = function(input, output, session) { output$distPlot <- renderPlot({ # generate bins based on input$bins from ui.R x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$uiExample <- renderUI({ tags$span( popify(bsButton("pointlessButton", "Button", style = "primary", size = "large"), "A Pointless Button", "This button is <b>pointless</b>. It does not do <em>anything</em>!"), tipify(bsButton("pB2", "Button", style = "inverse", size = "extra-small"), "This button is pointless too!") ) }) addPopover(session, "distPlot", "Data", content = paste0("<p>Waiting time between ", "eruptions and the duration of the eruption for the Old Faithful geyser ", "in Yellowstone National Park, Wyoming, USA.</p><p>Azzalini, A. and ", "Bowman, A. W. (1990). A look at some data on the Old Faithful geyser. ", "Applied Statistics 39, 357-365.</p>"), trigger = 'click') } ) ## Not run: runApp(app) ## End(Not run)
library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30), bsTooltip("bins", "The wait times will be broken into this many equally spaced bins", "right", options = list(container = "body")) ), mainPanel( plotOutput("distPlot"), uiOutput("uiExample") ) ) ), server = function(input, output, session) { output$distPlot <- renderPlot({ # generate bins based on input$bins from ui.R x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$uiExample <- renderUI({ tags$span( popify(bsButton("pointlessButton", "Button", style = "primary", size = "large"), "A Pointless Button", "This button is <b>pointless</b>. It does not do <em>anything</em>!"), tipify(bsButton("pB2", "Button", style = "inverse", size = "extra-small"), "This button is pointless too!") ) }) addPopover(session, "distPlot", "Data", content = paste0("<p>Waiting time between ", "eruptions and the duration of the eruption for the Old Faithful geyser ", "in Yellowstone National Park, Wyoming, USA.</p><p>Azzalini, A. and ", "Bowman, A. W. (1990). A look at some data on the Old Faithful geyser. ", "Applied Statistics 39, 357-365.</p>"), trigger = 'click') } ) ## Not run: runApp(app) ## End(Not run)
updateButton
is used in your Server logic to update the style or state
of a button.
updateButton(session, inputId, label = NULL, icon = NULL, value = NULL, style = NULL, size = NULL, block = NULL, disabled = NULL)
updateButton(session, inputId, label = NULL, icon = NULL, value = NULL, style = NULL, size = NULL, block = NULL, disabled = NULL)
session |
The session object passed to function given to shinyServer. |
inputId |
Specifies the input slot that will be used to access the value. |
label |
The contents of the button or link–usually a text label, but you could also use any other HTML, like an image. |
icon |
An optional |
value |
logical If |
style |
A Bootstrap style to apply to the button. ( |
size |
The size of the button ( |
block |
logical Should the button take the full width of the parent element? |
disabled |
logical Should the button be disabled (un-clickable)? |
Because of the way it is coded, updateButton
may work on buttons not
created by bsButton
such as submitButton
.
See Buttons
for more information about how to use updateButton
with the rest of the Buttons family.
Run bsExample("Buttons")
for an example
of updateButton
functionality.
Other Buttons: Buttons
;
bsButton
updateCollapse
is used within the Server logic of your Shiny app to
modify a Collapse after load.
updateCollapse(session, id, open = NULL, close = NULL, style = NULL)
updateCollapse(session, id, open = NULL, close = NULL, style = NULL)
session |
The session object passed to function given to shinyServer. |
id |
The id of the Collapse object you want to change. |
open |
A vector of |
close |
A vector of |
style |
A named list of Bootstrap styles ( |
See Collapses for more information about how to use updateCollapse
with the
rest of the Collapses family.
Run bsExample("Collapses")
for an example
of updateCollapse
functionality.
Other Collapses: Collapses
;
bsCollapsePanel
; bsCollapse
updateTypeahead
Update a typeaheadInput buttons.
updateTypeahead(session, inputId, label = NULL, value = NULL, choices = NULL)
updateTypeahead(session, inputId, label = NULL, value = NULL, choices = NULL)
session |
The session object passed to function given to shinyServer. |
inputId |
Input variable to assign the control's value to |
label |
Display label for the control |
value |
Initial value |
choices |
Array of strings to match against. Can also be JavaScript function. Use htmlwidgets::JS() to indicate JavaScript. |
typeaheadInput