| Title: | Compact Inline Widgets for 'shiny' Apps |
|---|---|
| Description: | Provides a basic set of compact widgets for 'shiny' apps which occupy less space and can appear inline with surrounding text. |
| Authors: | Nick Davies [aut, cre] |
| Maintainer: | Nick Davies <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.4.9000 |
| Built: | 2026-05-30 09:32:15 UTC |
| Source: | https://github.com/nicholasdavies/inshiny |
Wrapper for a line (or paragraph) containing a mix of explanatory text and inshiny inline widgets.
inline(..., class = "mb-1")inline(..., class = "mb-1")
... |
Unnamed arguments: Inline widgets (such as |
class |
Extra classes to apply to the line. The default, |
An HTML element to be included in your Shiny UI definition.
Inline widgets from inshiny are typically displayed with borders around them
to show that they are editable. For the borders to display correctly, inshiny
includes some custom CSS to make sure the borders work inside common
bslib containers such as bslib::card and
bslib::accordion_panel. However, if you place inline widgets inside a
custom container that has its own opaque background (e.g. a div with
background-color set), the border around widgets may disappear. To fix
this, add the CSS class "inshiny-bg" to the container:
tags$div(class = "inshiny-bg", style = "background-color: white;",
inline("Enter a value: ", inline_text("val", "hello"))
)
ui <- bslib::page_fixed( shiny::h1("Hello!"), inline("My name is ", inline_text("myname", "Sisyphus"), "."), inline("Please enter your name carefully.", style = "font-weight:bold") )ui <- bslib::page_fixed( shiny::h1("Hello!"), inline("My name is ", inline_text("myname", "Sisyphus"), "."), inline("Please enter your name carefully.", style = "font-weight:bold") )
A button widget similar to shiny::actionButton() that can be included in an
inline() wrapper.
inline_button(id, label, icon = NULL, meaning = label, accent = NULL)inline_button(id, label, icon = NULL, meaning = label, accent = NULL)
id |
The |
label |
The text appearing within the button. This can be a character
string or any other HTML, or |
icon |
An optional |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
accent |
A Bootstrap "accent" (such as |
An inline widget to be included in an inline() wrapper.
shiny::actionButton for how the button works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("A wonderful button"), inline("To update, please feel free to press the ", inline_button("mybutton", label = shiny::span(style = "font-style:italic", "button"), icon = shiny::icon("play"), meaning = "Update button", accent = "success"), "." ) )ui <- bslib::page_fixed( shiny::h1("A wonderful button"), inline("To update, please feel free to press the ", inline_button("mybutton", label = shiny::span(style = "font-style:italic", "button"), icon = shiny::icon("play"), meaning = "Update button", accent = "success"), "." ) )
A date input with a calendar pop-up similar to shiny::dateInput() that
can be included in an inline() wrapper.
inline_date( id, value = NULL, min = NULL, max = NULL, placeholder = "Enter date", meaning = NULL, max_width = "10em", format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en", autoclose = TRUE, datesdisabled = NULL, daysofweekdisabled = NULL )inline_date( id, value = NULL, min = NULL, max = NULL, placeholder = "Enter date", meaning = NULL, max_width = "10em", format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en", autoclose = TRUE, datesdisabled = NULL, daysofweekdisabled = NULL )
id |
The |
value |
The initially selected date. Either a Date object; a
character string in |
min, max
|
The minimum and maximum allowed date. Either a Date object,
a character string in |
placeholder |
The character string or HTML element that will appear in the textbox when it is empty, as a prompt. |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
max_width |
The maximum width of the text input as a CSS length
(e.g. |
format |
The format of the date to display in the browser; defaults to
"yyyy-mm-dd". Note that this is only for display purposes. Changing the
display format does not allow you to specify |
startview |
The view shown when the textbox is first clicked. Can be
|
weekstart |
Which day is the start of the week; an integer from 0 (Sunday) to 6 (Saturday). |
language |
The language used for month and day names, with |
autoclose |
Whether to close the calendar once a date has been selected. |
datesdisabled |
Dates that should be disabled (a character or Date
vector). Strings should be in the |
daysofweekdisabled |
Days of the week that should be disabled; an integer vector in which 0 is Sunday, and 6 is Saturday. |
An inline widget to be included in an inline() wrapper.
shiny::dateInput for how the date input works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Select a date"), inline("Run simulation starting on ", inline_date("start_date", NULL, meaning = "Simulation start date", format = "dd/mm/yyyy", daysofweekdisabled = c(0, 6)), " (weekdays only)." ) )ui <- bslib::page_fixed( shiny::h1("Select a date"), inline("Run simulation starting on ", inline_date("start_date", NULL, meaning = "Simulation start date", format = "dd/mm/yyyy", daysofweekdisabled = c(0, 6)), " (weekdays only)." ) )
A link widget similar to shiny::actionLink() that can be included in an
inline() wrapper.
inline_link(id, label, icon = NULL, meaning = label, accent = NULL)inline_link(id, label, icon = NULL, meaning = label, accent = NULL)
id |
The |
label |
The text appearing within the link. This can be a character
string or any other HTML, or |
icon |
An optional |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
accent |
A Bootstrap "accent" (such as |
An inline widget to be included in an inline() wrapper.
shiny::actionLink for how the link works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Link examples"), inline("These are ", inline_link("link1", "some"), " ", inline_link("link2", "increasingly", accent = "danger"), " ", inline_link("link3", "fancy", accent = c("success", "underline-warning", "offset-2")), " ", inline_link("link4", "links", icon = shiny::icon("link"), accent = "info"), "!") )ui <- bslib::page_fixed( shiny::h1("Link examples"), inline("These are ", inline_link("link1", "some"), " ", inline_link("link2", "increasingly", accent = "danger"), " ", inline_link("link3", "fancy", accent = c("success", "underline-warning", "offset-2")), " ", inline_link("link4", "links", icon = shiny::icon("link"), accent = "info"), "!") )
A single line numeric input similar to shiny::numericInput() that can be
included in an inline() wrapper.
inline_number( id, value, min = NULL, max = NULL, step = NULL, default = value, placeholder = "Enter number", meaning = NULL, max_width = "10em", arrows = TRUE )inline_number( id, value, min = NULL, max = NULL, step = NULL, default = value, placeholder = "Enter number", meaning = NULL, max_width = "10em", arrows = TRUE )
id |
The |
value |
The initial number. |
min, max
|
Minimum and maximum values. Use |
step |
A step value for incrementing and decrementing the number using the up or down arrow keys or with the clickable arrows on the widget. The Page Up and Page Down keys increment or decrement the number by 10 steps, and the Home and End keys set the number to the minimum or maximum respectively. The default step is 1. |
default |
A default value to be used if the input is invalid or empty. |
placeholder |
The character string or HTML element that will appear in the textbox when it is empty, as a prompt. |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
max_width |
The maximum width of the text input as a CSS length
(e.g. |
arrows |
Whether to show clickable arrows that can be used to adjust the number up or down. |
An inline widget to be included in an inline() wrapper.
shiny::numericInput for how the number input works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Breakfast app (beta)"), inline("Make me an omelette with ", inline_number("eggs", 6, min = 2, max = 12, step = 1, placeholder = "6 (default)", meaning = "Number of eggs"), " eggs.") )ui <- bslib::page_fixed( shiny::h1("Breakfast app (beta)"), inline("Make me an omelette with ", inline_number("eggs", 6, min = 2, max = 12, step = 1, placeholder = "6 (default)", meaning = "Number of eggs"), " eggs.") )
A select list input similar to shiny::selectInput() that can be
included in an inline() wrapper.
inline_select( id, choices, selected = NULL, multiple = FALSE, meaning = NULL, max_width = "10em" )inline_select( id, choices, selected = NULL, multiple = FALSE, meaning = NULL, max_width = "10em" )
id |
The |
choices |
Vector or list of values to select from. Provide one of the following:
|
selected |
The initially selected option's value. If |
multiple |
Whether to allow multiple selections. As of inshiny version
0.1.0, the version of inline_select with |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
max_width |
The maximum width of the text input as a CSS length
(e.g. |
An inline widget to be included in an inline() wrapper.
shiny::selectInput for how the select input works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Pet registration form"), inline("My ", inline_select("species", c("dog", "cat"), meaning = "Pet species"), "'s name is ", inline_select("name", list("Dog names" = c("Fido", "Rex"), "Cat names" = c("Felix", "Boots")), selected = "Rex"), ".") )ui <- bslib::page_fixed( shiny::h1("Pet registration form"), inline("My ", inline_select("species", c("dog", "cat"), meaning = "Pet species"), "'s name is ", inline_select("name", list("Dog names" = c("Fido", "Rex"), "Cat names" = c("Felix", "Boots")), selected = "Rex"), ".") )
A numeric input with a slider pop-up similar to shiny::sliderInput() that
can be included in an inline() wrapper.
inline_slider( id, value, min, max, step = NULL, default = value, placeholder = "Enter number", meaning = NULL, max_width = "10em" )inline_slider( id, value, min, max, step = NULL, default = value, placeholder = "Enter number", meaning = NULL, max_width = "10em" )
id |
The |
value |
The initial number. |
min, max
|
Minimum and maximum values. Both are required. |
step |
A step value that the slider will use to jump between values between min and max. |
default |
A default value to be used if the input is invalid or empty. |
placeholder |
The character string or HTML element that will appear in the textbox when it is empty, as a prompt. |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
max_width |
The maximum width of the text input as a CSS length
(e.g. |
An inline widget to be included in an inline() wrapper.
shiny::sliderInput for how the slider input works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Pep talk"), inline("When you go out there tonight, give ", inline_slider("amount", 10, 0, 110, step = 1, default = 50, placeholder = "Enter a percentage.", meaning = "Percent to give"), "%.") )ui <- bslib::page_fixed( shiny::h1("Pep talk"), inline("When you go out there tonight, give ", inline_slider("amount", 10, 0, 110, step = 1, default = 50, placeholder = "Enter a percentage.", meaning = "Percent to give"), "%.") )
An on/off switch widget similar to bslib::input_switch() that can be
included in an inline() wrapper.
inline_switch(id, value, on = "On", off = "Off", meaning = NULL)inline_switch(id, value, on = "On", off = "Off", meaning = NULL)
id |
The |
value |
Whether the switch is initially off or on; |
on, off
|
Labels that will appear to the right of the switch when the
switch is on or off, respectively. These can be character strings or
HTML elements. For example, you can style these with a
span and apply one of the
Bootstrap 5 text color classes
(see examples). |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
An inline widget to be included in an inline() wrapper.
bslib::input_switch for how the switch works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Switch test"), inline("The server is now ", inline_switch("myswitch", TRUE, on = shiny::span(class = "text-success", "powered ON"), off = shiny::span(class = "text-danger", "powered OFF"), meaning = "Server power switch"), "." ) )ui <- bslib::page_fixed( shiny::h1("Switch test"), inline("The server is now ", inline_switch("myswitch", TRUE, on = shiny::span(class = "text-success", "powered ON"), off = shiny::span(class = "text-danger", "powered OFF"), meaning = "Server power switch"), "." ) )
A single line text input similar to shiny::textInput() that can be
included in an inline() wrapper.
inline_text( id, value = "", placeholder = "Enter text", meaning = NULL, max_width = "10em" )inline_text( id, value = "", placeholder = "Enter text", meaning = NULL, max_width = "10em" )
id |
The |
value |
The initial text contents (a character string). |
placeholder |
The character string or HTML element that will appear in the textbox when it is empty, as a prompt. |
meaning |
A descriptive label, for people using assistive technology such as screen readers. |
max_width |
The maximum width of the text input as a CSS length
(e.g. |
An inline widget to be included in an inline() wrapper.
shiny::textInput for how the text input works with your Shiny server.
ui <- bslib::page_fixed( shiny::h1("Hello!"), inline("My name is ", inline_text("myname", "Sisyphus", placeholder = "Enter your name", meaning = "Your name"), ".") )ui <- bslib::page_fixed( shiny::h1("Hello!"), inline("My name is ", inline_text("myname", "Sisyphus", placeholder = "Enter your name", meaning = "Your name"), ".") )
Use this in your server code to change the parameters of an existing
inline widget. Most, but not all, parameters from the corresponding
inline_* functions can be changed. Note that while Shiny has a separate
update function for each type of widget (e.g. shiny::updateTextInput for
shiny::textInput, etc.), the inshiny package has this single function to
update all types of inline widgets. This function can only be called in a
reactive context, and can only be called on inline_* widgets, not on
"built-in" Shiny widgets.
update_inline( id, session = shiny::getDefaultReactiveDomain(), value, placeholder, meaning, label, icon, accent, min, max, step, default, on, off, datesdisabled, daysofweekdisabled, choices, selected )update_inline( id, session = shiny::getDefaultReactiveDomain(), value, placeholder, meaning, label, icon, accent, min, max, step, default, on, off, datesdisabled, daysofweekdisabled, choices, selected )
id |
The |
session |
The currently active Shiny session. In almost all cases you can leave this to its default value. |
value |
(date, number, select, slider, switch, text) The current value of the widget. |
placeholder |
(date, number, slider, text) The character string or HTML element that will appear when the widget's textbox is empty, as a prompt. |
meaning |
(all widgets) The descriptive label for people using assistive technology such as screen readers. |
label, icon
|
(button, link) The label and icon that appear in the button or link. |
accent |
(button, link) The Boostrap accent to apply to the button or link. |
min, max
|
(date, number, slider) The minimum and maximum allowable value. |
step |
(number, slider) The increment or decrement by which to change the value. |
default |
(number, slider) The default value to assume when the input is blank or invalid. |
on, off
|
(switch) Labels to use for when the switch is on or off. |
datesdisabled, daysofweekdisabled
|
(date) Dates to make unselectable. |
choices, selected
|
(select) Options to choose from and current selection. |
See the documentation for each inline widget for details of how each parameter is interpreted.
When adjusting min, max, datesdisabled, or daysofweekdisabled, it
is recommended that you also send an update to value with the current
value of input[[id]] or any new value as applicable. This will ensure that
any invalid value gets highlighted in the app as invalid after accounting
for the new bounds and disallowed values.
Nothing.
# Example UI setup ui <- bslib::page_fixed( inline( inline_button("mybutton", "Button"), inline_date("mydate"), inline_link("mylink", "Link"), inline_number("mynumber", 42), inline_select("myselect", letters), inline_slider("myslider", 42, 0, 100), inline_switch("myswitch", TRUE), inline_text("mytext") ) ) # This covers all updatable attributes except `meaning` (all widgets) and # `placeholder` (date, number, slider, text). server <- function(input, output) { update_inline("mybutton", label = "Click me", icon = shiny::icon("recycle"), accent = "info") update_inline("mydate", value = "2026-01-01", min = "2025-01-01", max = "2026-12-31", datesdisabled = "2025-12-25", daysofweekdisabled = c(0, 6)) update_inline("mylink", label = "Click me", icon = shiny::icon("recycle"), accent = "info") update_inline("mynumber", value = 25, min = 20, max = 50, step = 5, default = 25) update_inline("myselect", choices = letters[1:5], selected = "c") update_inline("myslider", value = 25, min = 20, max = 50, step = 5, default = 25) update_inline("myswitch", value = TRUE, on = "Present", off = "Absent") update_inline("mytext", value = "Howdy") }# Example UI setup ui <- bslib::page_fixed( inline( inline_button("mybutton", "Button"), inline_date("mydate"), inline_link("mylink", "Link"), inline_number("mynumber", 42), inline_select("myselect", letters), inline_slider("myslider", 42, 0, 100), inline_switch("myswitch", TRUE), inline_text("mytext") ) ) # This covers all updatable attributes except `meaning` (all widgets) and # `placeholder` (date, number, slider, text). server <- function(input, output) { update_inline("mybutton", label = "Click me", icon = shiny::icon("recycle"), accent = "info") update_inline("mydate", value = "2026-01-01", min = "2025-01-01", max = "2026-12-31", datesdisabled = "2025-12-25", daysofweekdisabled = c(0, 6)) update_inline("mylink", label = "Click me", icon = shiny::icon("recycle"), accent = "info") update_inline("mynumber", value = 25, min = 20, max = 50, step = 5, default = 25) update_inline("myselect", choices = letters[1:5], selected = "c") update_inline("myslider", value = 25, min = 20, max = 50, step = 5, default = 25) update_inline("myswitch", value = TRUE, on = "Present", off = "Absent") update_inline("mytext", value = "Howdy") }
For inshiny to work, you need to link your Shiny app to inshiny's JavaScript
code and CSS stylesheets. If you use inshiny's function inline() anywhere
in your Shiny UI definition, which you probably do, this happens
automatically. Otherwise, you can add a call to use_inshiny() to your UI.
use_inshiny()use_inshiny()
An htmltools::htmlDependency() object to include in your UI.
ui <- bslib::page( use_inshiny(), shiny::h1("My slider app"), inline_slider("slider", 50, 0, 100) )ui <- bslib::page( use_inshiny(), shiny::h1("My slider app"), inline_slider("slider", 50, 0, 100) )