Closed ixodid198 closed 3 years ago
There are a couple different ways to vertically align text, but here's one example that uses flexbox styles: https://glin.github.io/reactable/articles/cookbook/cookbook.html#show-data-from-other-columns-r
Applying that theme to this example:
reactable(df,
compact = TRUE,
fullWidth = FALSE,
columns = list(
Letter = colDef(
align = "center"
),
Numbers = colDef(
width = 400
)
),
theme = reactableTheme(
# Vertically center cells
cellStyle = list(display = "flex", flexDirection = "column", justifyContent = "center")
)
)
Vertical alignment is unfortunately tricky to do in reactable at the moment. These styles aren't obvious, and may also cause visual side effects in some rare cases. So at some point, I'd like to build an easier way to vertically align cells into reactable, either as a column option or theme option.
That works well for me. Thank-you.
Vertical alignment is now officially supported in the development version:
So in the next version, you'll be able to remove the theme styles and use the column option instead:
reactable(
df,
compact = TRUE,
fullWidth = FALSE,
columns = list(
Letter = colDef(
vAlign = "center"
),
Numbers = colDef(
width = 400
)
)
)
I wish to vertically center the text in my "Letter" column, which is tall because of the content in the adjacent "Numbers" column. I require the horizontal alignment of the "Letter" column to remain left-justified.
How do I do this with a Reactable table?