ns-table
#
IntroductionThe
ns-table
component displays information in a grid-like format of rows and columns. It organises information in a way that’s easy to scan, so that users can look for patterns and insights.
The table component consumes basic HTML table markup, which makes it accessible and responsive as well as styling it.
#
Content guidanceKey | Field type | Guidelines |
---|---|---|
A | Heading | Use to provide context to the table content. The recommended length is between 4 and 12 words, not exceeding 50 characters in total. |
B | Column Headings | A short description of the data or information found in the column cells below. |
C | Fixable Row Headings | This column can be used for data or information. It can also be set to a fixed column of headings for each row. |
D | Table Cells | This should contain the data or information required for each relevant column and row. |
#
Best practice💚 Do's | 💔 Don'ts |
---|---|
Add a <caption> to the ns-table | Use ns-table just for layout |
Use for displaying data in tables | Use for laying out components |
Use basic text, numbers | Use tables for anything but tabular data |
Include at least one column header or row header | |
Keep column and row headers short and concise | |
Structure them in a logical and expected way |
#
Considerations of best practice- Not all tables necessarily need captions, but it's recommended you provide one.
- Column header names should describe the type of content displayed in each column. Each row should contain data related to a single entity.
- Think about the experience on a smaller screen size.
- The
ns-table
component adds all the necessary Aria tags to the table to make it accessible for screen readers. - Keyboard controls are automatically added to the table to make it perform as a data grid. You can select cells and use the arrow keys to navigate.
- If your table has table headers
<th>
in the first column, the component will make these “sticky” so that the table data can be scrolled horizontally whilst the first column headers stay in place.
#
Usage#
Component placementThe ns-table component can be used in the following components:
#
Specificationns-table
doesn't expect any attributes to be added to it, you simply need to insert HTML table markup and it will render the table in an accessible and responsive way.
#
CaptionBe sure to add a <caption>
tag inside the <table>
. The caption should explain what the table is representing.
#
Column headersIf your table data has column headings across the first row then place header cells (<th>
) within the <thead>
tag.
#
Row headersIf your table has row headers in the left-most column then place these headers in <th>
within the <tbody>
. The component will automatically make these headings 'sticky' so that on smaller screens you can scroll the table horizontally while the row headers stay in place.
#
Feedback- Do you have insights or concerns to share? You can raise an issue via Github bugs.
- See all the issues already raised via Github issues.
💩 🎉 🦄 If you have any questions, contact us on Microsoft Teams in the Nucleus Design System channels.