Any table that has clear and understandable information is successful. Our table styles strive for flexibility, so there are several options to choose from. However, each follows a similar structure and pattern, with clear headings with high contrast, proper spacing between rows, and easy to read and large text to display information.
Tables can be left or center aligned with the column header. Our tables support a variety of actions, both individual and bulk. It’s important to note that we use zebra striping only for tables that have no action.
Examples
Due to the widespread use of tables across third-party widgets like calendars and date pickers, we've designed our tables to be opt-in. Just add the base class `.table` to any `table`, then extend with custom styles or our various included modifier classes.
Using the most basic table markup, here's how `.table`-based tables look in Cirrus. All table styles are inherited in Cirrus, meaning any nested tables will be styled in the same manner as the parent.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Table head options
Use the modifier classes `.thead-light`, `.thead-dark` to change the header appearance.
Dark
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Light
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Clean
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Striped rows
Striping on tables should always be done through CSS. This allows us to filter, modify, add, remove, and change rows without causing weird visual issues.
Use `.table-striped` to add zebra-striping to any table row within the `tbody`.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Bordered table
Add `.table-bordered` for borders on all sides of the table and cells.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
Borderless table
Add `.table-borderless` for a table without borders.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
Hoverable rows
Add `.table-hover` to enable a hover state on table rows within a `tbody`.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
Small table
Add `.table-sm` to make tables more compact by cutting cell padding in half.
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
Conveying meaning to assistive technologies
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
Captions
A `caption` functions like a heading for a table. It helps users with screen readers to find a table and understand what it's about and decide if they want to read it.
List of users
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry
the Bird
@twitter
Interactive Table
Since tables will be custom per project, there are no "pre-build" functionality of the below table. Clicking the buttons will only show the UI and not change the structure.
Important! If you use an interactive table that submits data somewhere through AJAX/Fetch, then the table should be wrapped in a form tag to be as semantic as possible.
Responsive tables
Mobile tables are extremely dependent upon the information being displayed. We use a card structure, as exemplified in the Cards & Tiles section. Make sure that destructive actions are away from a user would be doing a majority of their scrolling, such as the center of the screen. However, certain designs may have to make concessions based on content, so use your best judgment when laying out a table for mobile.
If you can’t or don’t want to use cards, make sure to clearly separate rows to draw a distinction between different rows of information.
This is an example of what a table could reduce down to. Every row has a data-title attribute that has the name of the column header. This is then shown when the table reduces down to a specific size. This layout does not exist in the core code and is for demonstration purposes only.
Responsive Table CSS Example
This isn't using media queries but could easily be dropped in one using the built in grid system. Boxes should be arranged to fit their appropriate content. Work closely with the designers when building mobile versions of table to make sure that all data is accounted for.
Mobile Screen Size Magic Toggle
(MSSMT for short)
Vertical clipping/truncation
Responsive tables make use of `overflow-y: hidden`, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
Scrolling responsive - a last resort
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a `.table` with `.table-responsive`. Or, pick a maximum breakpoint with which to have a responsive table up to by using `.table-responsive{-sm|-md|-lg|-xl}`.
Across every breakpoint, use `.table-responsive` for horizontally scrolling tables.
#
Heading
Heading
Heading
Heading
Heading
Heading
Heading
Heading
Heading
1
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
2
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
3
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Cell
Breakpoint specific
Use `.table-responsive{-sm|-md|-lg|-xl}` as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally.
These tables may appear broken until their responsive styles apply at specific viewport widths.