# Default settings: adds resizer to both tables and images at the top
r2resize::add.resizer()
# Add resizer to only images, placed at the bottom of the page
if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(
r2resize::add.resizer(
tables = FALSE,
images = TRUE,
position = "bottom"
),
shiny::tags$img(src = "https://via.placeholder.com/150", width = "100px"),
shiny::h3("Only images will have a resizer toolbar.")
),
server = function(input, output) {}
)
}
# Add resizer to only tables with a specific theme color and font size
if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(
r2resize::add.resizer(
tables = TRUE,
images = FALSE,
theme.color = "darkgreen",
font.size = "16px"
),
shiny::h3("Table with resizer:"),
shiny::renderTable(data.frame(
A = 1:3,
B = LETTERS[1:3]
))
),
server = function(input, output) {}
)
}
# Customize resizer line color, width, and height, and set default image width
r2resize::add.resizer(
line.color = "#FF5733",
line.width = 250,
line.height = 10,
thumb.width = 30,
thumb.height = 30,
dim.units = "pt",
default.image.width = "60%"
)
# Full customization example for R Markdown or Shiny
if (FALSE) {
# In an R Markdown document or Shiny UI:
add.resizer(
theme.color = "purple",
position = "top",
font.size = "13px",
font.color = "#4A148C",
tables = TRUE,
images = TRUE,
line.color = "#C2185B",
thumb.width = 28,
thumb.height = 28,
line.width = 200,
line.height = 8,
dim.units = "px",
default.image.width = "75%"
)
}
Run the code above in your browser using DataLab