Skip to content

Commit 645c901

Browse files
shleewhitealex-ju
andauthored
Table: add borders around the cells (#2588)
Co-authored-by: Alex <alex-ju@users.noreply.github.com>
1 parent af6a0b7 commit 645c901

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

.changeset/gorgeous-days-call.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hashicorp/design-system-components": minor
3+
---
4+
5+
`Table` - Updated the visual design of `Table` cells by adding borders, making them more distinguishable when spanning rows or columns.

packages/components/src/styles/components/table.scss

+7-30
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
2424

2525
.hds-table {
2626
width: 100%;
27-
border: $hds-table-border-width solid $hds-table-border-color;
2827
border-radius: $hds-table-border-radius;
2928
border-spacing: 0;
3029
}
@@ -36,6 +35,13 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
3635
table-layout: fixed;
3736
}
3837

38+
// table border
39+
40+
.hds-table,
41+
.hds-table__th,
42+
.hds-table__td {
43+
border: calc(#{$hds-table-border-width} / 2) solid $hds-table-border-color;
44+
}
3945

4046
// ----------------------------------------------------------------
4147

@@ -47,26 +53,8 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
4753
background-color: var(--token-color-surface-strong);
4854

4955
.hds-table__th {
50-
position: relative;
5156
padding: $hds-table-cell-padding-medium;
5257
text-align: left;
53-
border-top: none;
54-
border-right: none;
55-
border-bottom: $hds-table-border-width solid $hds-table-border-color;
56-
border-left: none;
57-
58-
// border between two cells (we emulate a cell border slightly detached from the top/bottom borders)
59-
60-
+ .hds-table__th::before {
61-
position: absolute;
62-
top: 6px;
63-
bottom: 6px;
64-
left: -1px; // we need to offset the border by 1px to render a right border of the previous cell
65-
width: 1px;
66-
background-color: $hds-table-border-color;
67-
content: "";
68-
pointer-events: none;
69-
}
7058
}
7159

7260
// horizontal alignment
@@ -187,11 +175,6 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
187175
// border radius: target first th (scope of row) and td, and last td elements in the last row
188176

189177
&:last-of-type {
190-
.hds-table__th,
191-
.hds-table__td {
192-
border-bottom: none;
193-
}
194-
195178
.hds-table__th:first-child,
196179
.hds-table__td:first-child {
197180
border-bottom-left-radius: $hds-table-inner-border-radius;
@@ -207,10 +190,6 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
207190
.hds-table__th,
208191
.hds-table__td {
209192
text-align: left;
210-
border-top: none;
211-
border-right: none;
212-
border-bottom: $hds-table-border-width solid $hds-table-border-color;
213-
border-left: none;
214193

215194
// density
216195

@@ -225,9 +204,7 @@ $hds-table-cell-padding-tall: 22px 16px 21px 16px; // the 1px difference is to a
225204
.hds-table--density-tall & {
226205
padding: $hds-table-cell-padding-tall;
227206
}
228-
229207
}
230-
231208
// horizontal alignment
232209

233210
.hds-table__th--align-center,

0 commit comments

Comments
 (0)