File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @primer/react " : minor
3+ ---
4+
5+ Vertically align cell contents in ` DataTable `
Original file line number Diff line number Diff line change @@ -66,7 +66,10 @@ const StyledTable = styled.table<React.ComponentPropsWithoutRef<'table'>>`
6666 .TableHeader,
6767 .TableCell {
6868 text-align: start;
69+ display: flex;
70+ align-items: center;
6971 border-bottom: 1px solid ${ get ( 'colors.border.default' ) } ;
72+ padding: var(--table-cell-padding);
7073 }
7174
7275 .TableHeader[data-cell-align='end'],
@@ -102,12 +105,6 @@ const StyledTable = styled.table<React.ComponentPropsWithoutRef<'table'>>`
102105 border-bottom-right-radius: var(--table-border-radius);
103106 }
104107
105- /* TableHeader, TableCell */
106- .TableCell,
107- .TableHeader {
108- padding: var(--table-cell-padding);
109- }
110-
111108 /**
112109 * Offset padding to make sure type aligns regardless of cell padding
113110 * selection
@@ -160,6 +157,8 @@ const StyledTable = styled.table<React.ComponentPropsWithoutRef<'table'>>`
160157
161158 /* TableCell */
162159 .TableCell[scope='row'] {
160+ align-items: center;
161+ display: flex;
163162 color: ${ get ( 'colors.fg.default' ) } ;
164163 font-weight: 600;
165164 }
Original file line number Diff line number Diff line change @@ -230,6 +230,24 @@ describe('Table', () => {
230230 )
231231 expect ( screen . getByRole ( 'rowheader' , { name : 'Cell' } ) ) . toBeInTheDocument ( )
232232 } )
233+
234+ it ( 'should vertically align cell contents' , ( ) => {
235+ render (
236+ < Table >
237+ < Table . Head >
238+ < Table . Row >
239+ < Table . Header > Column</ Table . Header >
240+ </ Table . Row >
241+ </ Table . Head >
242+ < Table . Body >
243+ < Table . Row >
244+ < Table . Cell > Cell</ Table . Cell >
245+ </ Table . Row >
246+ </ Table . Body >
247+ </ Table > ,
248+ )
249+ expect ( screen . getByRole ( 'cell' ) ) . toHaveStyle ( 'align-items: center' )
250+ } )
233251 } )
234252
235253 describe ( 'Table.Skeleton' , ( ) => {
You can’t perform that action at this time.
0 commit comments