table: how to add border to heading only? #246
-
Describe the bug Desired output: (but I'm going to make heading pink instead of first element) I'm trying to add a bottom border so only the header is underlined and the rest of the table has hidden borders. The issue is that if I try to add borders to the header through the If I remove all borders but the bottom one, e.g. if row == 0 {
return lipgloss.NewStyle().
Foreground(lipgloss.Color("212")).
Border(lipgloss.NormalBorder()).
BorderTop(false).
BorderLeft(false).
BorderRight(false).
BorderBottom(true).
Bold(true)
} then it still doesn't render the bottom-most border Setup
To Reproduce
Source Code https://github.com/charmbracelet/taskcli/blob/feat/lipgloss-table/cmds.go#L124 Expected behavior Screenshots Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
The more correct solution here would be to allow a custom border to be passed to use on the header itself, or to allow fully custom styling of the border header but I suspect this is a niche use case. What do you think? |
Beta Was this translation helpful? Give feedback.
Hey! So the
StyleFunc
is used to style each cell which is why when you apply a border to the cell it tries to add a border to each cell and gives you that weird result. We should probably handle this a little bit better.The
BorderHeader
is applied with the Border supplied on the border so when givenlipgloss.HiddenBorder
theBorderHeader
also applies with a hidden border. This is so that it is consistent with the rest of the table.I think this can be solved through a custom border, would this style be good?
If so, the following custom border can be used: