R Shiny set DataTable column width

Try this

#OUTPUT - dtdata
output$table <- DT::renderDataTable({
  data.frame(a=c(1,2,3,4,5),b=c("A","B","C","D","E"))
},
options = list(
  autoWidth = TRUE,
  columnDefs = list(list(width="200px", targets = "_all"))
))

Sets the width of all columns to 200px.

To set width of selected columns, change targetsto a number or vector.

targets = c(1,3)

Leave a Comment