library(muiDataGrid)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, unionRow Height
The Data Grid provides flexible options for controlling row height, from static heights to dynamic sizing based on content.
Column Header Height
Customize the height of the column header using the
columnHeaderHeight prop:
DataGrid(
rows = starwars |> select(name, height, mass, species) |> head(),
columnHeaderHeight = 80
)Dynamic Row Height
Auto Height
Use ‘auto’ to let rows expand to fit their content:
DataGrid(
rows = starwars |> select(name, films) |> head(),
columns = list(
list(field = "name", width = 180),
list(field = "films", width = 400)
),
getRowHeight = JS("function() { return 'auto'; }")
)With Estimated Height
Provide an estimated height for better scrolling performance:
DataGrid(
rows = starwars |> select(name, films) |> head(10),
columns = list(
list(field = "name", width = 180),
list(field = "films", width = 400)
),
getRowHeight = JS("function() { return 'auto'; }"),
getEstimatedRowHeight = JS("function() { return 80; }")
)Row Density
Density Presets
Use predefined density settings to quickly adjust row height:
# Compact density
DataGrid(
rows = starwars |> select(name, height, mass, species) |> head(),
density = "compact"
)
# Standard density (default)
DataGrid(
rows = starwars |> select(name, height, mass, species) |> head(),
density = "standard"
)
# Comfortable density
DataGrid(
rows = starwars |> select(name, height, mass, species) |> head(),
density = "comfortable"
)Density values affect row height: - “compact”: ~52px - “standard”: ~52px (default) - “comfortable”: ~62px