Package 'tabler'

Title: Create Dashboards with 'Tabler'
Description: Provides functions to build interactive dashboards using the 'Tabler', making it easy to create professional-looking web applications. 'Tabler' is fully responsive and compatible with all modern browsers. Offers customizable layouts and components built with 'HTML5' and 'CSS3'. The underlying 'Tabler' (<https://github.com/tabler/tabler>) and 'Tabler Icons' (<https://github.com/tabler/tabler-icons>) were pre-built from source to eliminate the need for 'Node.js' and 'NPM' on package installation.
Authors: Mauricio Vargas Sepulveda [aut, cre], Tabler [ctb, cph] (Tabler Dashboard)
Maintainer: Mauricio Vargas Sepulveda <[email protected]>
License: Apache License (>= 2)
Version: 1.4.0
Built: 2026-07-15 20:44:32 UTC
Source: https://github.com/pachadotdev/tabler

Help Index


Register a Directory of Static Resources

Description

Serves files under directoryPath at URLs beginning with /prefix/, mirroring shiny::addResourcePath(). Use this to serve an app's own CSS/JS/image assets (e.g. from inst/app/www) without depending on shiny or golem.

Usage

addResourcePath(prefix, directoryPath)

Arguments

prefix

The URL prefix (e.g. "www" serves files at /www/...).

directoryPath

Absolute path to the directory to serve.

Value

Invisibly, NULL.


Bootstrap Grid Column

Description

Wraps content in a Bootstrap column of the given width.

Build a modern card component with optional header, body, and footer

Small helper to render the page pretitle element used by Tabler examples

Small helper to render the page title element used by Tabler examples

Create a standalone page header with optional pretitle and action buttons

Create the full page body structure with optional header

Display a key metric or value prominently

Display an icon from Tabler Icons or other icon libraries

Display important messages to users

Create interactive buttons with Tabler styling

Usage

column(width, ..., class = NULL)

card(..., title = NULL, footer = NULL, status = NULL, class = NULL)

pre_title(text)

title(text)

header(title, subtitle = NULL, header_actions = NULL)

body(..., title = NULL, subtitle = NULL, header_actions = NULL)

value_box(value, title, icon = NULL, color = "primary", width = 3)

icon(name, library = "tabler", class = NULL)

alert(..., type = "info", dismissible = FALSE, title = NULL)

button(
  label,
  href = NULL,
  onclick = NULL,
  color = "primary",
  size = "md",
  outline = FALSE,
  icon = NULL,
  icon_right = FALSE,
  disabled = FALSE,
  block = FALSE,
  pill = FALSE,
  square = FALSE,
  loading = FALSE,
  class = NULL,
  type = "button",
  ...
)

Arguments

width

Column width (1-12)

...

Additional HTML attributes

class

Additional CSS classes

title

Alert title (optional)

footer

Card footer content (optional)

status

Card color status: "primary", "secondary", "success", "warning", "danger", etc.

text

The title text to display

subtitle

The page pretitle text (optional)

header_actions

Additional elements to include in the header (e.g., action buttons)

value

Main value to display

icon

Icon to include

color

Button color theme

name

Icon name

library

Icon library: "tabler", "bootstrap", "feather"

type

HTML button type attribute

dismissible

Whether alert can be dismissed

label

Button text

href

URL to link to (creates an anchor tag instead of button)

onclick

JavaScript to execute on click

size

Button size: "sm", "md", "lg"

outline

Use outline style

icon_right

Position icon on the right side

disabled

Whether the button is disabled

block

Make button full-width (block-level)

pill

Use pill-shaped button style

square

Use square button style

loading

Show loading spinner

Value

An HTML tag.

An HTML tag representing the card

An HTML tag representing the value box

An HTML tag representing the icon

An HTML tag representing the alert

An HTML tag representing the button


The Currently Running tablerApp Session

Description

Returns the session object of the tablerApp server function currently executing, or NULL if none is running. Used as the default session argument of moduleServer.

Usage

getDefaultReactiveDomain()

Value

A tablerApp session object, or NULL.


Initialize a Tag as Hidden

Description

Create a tag (or tag list) that is invisible when the page first loads. It can be made visible later with toggle or show.

Usage

hidden(...)

Arguments

...

Tag (or tagList or list of tags) to make invisible.

Value

The tag (or tags) that were given as an argument, in a hidden state.

See Also

show, hide, toggle

Examples

if (interactive()) {
  ui <- page(
    title = "Hidden Example",
    body = body(
      actionButton("btn", "Click me"),
      hidden(
        p(id = "element", "I was born invisible")
      )
    )
  )

  server <- function(input, output, session) {
    observeEvent(input$btn, {
      show(session, "element")
    })
  }

  tablerApp(ui, server)
}

Mark a String as Raw HTML (Do Not Escape)

Description

Mark a String as Raw HTML (Do Not Escape)

Usage

HTML(text)

Arguments

text

Character string of literal HTML.

Value

An object of class "tabler.html".


HTML Tag Builder Functions

Description

Convenience functions for building common HTML elements. Each function accepts child content and named attributes as ... arguments and returns a tabler.tag object that can be nested, rendered with as.character(), or passed to any tabler layout function.

Usage

div(...)

span(...)

p(...)

a(...)

img(...)

ul(...)

li(...)

aside(...)

h1(...)

h2(...)

h3(...)

h4(...)

h5(...)

h6(...)

br(...)

Arguments

...

Child elements (strings, other tags) and/or named HTML attributes (e.g. class = "foo", href = "#").

Value

A tabler.tag object.

See Also

tags for the full HTML5 tag namespace.


Tabler Icons Data

Description

A dataset containing Tabler icon names and their categories.

Usage

icons

Format

A data frame with 6,019 rows and 3 variables:

root

The root category of the icon (e.g., "arrow/arrows", "brand", "device", etc.)

icon

The full icon name (e.g., "arrow-up", "arrow-down", "circle-arrow-up", "circle-arrow-up-filled", etc.)

filled

Logical indicating whether the icon is a filled or not.

Source

Derived from the icons from https://github.com/tabler/tabler-icons

Examples

icons[grepl("paw", icons$icon), ]

Create a Namespaced Module Server

Description

Dependency-free equivalent of shiny::moduleServer(). Wraps input/output so that unprefixed names accessed inside module are automatically namespaced with id, matching the ids produced by NS(id) in the module's UI function.

Usage

moduleServer(id, module, session = getDefaultReactiveDomain())

Arguments

id

The module's namespace id (must match the id used to call the module's *_ui function).

module

A function with signature function(input, output, session).

session

The parent session object. Defaults to the currently running tablerApp session (see getDefaultReactiveDomain).

Value

The return value of module, invisibly.


Namespace an Id

Description

Prefixes an id with a namespace, mirroring the id-prefixing behaviour of shiny::NS() without depending on shiny or its module system.

Usage

NS(namespace, id = NULL)

Arguments

namespace

Namespace prefix.

id

Id to namespace. If missing, returns a function that namespaces any id it is given (as shiny::NS() does).

Value

If id is given, a namespaced id (character string). Otherwise, a function that namespaces any id passed to it.

Examples

ns <- NS("mymodule")
ns("button") # "mymodule-button"
NS("mymodule", "button") # "mymodule-button"

Create a Tabler Dashboard Page

Description

Main function to create a complete dashboard page with Tabler theme

Helper to create a top navigation header. This replaces the previous top-navbar behavior when users passed a header-like component.

Footer for the dashboard

Container for navigation items in sidebar

Container for navigation items in horizontal layout

Individual navigation item for sidebar

Container for multiple tab panels in tabbed layouts

Individual tab panel content

Usage

page(
  title = NULL,
  navbar = NULL,
  body = NULL,
  footer = NULL,
  layout = "boxed",
  theme = "light",
  color = "blue",
  show_theme_button = FALSE
)

topbar(title = NULL, brand_image = NULL, ...)

footer(left = NULL, right = NULL)

sidebar_menu(..., title = NULL)

horizontal_menu(...)

menu_item(text, tab_name = NULL, icon = NULL, href = NULL, badge = NULL)

tab_items(...)

tab_item(tab_name, ...)

Arguments

title

Optional brand for the sidebar; either a string (text title) or a named list with elements 'text' and 'img' (URL/path) to render a brand image and title. Example: 'title = list(text = "My App", img = "logo.png")'.

navbar

Dashboard navbar/menu. Can be: - 'sidebar_menu()' for a vertical sidebar - 'horizontal_menu()' for a horizontal menu

body

Dashboard body content

footer

Dashboard footer (optional)

layout

Layout type: "boxed" (default), "combo", "condensed", "fluid", "fluid-vertical", "horizontal", "navbar", "navbar-dark", "navbar-overlap", "navbar-sticky", "navbar-sticky-dark", "rtl", "vertical", "vertical-right", "vertical-transparent"

theme

Default theme: "light" (default) or "dark".

color

Color theme (optional): "blue" (default), "azure", "indigo", "purple", "pink", "red", "orange", "yellow", "lime", "green", "teal", "cyan".

show_theme_button

Whether to show the theme toggle buttons (default: 'FALSE').

brand_image

URL or path to brand image

...

Content for this tab

left

Left-aligned content

right

Right-aligned content

text

Item text/label

tab_name

Unique identifier for the tab (must match menuItem tab_name)

icon

Icon name (optional)

href

Link URL (optional, alternative to tab_name)

badge

Badge text (optional)

Value

HTML tag with dependencies attached

An HTML tag representing the top header

An HTML tag representing the footer

An HTML tag representing the sidebar menu

An HTML tag representing the horizontal menu

An HTML tag representing the menu item

An HTML tag representing the tab items container

An HTML tag representing the tab item

Examples

ui <- page(
  title = "Combo Dashboard",
  layout = "combo",
  navbar = list(
    top = topbar(title = "My App"),
    side = sidebar_menu(
      menu_item("Dogs", icon = "dog"),
      menu_item("Cats", icon = "cat")
    )
  ),
  body = body("Welcome to Tabler!")
)

server <- function(input, output, session) {}

# tablerApp(ui, server)

Reactive Value

Description

A single mutable reactive value. Call with no argument to read (tracks the caller as a dependent); call with one argument to write (invalidates all current dependents).

A named collection of reactive values similar to a reactive list. Access with rv$name (reactive read) or rv$name <- val (reactive write).

Returns a plain list snapshot of a reactiveValues object's current values, establishing a reactive read dependency on each contained value, similar to shiny::reactiveValuesToList().

A lazy, cached computation that re-evaluates only when its reactive dependencies are invalidated.

Stops execution of the current reactive expression, observer, or render function if any argument is not "truthy" (i.e. is NULL, NA, FALSE, an empty string, or an empty vector), similar to shiny::req(). Unlike a normal error, this stop is silent: an observe()/observeEvent() block simply does nothing for this run, and a render function (renderUI, renderText, ...) simply leaves its output unchanged, instead of showing an error.

Any reactive reads inside expr are not registered as dependencies of the current context.

Eagerly re-runs expr whenever its reactive dependencies change.

Runs handlerExpr whenever eventExpr changes.

A reactive expression that recomputes valueExpr only when eventExpr changes, similar to shiny::eventReactive().

Modifies a reactive expression created by reactive so that it only (re)executes when the given event expression(s) change, similar to shiny::bindEvent(). Typically used with the pipe: reactive({...}) |> bindEvent(input$go).

Configure package-wide options for tabler. Currently this only sets the cache backend used by bindCache, mirroring shiny::shinyOptions(cache = ...).

Persistently caches a reactive expression's value, keyed by one or more key expressions, similar to shiny::bindCache(). Unlike reactive's built-in caching (in-memory, lost as soon as its dependencies change), bindCache() stores values in the cache backend configured via tablerOptions (e.g. cachem::cache_disk()), so identical key combinations are served instantly - even across app restarts or different sessions - without re-running x. Typically used with the pipe: reactive({...}) |> bindCache(key1, key2) |> bindEvent(input$go).

Call once inside the server function to enable two-way URL parameter synchronisation: the URL query string initialises inputs on page load, and every subsequent input change updates the URL in-place (no page reload, no browser-history spam).

Usage

reactiveVal(value = NULL)

reactiveValues(...)

reactiveValuesToList(x, all.names = FALSE)

reactive(expr)

req(..., cancelOutput = FALSE)

isolate(expr)

observe(expr)

observeEvent(eventExpr, handlerExpr, ignoreInit = TRUE)

eventReactive(eventExpr, valueExpr, ignoreNULL = TRUE, ignoreInit = TRUE)

bindEvent(x, ..., ignoreNULL = TRUE, ignoreInit = TRUE)

tablerOptions(cache)

bindCache(x, ...)

syncUrl(session, exclude = character(0L))

Arguments

value

Initial value.

...

One or more (unevaluated) key expressions. Whenever their combined value changes, x is (re)computed and the result is cached; otherwise the previously cached value is returned directly, without calling x again.

x

A reactive expression created by reactive.

all.names

Include names starting with a dot (default FALSE).

expr

Expression with side effects.

cancelOutput

Ignored (kept for signature compatibility with Shiny).

eventExpr

Reactive expression whose change triggers re-evaluation.

handlerExpr

Expression to run when the event fires.

ignoreInit

If TRUE (default), x is not computed until an event expression first changes (e.g. an actionButton's click counter starts at 0, not NULL, so without this, x would compute once immediately on creation, before any click).

valueExpr

Expression to evaluate (and cache) when the event fires.

ignoreNULL

If TRUE (default), do not (re)compute while all event expressions evaluate to NULL.

cache

A cachem cache object (e.g. cachem::cache_disk(dir = "/path/to/cache") or cachem::cache_mem()) used to store bindCache values. If never set, an in-memory cachem::cache_mem() is created and used automatically - which (like a plain reactive) does not survive an R restart. Pass a cache_disk() object to persist values across app restarts and sessions.

session

The session object passed by tablerApp to the server function.

exclude

Character vector of input IDs to omit from the URL. Action buttons are always omitted regardless of this setting.

Details

The resulting URL is clean and quote-free, e.g.

http://localhost:3000/?dataset=mtcars&n_rows=10&stat=mean

Sharing or bookmarking that URL restores the exact input state.

Value

A function that acts as getter/setter.

An environment of class "ReactiveValues".

A named list.

A zero-argument function returning the cached value.

The last argument, invisibly, if all checks pass.

The result of expr.

An invisible observer handle with $suspend() / $resume().

A zero-argument function returning the cached value.

A new zero-argument function returning the cached value.

Invisibly, the previous options (as a named list, for restoring later).

A new zero-argument function returning the (possibly cached) value.

Invisibly, session (for chaining).


Select Input

Description

A dropdown that lets the user pick one item from a list.

A horizontal range slider. When value has length 2, two thumbs are rendered (a "from"/"to" range slider) and the server receives a length-2 numeric vector, e.g. c(2018, 2022).

Change the choices and/or selected value of a selectInput already displayed in the browser, without a full page reload, similar to shiny::updateSelectInput().

Change the value/min/max/step of a sliderInput already displayed in the browser, similar to shiny::updateSliderInput().

A single-line text field.

A numeric input field.

A boolean on/off checkbox.

A clickable button. Its value in input is an integer that increments by one on each click (starts at 0).

A set of checkboxes for selecting multiple values.

A group of mutually-exclusive radio buttons.

Usage

selectInput(inputId, label, choices, selected = NULL, ...)

sliderInput(inputId, label, min, max, value, step = 1, ...)

updateSelectInput(
  session,
  inputId,
  label = NULL,
  choices = NULL,
  selected = NULL,
  ...
)

updateSelectizeInput(
  session,
  inputId,
  label = NULL,
  choices = NULL,
  selected = NULL,
  ...
)

updateSliderInput(
  session,
  inputId,
  label = NULL,
  value = NULL,
  min = NULL,
  max = NULL,
  step = NULL
)

textInput(inputId, label, value = "", placeholder = NULL, ...)

numericInput(inputId, label, value, min = NULL, max = NULL, step = 1, ...)

checkboxInput(inputId, label, value = FALSE, ...)

actionButton(inputId, label, class = "btn-primary", icon = NULL, ...)

checkboxGroupInput(inputId, label, choices, selected = NULL)

radioButtons(inputId, label, choices, selected = NULL)

Arguments

inputId

The input identifier.

label

Display label.

choices

Named or unnamed character vector of choices.

selected

Initially-selected value (defaults to first choice).

...

Additional HTML attributes.

min

Minimum (optional).

max

Maximum (optional).

value

Initial checked state (FALSE).

step

Step size (default 1).

session

The session object.

placeholder

Placeholder text.

class

Additional CSS classes (default "btn-primary").

icon

Optional icon name to prepend.

Value

An HTML tag.

An HTML tag.

Invisibly, NULL.

Invisibly, NULL.

An HTML tag.

An HTML tag.

An HTML tag.

An HTML tag.

An HTML tag.

An HTML tag.


Show/Hide a Full-Page Progress Overlay

Description

Displays (or hides) a full-page loading overlay with an animated progress bar in a running tablerApp. Useful for indicating that a long-running computation (e.g. a database query) is in progress.

Usage

showProgress(session = getDefaultReactiveDomain(), text = "Loading...")

hideProgress(session = getDefaultReactiveDomain())

Arguments

session

The session object passed by tablerApp to the server function. Defaults to getDefaultReactiveDomain().

text

The message displayed above the progress bar.

Details

This is a dependency-free replacement for ad-hoc waiter/custom JS overlay setups. It works the same way as show/hide: the server sends a small message over the WebSocket connection and the browser-side JS (tabler-progress.js) creates/reveals or hides the overlay.

tablerApp's event loop only writes queued WebSocket messages to the socket in between iterations of its repeat { httpuv::service(); ... } loop. If showProgress() is immediately followed by a long, blocking computation in the same observer, the "show" message sits in the queue - never reaching the browser - until that observer (and thus the slow computation) finishes, making the overlay flash on right at the end instead of before the work starts. Calling httpuv::service() again from inside the observer to force an early flush is unsafe here: it re-enters httpuv's event loop while it is still dispatching the current WebSocket message, which can cause that message (and the input it carries) to be processed more than once. Use withProgress instead, which defers the slow computation with later::later() so control returns to the event loop (flushing the "show" message) before the work actually runs.

Value

Invisibly, NULL.

See Also

tablerApp, withProgress

Examples

if (interactive()) {
  ui <- page(
    title = "Progress Example",
    body = body(actionButton("btn", "Load data"))
  )

  server <- function(input, output, session) {
    observeEvent(input$btn, {
      withProgress(session, "Loading data...", {
        Sys.sleep(2)
      })
    })
  }

  tablerApp(ui, server)
}

Run a Tabler Application

Description

Launches a self-contained web application using httpuv for HTTP and WebSocket transport.

Usage

tablerApp(
  ui,
  server,
  host = "127.0.0.1",
  port = 3000L,
  launch.browser = interactive()
)

Arguments

ui

The UI definition — typically a call to page().

server

A function with signature function(input, output, session).

host

Host to listen on (default "127.0.0.1").

port

Port number (default 3000L).

launch.browser

Open a browser automatically when in an interactive session.

Details

Protocol

The browser and server exchange plain JSON messages over a WebSocket at /ws:

  • Browser → R: {"type":"input","name":"<id>","value":<v>}

  • R → Browser: {"type":"output","id":"<id>","html":"<escaped HTML>"}

Reactive system

Uses tabler's own dependency-tracking reactive system (see reactive, observe, reactiveVal, observeEvent). Render functions (renderText, renderUI, renderPrint) are assigned to output inside server.

Value

Invisibly, after the server is stopped.


Append Attributes to an Existing Tag

Description

Append Attributes to an Existing Tag

Usage

tagAppendAttributes(tag, ...)

Arguments

tag

A tabler.tag object.

...

Named attributes to add/overwrite. The class attribute is appended (space-separated) rather than replaced.

Value

The modified tag.


Create an Ordered Collection of Tags

Description

Create an Ordered Collection of Tags

Usage

tagList(...)

Arguments

...

Tags or other HTML content.

Value

A tabler.tag.list object.


HTML Tag Namespace

Description

A named list of tag-builder functions covering the full HTML5 element set. Usage: tags$section(class = "foo", "content").

Usage

tags

Text Output Placeholder

Description

Places a <span> in the UI whose content is updated by renderText in the server.

Places a <pre> in the UI for monospace/printed output.

Places a tag (by default a <div>) whose inner HTML is replaced wholesale by renderUI output.

Returns a character string that is HTML-escaped and injected as the inner HTML of the matching textOutput placeholder.

Captures the print() representation of the result and shows it verbatim (HTML-escaped).

Returns an HTML tag tree that replaces the inner HTML of the matching uiOutput placeholder.

Places a <div> in the UI whose content is replaced by a base-R plot rendered server-side via renderPlot.

Evaluates expr inside an SVG graphics device, and injects the resulting inline SVG into the matching plotOutput placeholder. Works with base-R graphics, tinyplot, ggplot2, lattice, and any other graphics system that honours the active device.

Places a <div> in the UI whose content is replaced by an htmlwidget (e.g. from d3po, leaflet, plotly) rendered by a matching server-side call. The widget is served inside a sandboxed <iframe> so its own JS/CSS cannot conflict with the page.

Generic render function for any htmlwidgets-based widget. Captures the expression without evaluating it and stores the calling environment, so tablerApp can evaluate it inside a reactive context without requiring a live Shiny session. Reactive values referenced inside expr are tracked automatically.

Assigned to output$id, serves a file for download when the browser requests the matching downloadButton's link, similar to shiny::downloadHandler(). Unlike other outputs, the file is generated fresh (not cached/pushed) each time it is requested.

Creates a link that triggers a file download from the matching downloadHandler, similar to shiny::downloadButton()/shiny::downloadLink().

Usage

textOutput(outputId, inline = FALSE)

verbatimTextOutput(outputId)

uiOutput(outputId, container = div, ...)

htmlOutput(outputId, container = div, ...)

renderText(expr)

renderPrint(expr)

renderUI(expr)

plotOutput(outputId, width = "100%", height = "400px")

renderPlot(expr, width = 800, height = 400)

widgetOutput(outputId, width = "100%", height = "400px")

renderWidget(expr)

downloadHandler(filename, content, contentType = NULL)

downloadButton(
  outputId,
  label = "Download",
  class = "btn-primary",
  icon = "download",
  ...
)

downloadLink(outputId, label = "Download", class = NULL, icon = NULL, ...)

Arguments

outputId

The output identifier (must match the server-side downloadHandler assigned to output[[outputId]]).

inline

If TRUE, use <span>; otherwise <div>.

container

A tag-building function used to create the placeholder element, e.g. tags$h1. Defaults to div.

...

Additional HTML attributes.

expr

Expression that returns an htmlwidget object (e.g. d3po(...), leaflet(...)).

width

CSS width string (default "100%").

height

CSS height string (default "400px").

filename

A string, or a zero-argument function returning a string, giving the filename offered to the browser (e.g. "data.csv").

content

A one-argument function function(file) {...} that writes the file's contents to the path given by file.

contentType

Optional MIME type string. If NULL (default), it is guessed from the filename's extension.

label

Link/button text.

class

Additional CSS classes (default "btn-primary" for downloadButton, none for downloadLink).

icon

Optional icon name to prepend.

Details

Package authors who ship their own render_*() helpers can make them tabler-compatible by attaching the same two attributes:

  attr(fn, "tabler_expr") <- substitute(expr)
  attr(fn, "tabler_env")  <- parent.frame()

This is exactly what render_d3po() in d3po already does.

Value

An HTML tag.

An HTML tag.

An HTML tag.

A tabler_render object for use with tablerApp.

A tabler_render object.

A tabler_render object.

An HTML tag.

A tabler_render object.

An HTML tag.

A zero-argument function with tabler_expr and tabler_env attributes recognised by tablerApp.

A tabler_render object for use with tablerApp.

An HTML tag.


Show/Hide an element

Description

Show or hide an HTML element in a running tablerApp.

show makes an element visible, hide makes an element invisible, toggle displays the element if it is hidden and hides it if it is visible.

showElement, hideElement, and toggleElement are synonyms for show/hide/ toggle.

If condition is given to toggle, that condition is used to decide whether to show or hide the element: the element is shown when the condition evaluates to TRUE and hidden otherwise.

Usage

show(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL
)

showElement(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL
)

hide(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL
)

hideElement(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL
)

toggle(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL,
  condition = NULL
)

toggleElement(
  session = getDefaultReactiveDomain(),
  id = NULL,
  anim = FALSE,
  animType = "slide",
  time = 0.5,
  selector = NULL,
  condition = NULL
)

Arguments

session

The session object passed by tablerApp to the server function.

id

The id of the element/HTML tag.

anim

If TRUE then animate the behaviour.

animType

The type of animation to use, either "slide" or "fade".

time

The number of seconds to make the animation last.

selector

CSS selector of the elements to show/hide. Ignored if the id argument is given. For example, to select all span elements with class x, use selector = "span.x".

condition

An optional argument to toggle, see 'Details' below.

Details

This is a dependency-free adaptation of shinyjs's show/hide/toggle functions for tabler, which does not use or depend on shiny. Instead of relying on a Shiny session, these functions use the plain-list session object created by tablerApp and passed as the third argument to the server function.

See Also

tablerApp

Examples

if (interactive()) {
  ui <- page(
    title = "Show/Hide Example",
    body = body(
      actionButton("btn", "Click me"),
      div(id = "panel", "Watch what happens to me")
    )
  )

  server <- function(input, output, session) {
    observeEvent(input$btn, {
      # Change the following line for more examples
      toggle(session, "panel")
    })
  }

  tablerApp(ui, server)
}
## Not run: 
  # The function call in the above app can be replaced by any of the
  # following examples to produce similar apps
  toggle(session, id = "panel")
  toggle(session, "panel", TRUE)
  toggle(session, "panel", TRUE, "fade", 2)
  toggle(session, id = "panel", time = 1, anim = TRUE, animType = "slide")
  show(session, "panel")
  show(session, id = "panel", anim = TRUE)
  hide(session, "panel")
  hide(session, id = "panel", anim = TRUE)

## End(Not run)

## toggle can be given an optional `condition` argument, which
## determines if to show or hide the element
if (interactive()) {
  ui <- page(
    title = "Conditional Toggle",
    body = body(
      checkboxInput("checkbox", "Show the text", TRUE),
      div(id = "element", "Watch what happens to me")
    )
  )

  server <- function(input, output, session) {
    observe({
      toggle(session, id = "element", condition = input$checkbox)
    })
  }

  tablerApp(ui, server)
}

Run a Long Computation with a Progress Overlay

Description

Shows the full-page progress overlay (see showProgress), then runs expr, then hides the overlay again - but unlike calling showProgress/hideProgress directly around a blocking computation, expr is deferred with later::later() so that tablerApp's event loop gets a chance to actually flush the "show" message to the browser before the slow work begins.

Usage

withProgress(session = getDefaultReactiveDomain(), text = "Loading...", expr)

Arguments

session

The session object passed by tablerApp to the server function. Defaults to getDefaultReactiveDomain().

text

The message displayed above the progress bar.

expr

The (potentially slow) expression to run once the overlay is visible.

Value

Invisibly, NULL. expr runs asynchronously, after withProgress() itself has already returned.

See Also

showProgress, tablerApp

Examples

if (interactive()) {
  ui <- page(
    title = "Progress Example",
    body = body(actionButton("btn", "Load data"))
  )

  server <- function(input, output, session) {
    observeEvent(input$btn, {
      withProgress(session, "Loading data...", {
        Sys.sleep(2)
      })
    })
  }

  tablerApp(ui, server)
}