-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vertical alignment of cells when other columns contain multiple lines #142
Comments
Ok so I've fudged two potential solutions to this (assuming there isn't something obvious I'm missing - which is quite possible).
I was hoping for something as simple as some CSS and/or HTML that would accept |
Oh my God, what a moron I am. Had one last look at the documentation as soon as I posted the above and noticed the Star Wars demo. How did I miss that?! All it needs is: theme = reactableTheme(
# Vertically center cells
cellStyle = list(display = "flex", flexDirection = "column", justifyContent = "center")
)) in the reactable call. Ignore me! Although hopefully the above might prove useful for someone, maybe point 2 in previous comment is a nice way to handle long cell entries if you don't want to end up with some rows thicker than others. |
Hi, vertical alignment is now supported in the development version: Sorry for that example being so hidden before. Vertical alignment is tricky in reactable for many reasons, and even the theme method in the docs can break in some cases (#177 (comment)). You also can't just set In the next version, you can replace those theme styles with the column option, which should work more reliably. I've also added a more prominent example for vertical alignment in the examples: https://glin.github.io/reactable/articles/examples.html#vertical-alignment. |
That's brilliant. And no need to apologise, the example wasn't hidden it was totally my fault for skimming too quickly - there's just so many things you can do with reactable, and your docs packed full of useful examples. In fact, they're right up amongst the best I've read of any R package. |
Hi! I'm actually in a pickle on this. I cant use the new version yet because our app is being deployed next week. I need my headers to align to the bottom, but using the theme options for headerStyle, I can only vertically center the headers. Any ideas from folks on this thread? |
Hello @melanierogala have you seen my comment above here. You don't need the latest version to use this? You would just change the justify argument to "bottom" I assume. That might not be what you're looking for though as I'm not sure I fully understand your question. |
Right! I tried this and was able to use it to center, but "bottom" or
"baseline" didn't work
…On Thu, Dec 2, 2021 at 6:11 AM py9mrg ***@***.***> wrote:
Hello @melanierogala <https://github.com/melanierogala> have you seen my
comment above here
<#142 (comment)>.
You don't need the latest version to use this? You would just change the
justify argument to "bottom" I assume. That might not be what you're
looking for though as I'm not sure I fully understand your question.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#142 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQVBSF56GHYUWZE252CIASLUO55A3ANCNFSM42WYXTPA>
.
|
Strange, I'm not sure. Maybe the package author can help. It would be good to have an MWE (reprex) to test. |
@melanierogala Can you try library(reactable)
library(dplyr)
library(htmltools)
data <- starwars[1:6, ] %>%
select(character = name, height, mass, gender, homeworld, species)
reactable(
data,
columns = list(
character = colDef(
name = "Character / Species",
# Show species under character names
cell = function(value, index) {
species <- data$species[index]
species <- if (!is.na(species)) species else "Unknown"
div(
div(style = list(fontWeight = 600), value),
div(style = list(fontSize = 12), species)
)
}
),
species = colDef(show = FALSE)
),
theme = reactableTheme(
# Align headers to the bottom
headerStyle = list(display = "flex", flexDirection = "column", justifyContent = "flex-end")
),
bordered = TRUE,
width = 600
)
|
Hello,
I can't work out a way to align cells vertically (i.e. the contents in the middle) when other columns contain entries that span multiple lines. I've tried, colDef, CSS, html within the cells, everything. It all seems to work within each line of the cell and not across the full cell. If that makes sense? Compare the two results below (ignore horizontal alignment), hopefully it makes more sense:
Created on 2021-04-10 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: