Tables
Documentation and examples for opt-in styling of tables with Inkline.
Basic Table
Using the most basic table markup, here’s how tables look in Inkline. All table styles are inherited in Inkline, meaning any nested tables will be styled in the same manner as the parent.
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
<i-table>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">#</th>
<td>Alex</td>
<td>Grozav</td>
<td>@alexgrozav</td>
</tr>
<tr>
<th scope="row">#</th>
<td>John</td>
<td>Doe</td>
<td>@johndoe</td>
</tr>
<tr>
<th scope="row">#</th>
<td>Alice</td>
<td>Doe</td>
<td>@alicecooper</td>
</tr>
</tbody>
</i-table>
If your tables require more features such as sorting, filtering and rendering, you might want to take a look at the Data Table component.
Bordered Table
Add the bordered
property for borders on all sides of the table and table cells.
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
<i-table bordered>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">#</th>
<td>Alex</td>
<td>Grozav</td>
<td>@alexgrozav</td>
</tr>
<tr>
<th scope="row">#</th>
<td>John</td>
<td>Doe</td>
<td>@johndoe</td>
</tr>
<tr>
<th scope="row">#</th>
<td>Alice</td>
<td>Doe</td>
<td>@alicecooper</td>
</tr>
</tbody>
</i-table>
Striped Table
Add the striped
property to add zebra-striping to any table row within the table body.
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
<i-table striped>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">#</th>
<td>Alex</td>
<td>Grozav</td>
<td>@alexgrozav</td>
</tr>
<tr>
<th scope="row">#</th>
<td>John</td>
<td>Doe</td>
<td>@johndoe</td>
</tr>
<tr>
<th scope="row">#</th>
<td>Alice</td>
<td>Doe</td>
<td>@alicecooper</td>
</tr>
</tbody>
</i-table>
Hoverable Table
Add the hover
property to enable a hover state on table rows within a <tbody>
.
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
<i-table hover>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">#</th>
<td>Alex</td>
<td>Grozav</td>
<td>@alexgrozav</td>
</tr>
<tr>
<th scope="row">#</th>
<td>John</td>
<td>Doe</td>
<td>@johndoe</td>
</tr>
<tr>
<th scope="row">#</th>
<td>Alice</td>
<td>Doe</td>
<td>@alicecooper</td>
</tr>
</tbody>
</i-table>
Responsive Table
Enable responsiveness by adding the responsive
property. Responsive tables scroll horizontally on small devices. When viewing on anything larger, you will not see any difference in these tables.
You can target specific responsive breakpoints by setting a value to the responsive
property: responsive="<breakpoint>"
, where breakpoint is one of xs
, sm
, md
, lg
or xl
.
# | Table Heading | Table Heading | Table Heading | Table Heading | Table Heading | Table Heading |
1 | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell |
2 | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell |
3 | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell | Table Cell |
---|
<i-table responsive>
<thead>
<tr>
<th>#</th>
<th>Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
<td>Table Cell</td>
</tr>
</tbody>
</i-table>
Variants
Tables can be themed using the variant
property. You can use colors such as light
, dark
, primary
, secondary
, info
, success
, warning
, and danger
. You can set a variant for the table as a whole or individual table elements. By default, tables have the light
variant. You can use a variation of any of the above classes to create the table design you need.
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
# | First Name | Last Name | Username |
1 | Alex | Grozav | @alexgrozav |
2 | John | Doe | @johndoe |
3 | Alice | Cooper | @alicecooper |
---|
<i-table variant="light"> .. </i-table>
<i-table variant="dark"> .. </i-table>
<i-table variant="primary"> .. </i-table>
<i-table variant="secondary"> .. </i-table>
<i-table variant="info"> .. </i-table>
<i-table variant="success"> .. </i-table>
<i-table variant="warning"> .. </i-table>
<i-table variant="danger"> .. </i-table>
Component API
Here you can find a list of the various customization options you can use for the table components as props, as well as available slots.
Property bordered
Type Boolean
Accepted true
, false
Default false
Description Sets the table as bordered.
Property hover
Type Boolean
Accepted true
, false
Default false
Description Sets the table as hoverable.
Property responsive
Type Boolean
Accepted true
, false
Default false
Description Sets the table as responsive. When the table width reaches an overflow threshold, it will start scrolling horizontally.
Property striped
Type Boolean
Accepted true
, false
Default false
Description Sets the table as striped.
Property variant
Type String
Accepted light
, dark
, primary
, secondary
, success
, danger
, warning
, info
Default light
Description Sets the color variant of the table component.
Description Slot for table default content.
Sass Variables
Here you can find a list of the Sass variables you can use for the table components. If you're looking to find common variables that these rely on, you should take a look at the Sass Variables page.
Property $table-margin-bottom
Default $spacer
Property $table-cell-padding
Default 0.75rem
Property $table-cell-padding-sm
Default 0.3rem
Property $table-border-width
Default $border-width
Property $table-border-color
Default $border-color
Property $table-color-for-light-variant
Default $color-for-light-variant
Property $table-color-for-dark-variant
Default $color-for-dark-variant
Property $table-variant-{variant}
Default table-variant($color-{variant})
Default (
primary: $table-variant-primary,
secondary: $table-variant-secondary,
light: $table-variant-light,
dark: $table-variant-dark,
info: $table-variant-info,
success: $table-variant-success,
warning: $table-variant-warning,
danger: $table-variant-danger
)
Default @function table-variant($variant) {
$table-variant-color: variant-color-by-luminance($variant, $table-color-for-light-variant, $table-color-for-dark-variant);
$table-variant-background: $variant;
$table-variant-background-hover: variant-color-by-luminance($variant, darken-lightness($variant, 10%), lighten-lightness($variant, 10%));
$table-variant-background-striped: variant-color-by-luminance($variant, darken-lightness($variant, 5%), lighten-lightness($variant, 5%));
$table-variant-border-color: darken($variant, 10%);
$variant-map: (
color: $table-variant-color,
background: $table-variant-background,
background-hover: $table-variant-background-hover,
background-striped: $table-variant-background-striped,
border-color: $table-variant-border-color,
);
@return $variant-map;
}