Table Layout

Utilities for controlling the table layout algorithm.

React propsCSS Properties
tableLayout={keyword}table-layout: {keyword};

Auto

Use tableLayout="auto" to allow the table to automatically size columns to fit the contents of the cell.

<x.table tableLayout="auto"> <thead> <tr> <th>Title</th> <th>Author</th> <th>Views</th> </tr> </thead> <tbody> <tr> <td>Another Story</td> <td>James</td> <td>858</td> </tr> <x.tr bg="light-blue-200"> <td> A Long and Winding Tour of the History of UI Frameworks and Tools and the Impact on Design </td> <td>James</td> <td>112</td> </tr> <tr> <td>A short story</td> <td>Chris</td> <td>1,280</td> </x.tr> </tbody> </x.table>

Fixed

Use tableLayout="fixed" to allow the table to ignore the content and use fixed widths for columns. The width of the first row will set the column widths for the whole table.

You can manually set the widths for some columns and the rest of the available width will be divided evenly amongst the columns without explicit width.

<x.table tableLayout="auto"> <thead> <tr> <x.th w={1 / 2}>Title</x.th> <x.th w={1 / 4}>Author</x.th> <x.th w={1 / 4}>Views</x.th> </tr> </thead> <tbody> <tr> <td>Another Story</td> <td>James</td> <td>858</td> </tr> <x.tr bg="light-blue-200"> <td> A Long and Winding Tour of the History of UI Frameworks and Tools and the Impact on Design </td> <td>James</td> <td>112</td> </tr> <tr> <td>A short story</td> <td>Chris</td> <td>1,280</td> </x.tr> </tbody> </x.table>

Responsive

To control the table layout of an element at a specific breakpoint, use responsive object notation. For example, adding the property tableLayout={{ md: "fixed" }} to an element would apply the tableLayout="fixed" utility at medium screen sizes and above.

<x.table tableLayout={{ md: 'fixed' }} />

For more information about xstyled's responsive design features, check out Responsive Design documentation.

Edit this page on GitHub