 Search
components/accordion: Accordion components/badge: Badge components/button: Button components/checkbox: Checkbox components/dialog: Dialog components/input: Input components/mark: Mark components/popover: Popover components/progress: Progress components/pre: Pre components/radio: Radio components/range: Range components/separator: Separator components/spinner: Spinner components/switch: Switch components/table: Table components/textarea: Textarea components/tooltip: Tooltip components/typography: Typography components/view: View plugins/plugin-declarative-layout: Declarative Layout plugins/plugin-nf: Nerd Font Plugin plugins/theme-everforest: Everforest Theme plugins/theme-catppuccin: Catppuccin Theme contributing/style-guide: Style Guide contributing/style-guide: ## CSS Units contributing/style-guide: ## Selectors contributing/style-guide: ## Documentation plugins/plugin-dev: Developing Plugins plugins/plugin-dev: ### Style Layers contributing/contributing: Contributing contributing/contributing: ## Local Development contributing/contributing: ## Issues contributing/contributing: ## Pull Requests installation/nextjs: Next.js installation/vite: Vite installation/astro: Astro installation/astro: ## Scoping installation/astro: ### Frontmatter Imports installation/astro: ### <style> tag installation/astro: ### Full Library Import plugins/theme-gruvbox: Gruvbox Theme plugins/theme-nord: Nord Theme plugins/theme-osmium: Osmium Theme plugins/theme-vitesse: Vitesse Theme start/ascii-boxes: ASCII Boxes start/changelog: Changelog start/installation: Installation start/plugins: Plugins start/plugins: ## Official Plugins start/plugins: ### Themes start/plugins: ## Community Plugins start/intro: Introduction start/intro: ## Features start/theming: Theming start/theming: ## CSS Variables start/theming: ### Font Styles start/theming: ### Colors start/theming: ### Light & Dark start/theming: ## Theme Plugins start/theming: ### Using Multiple Theme Accents start/tuis-vs-guis: TUIs vs GUIs start/tuis-vs-guis: ## Monospace Fonts start/tuis-vs-guis: ## Character Cells

Table

Displays a table

1 <table>
2 <thead>
3 <tr>
4 <th>Name</th>
5 <th>Age</th>
6 <th>Country</th>
7 </tr>
8 </thead>
9 <tbody>
10 <tr>
11 <td>John</td>
12 <td>25</td>
13 <td>USA</td>
14 </tr>
15 <tr>
16 <td>Jane</td>
17 <td>30</td>
18 <td>Canada</td>
19 </tr>
20 </tbody>
21 <tfoot>
22 <tr>
23 <td>Joe</td>
24 <td>27.8</td>
25 <td>Lithuania for some unexplainable reason</td>
26 </tr>
27 </tfoot>
28 </table>
29

Import

@import '@webtui/css/components/table.css';

Usage

<table>
    <thead>
        <tr>
            <td>...</td>
            <td>...</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>...</td>
            <td>...</td>
            <td>...</td>
        </tr>
        ...
    </tbody>
    <tfoot>
        <tr>
            <td>...</td>
        </tr>
    </tfoot>
</table>

Examples

Divide

Use the divide- attribute to change the direction of the table dividers

<table divide-="none"></table>
<table divide-="horizontal"></table>
<table divide-="vertical"></table>
<table divide-="both"></table>
<!-- Not providing `divide-` is the same as `divide-="both"` -->
<table></table>
1
2 <table divide-="both">
3 <thead>
4 <tr>
5 <th>divide-</th>
6 <th>both</th>
7 </tr>
8 </thead>
9 <tbody>
10 <tr>
11 <td>or</td>
12 <td>also</td>
13 </tr>
14 <tr>
15 <td>divide-</td>
16 <td><not provided></td>
17 </tr>
18 </tbody>
19 </table>
20 <table divide-="horizontal">
21 <thead>
22 <tr>
23 <th>divide-</th>
24 <th>horizontal</th>
25 </tr>
26 </thead>
27 <tbody>
28 <tr>
29 <td>hey</td>
30 <td>look</td>
31 </tr>
32 <tr>
33 <td>horizontal</td>
34 <td>lines</td>
35 </tr>
36 </tbody>
37 </table>
38 <table divide-="vertical">
39 <thead>
40 <tr>
41 <th>divide-</th>
42 <th>vertical</th>
43 </tr>
44 </thead>
45 <tbody>
46 <tr>
47 <td>hey</td>
48 <td>look</td>
49 </tr>
50 <tr>
51 <td>vertical</td>
52 <td>lines</td>
53 </tr>
54 </tbody>
55 </table>
56 <table divide-="none">
57 <thead>
58 <tr>
59 <th>divide-</th>
60 <th>none</th>
61 </tr>
62 </thead>
63 <tbody>
64 <tr>
65 <td>hey</td>
66 <td>look</td>
67 </tr>
68 <tr>
69 <td>no</td>
70 <td>lines</td>
71 </tr>
72 </tbody>
73 </table>
74

ASCII Boxes

Pair the table component with the box- utility to add box borders around the table

<table box-="none" divide-="none"></table>
<table box-="square" divide-="both"></table>
<table box-="round" divide-="horizontal"></table>
<table box-="double" divide-="vertical"></table>
1
2 <table divide-="both" box-="square">
3 <thead>
4 <tr>
5 <th>divide-</th>
6 <th>both</th>
7 </tr>
8 </thead>
9 <tbody>
10 <tr>
11 <td>box-</td>
12 <td>square</td>
13 </tr>
14 </tbody>
15 </table>
16 <table divide-="horizontal" box-="round">
17 <thead>
18 <tr>
19 <th>divide-</th>
20 <th>horizontal</th>
21 </tr>
22 </thead>
23 <tbody>
24 <tr>
25 <td>box-</td>
26 <td>round</td>
27 </tr>
28 </tbody>
29 </table>
30 <table divide-="vertical" box-="double">
31 <thead>
32 <tr>
33 <th>divide-</th>
34 <th>vertical</th>
35 </tr>
36 </thead>
37 <tbody>
38 <tr>
39 <td>box-</td>
40 <td>double</td>
41 </tr>
42 </tbody>
43 </table>
44 <table divide-="none" box-="none">
45 <thead>
46 <tr>
47 <th>divide-</th>
48 <th>none</th>
49 </tr>
50 </thead>
51 <tbody>
52 <tr>
53 <td>box-</td>
54 <td>none</td>
55 </tr>
56 </tbody>
57 </table>
58

Reference

Properties

  • --table-border-width: The width of the table borders
  • --table-border-color: The color of the table borders

Note: If used with box-, --table-border-color inherits the value of --box-border-color

table {
    --table-border-width: 1px;
    --table-border-color: var(--foreground2);
}

Extending

To extend the Table stylesheet, define a CSS rule on the components layer

@layer components {
    table {
        /* ... */
    }
}

Scope

  • All <table> elements
  • All <tr>, <th>, and <td> elements that are children of a <table>
table {
    tr {
        th {
            /* ... */
        }
        td {
            /* ... */
        }
    }
}