dt2_use_buttons: Enable Buttons (extension) and define buttons

View source: R/dt2_options.R

dt2_use_buttonsR Documentation

Enable Buttons (extension) and define buttons

Description

Uses the modern DataTables 2.x layout API (not the deprecated dom).

Usage

dt2_use_buttons(
  options = list(),
  buttons = c("copy", "csv", "excel", "print"),
  position = "topEnd",
  button_class = NULL
)

Arguments

options

Options list.

buttons

Vector of button ids (e.g., c("copy","csv","excel","print","colvis")).

position

Where to place buttons in the layout. One of "topEnd" (default), "topStart", "bottomEnd", "bottomStart".

button_class

CSS class for buttons (e.g., "btn btn-sm btn-primary"). If NULL, uses the theme default ("btn btn-sm btn-outline-secondary"). Applied per-button via className.

Value

Updated options.

See Also

dt2_buttons() for a lower-level variant that takes full button objects and can relocate the buttons container to a custom CSS selector.

Examples

opts <- dt2_use_buttons(list(), buttons = c("copy", "csv", "excel"))
dt2(mtcars, options = opts)

DT2 documentation built on June 14, 2026, 9:06 a.m.