| Title: | Layout Manager Widget for R and 'shiny' Apps |
|---|---|
| Description: | Provides R bindings to the 'dockview' 'JavaScript' library <https://dockview.dev/>. Create fully customizable grid layouts (docks) in seconds to include in interactive R reports with R Markdown or 'Quarto' or in 'shiny' apps <https://shiny.posit.co/>. In 'shiny' mode, modify docks by dynamically adding, removing or moving panels or groups of panels from the server function. Choose among 8 stunning themes (dark and light), serialise the state of a dock to restore it later. |
| Authors: | David Granjon [aut, cre], Nelson Stevens [aut], Nicolas Bennett [aut], mathuo [cph], cynkra GmbH [fnd] |
| Maintainer: | David Granjon <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-11 07:45:15 UTC |
| Source: | https://github.com/cynkra/dockViewR |
Functions to dynamically manipulate panels in a dockview instance.
add_panel(dock, panel, ...) remove_panel(dock, id) set_panel_title(dock, id, title) select_panel(dock, id) move_panel(dock, id, position = NULL, group = NULL, index = NULL) move_group(dock, from, to, position = NULL) move_group2(dock, from, to, position = NULL)add_panel(dock, panel, ...) remove_panel(dock, id) set_panel_title(dock, id, title) select_panel(dock, id) move_panel(dock, id, position = NULL, group = NULL, index = NULL) move_group(dock, from, to, position = NULL) move_group2(dock, from, to, position = NULL)
dock |
Dock proxy object created with |
panel |
A panel object (for |
... |
Additional options (currently unused). |
id |
Panel ID (character string). |
title |
New panel title. |
position |
Panel/group position: one of "left", "right", "top", "bottom", "center". |
group |
ID of a panel that belongs to the target group (for |
index |
Panel index within a group (for |
from |
Source group/panel ID (for move operations). |
to |
Destination group/panel ID (for move operations). |
set_panel_title(): Sets the title of a panel dynamically.
add_panel(): Adds a new panel to the dockview
remove_panel(): Removes an existing panel
select_panel(): Selects/focuses a specific panel
move_panel(): Moves a panel to a new position
move_group(): Moves a group using group IDs
move_group2(): Moves a group using panel IDs
All functions return the dock proxy object invisibly, allowing for method chaining.
An example of a JavaScript function that can be used as a default when adding a new tab/panel.
default_add_tab_callback()default_add_tab_callback()
An object of class JS_EVAL representing the JavaScript callback.
An example of a JavaScript function that can be used as a default when removing a tab/panel.
default_remove_tab_callback()default_remove_tab_callback()
An object of class JS_EVAL representing the JavaScript callback.
Creates an interactive dock view widget that enables flexible layout management with draggable, resizable, and dockable panels. This is a wrapper around the dockview.dev JavaScript library, providing a powerful interface for creating IDE-like layouts in Shiny applications or R Markdown documents.
dock_view( panels = list(), ..., theme = c("light-spaced", "light", "abyss", "abyss-spaced", "dark", "vs", "dracula", "replit"), add_tab = new_add_tab_plugin(), width = NULL, height = NULL, elementId = NULL )dock_view( panels = list(), ..., theme = c("light-spaced", "light", "abyss", "abyss-spaced", "dark", "vs", "dracula", "replit"), add_tab = new_add_tab_plugin(), width = NULL, height = NULL, elementId = NULL )
panels |
An unnamed list of |
... |
Other options. See https://dockview.dev/docs/api/dockview/options/. |
theme |
Theme. One of
|
add_tab |
Globally controls the add tab behavior. List with enable and callback.
Enable is a boolean, default to FALSE and callback is a
JavaScript function passed with JS.
See |
width |
Widget width. |
height |
Widget height. |
elementId |
When used outside Shiny. |
An HTML widget object.
Create plugins to enable additional functionality in dock view interfaces. Currently supports "add_tab" and "remove_tab" plugins.
new_dock_view_plugin(type, ...) ## S3 method for class 'add_tab' new_dock_view_plugin(type, enable = FALSE, callback = NULL, ...) ## S3 method for class 'remove_tab' new_dock_view_plugin(type, enable = FALSE, callback = NULL, mode = "auto", ...) new_add_tab_plugin(enable = FALSE, callback = NULL, ...) new_remove_tab_plugin(enable = FALSE, callback = NULL, mode = "auto", ...)new_dock_view_plugin(type, ...) ## S3 method for class 'add_tab' new_dock_view_plugin(type, enable = FALSE, callback = NULL, ...) ## S3 method for class 'remove_tab' new_dock_view_plugin(type, enable = FALSE, callback = NULL, mode = "auto", ...) new_add_tab_plugin(enable = FALSE, callback = NULL, ...) new_remove_tab_plugin(enable = FALSE, callback = NULL, mode = "auto", ...)
type |
Character string specifying the plugin type. |
... |
Additional plugin configuration arguments. |
enable |
Logical, whether the plugin functionality is enabled. |
callback |
Optional JavaScript function. If |
mode |
For remove_tab plugins only. One of "auto" or "manual". |
A dock view plugin object of class add_tab or remove_tab, depending
on the choosen 'type“.
# Add tab plugin new_dock_view_plugin("add_tab", enable = TRUE) new_add_tab_plugin(enable = TRUE) # convenience function # Remove tab plugin new_dock_view_plugin("remove_tab", enable = TRUE, mode = "auto") new_remove_tab_plugin(enable = TRUE, mode = "manual") # convenience function# Add tab plugin new_dock_view_plugin("add_tab", enable = TRUE) new_add_tab_plugin(enable = TRUE) # convenience function # Remove tab plugin new_dock_view_plugin("remove_tab", enable = TRUE, mode = "auto") new_remove_tab_plugin(enable = TRUE, mode = "manual") # convenience function
This function creates a proxy object that can be used to update an existing dockview instance after it has been rendered in the UI. The proxy allows for server-side modifications of the graph without completely re-rendering it.
dock_view_proxy(id, data = NULL, session = getDefaultReactiveDomain())dock_view_proxy(id, data = NULL, session = getDefaultReactiveDomain())
id |
Character string matching the ID of the dockview instance to be modified. |
data |
Unused parameter (for future compatibility). |
session |
The Shiny session object within which the graph exists. By default, this uses the current reactive domain. |
A proxy object of class "dock_view_proxy" that can be used with dockview proxy methods
such as add_panel(), remove_panel(), etc. It contains:
id: The ID of the dockview instance.
session: The Shiny session object.
Output and render functions for using dock_view within Shiny applications and interactive Rmd documents.
dockViewOutput(outputId, width = "100%", height = "400px") dock_view_output(outputId, width = "100%", height = "400px") renderDockView(expr, env = parent.frame(), quoted = FALSE) render_dock_view(expr, env = parent.frame(), quoted = FALSE)dockViewOutput(outputId, width = "100%", height = "400px") dock_view_output(outputId, width = "100%", height = "400px") renderDockView(expr, env = parent.frame(), quoted = FALSE) render_dock_view(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width, height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a dock_view |
env |
The environment in which to evaluate |
quoted |
Is |
dockViewOutput and dock_view_output
return a Shiny output function that can be used in the UI definition.
renderDockView and render_dock_view return a
Shiny render function that can be used in the server definition to
render a dock_view element.
get dock
get dock panels
get dock panels ids
get dock active group
get dock grid
get dock groups
get dock groups ids
get dock groups panels
get active views
get active panel
save a dock
restore a dock
get_dock(dock) get_panels(dock) get_panels_ids(dock) get_active_group(dock) get_grid(dock) get_groups(dock) get_groups_ids(dock) get_groups_panels(dock) get_active_views(dock) get_active_panel(dock) save_dock(dock) restore_dock(dock, data)get_dock(dock) get_panels(dock) get_panels_ids(dock) get_active_group(dock) get_grid(dock) get_groups(dock) get_groups_ids(dock) get_groups_panels(dock) get_active_views(dock) get_active_panel(dock) save_dock(dock) restore_dock(dock, data)
dock |
Dock proxy created with |
data |
Data representing a serialised dock object. |
get_dock returns a list of 3 elements:
grid: a list representing the dock layout.
panels: a list having the same structure as panel() composing the dock.
activeGroup: the current active group (a string).
Each other function allows to deep dive into the returned
value of get_dock().
get_panels() returns the panels element of get_dock().
get_panels_ids() returns a character vector containing all panel ids
from get_panels().
get_active_group() extracts the activeGroup component of
get_dock() as a string.
get_active_views() is a convenience function that returns the active view
in each group.
get_active_panel() is a convenience function that returns the active panel
in the active group.
get_grid() returns the grid element of get_dock() which is a list.
get_groups() returns a list of panel groups from get_grid().
get_groups_ids() returns a character vector of groups ids
from get_groups().
get_groups_panels() returns a list of character vector containing
the ids of each panel within each group.
save_dock() and restore_dock() are used for their side effect to
allow to respectively serialise and restore a dock object.
Only works with server side functions like add_panel. Don't call it from the UI.
Check if object is an add tab plugin
is_add_tab_plugin(x)is_add_tab_plugin(x)
x |
An object to test. |
Logical value.
Check if object is a dock view plugin of specific type
is_dock_view_plugin(x, type)is_dock_view_plugin(x, type)
x |
An object to test. |
type |
Character string specifying plugin type ("add_tab" or "remove_tab"). |
Logical value indicating whether the object is the specified plugin type.
Check if object is a remove tab plugin
is_remove_tab_plugin(x)is_remove_tab_plugin(x)
x |
An object to test. |
Logical value.
Create a panel for use within a dock_view() widget.
Panels are the main container components that can be docked, dragged,
resized, and arranged within the dockview interface.
panel( id, title, content, active = TRUE, remove = new_remove_tab_plugin(), style = list(padding = "10px", overflow = "auto", height = "100%", margin = "10px"), ... )panel( id, title, content, active = TRUE, remove = new_remove_tab_plugin(), style = list(padding = "10px", overflow = "auto", height = "100%", margin = "10px"), ... )
id |
Panel unique id. |
title |
Panel title. |
content |
Panel content. Can be a list of Shiny tags. |
active |
Is active? |
remove |
List with two fields: enable and mode. Enable is a boolean
and mode is one of |
style |
List of CSS style attributes to apply to the panel content. See defaults |
... |
Other options passed to the API. See https://dockview.dev/docs/api/dockview/panelApi/. If you pass position, it must be a list with 2 fields:
|
A list representing a panel object to be consumed by dock_view:
id: unique panel id (string).
title: panel title (string).
content: panel content (shiny.tag.list or single shiny.tag).
active: whether the panel is active or not (boolean).
...: extra parameters to pass to the API.
This does not rerender the widget, just update options like global theme.
update_dock_view(dock, options)update_dock_view(dock, options)
dock |
Dock proxy created with |
options |
List of options for the dock_view instance. |
This function is called for its side effect. It sends a message to JavaScript through the current websocket connection, leveraging the shiny session object.