Angular Table Directives
Documentation and examples for opt-in styling of Angular tables.
Examples
Using the most basic table CoreUI, here's how cTable
based tables look in CoreUI.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Variants
Use contextual classes to color tables, table rows or individual cells.
Class | Heading | Heading |
---|---|---|
Default | Cell | Cell |
Primary | Cell | Cell |
Secondary | Cell | Cell |
Success | Cell | Cell |
Danger | Cell | Cell |
Warning | Cell | Cell |
Info | Cell | Cell |
Light | Cell | Cell |
Dark | Cell | Cell |
Striped rows
Use striped
property to add zebra-striping to any table row within the tbody
.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Striped columns
Use stripedColumns
property to add zebra-striping to any table column.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Use color
property to add some color variants.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Hoverable rows
Use hover
property to enable a hover state on table rows within a tbody
.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
These hoverable rows can also be combined with the striped
variant:
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Active tables
Highlight a table row or cell by adding a cTableActive
property.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Bordered tables
Add bordered
property for borders on all sides of the table and cells.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Border color utilities can be added to change colors:
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Borderless
Add borderless
property for a table without borders.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Small tables
Add small
property to make any cTable
more compact by cutting all cell padding
in half.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Vertical alignment
Table cells of thead
are always vertical aligned to the
bottom. Table cells in tbody
inherit their alignment from
cTable
and are aligned to the the top by default. Use the align
property to re-align where needed.
Heading 1 | Heading 2 | Heading 3 | Heading 4 |
---|---|---|---|
This cell inherits vertical-align: middle; from the table | This cell inherits vertical-align: middle; from the table | This cell inherits vertical-align: middle; from the table | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
This cell inherits vertical-align: bottom; from the table row | This cell inherits vertical-align: bottom; from the table row | This cell inherits vertical-align: bottom; from the table row | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
This cell inherits vertical-align: middle; from the table | This cell inherits vertical-align: middle; from the table | This cell is aligned to the top. | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonsCTableRowate how the vertical alignment works in the preceding cells. |
Nesting
Border styles, active styles, and table variants are not inherited by nested tables.
# | Class | Heading | Heading | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Mark | Otto | @mdo | ||||||||||||
| |||||||||||||||
3 | Larry the Bird |
Table head
Similar to tables and dark tables, use the modifier prop color="light"
or color="dark"
to make thead
appear light or dark gray.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Table foot
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird | ||
Footer | Footer | Footer | Footer |
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.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
You can also put a caption on the top of the table with caption="top"
.
# | Class | Heading | Heading |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Responsive tables
Always responsive
Responsive tables allow tables to be scrolled horizontally with ease.
Make any table responsive across all viewports by adding a responsive
property.
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
Breakpoint specific
Or pick a maximum breakpoint with which to have a responsive table up to by using responsive="sm|md|lg|xl|xxl"
.
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
API reference
Table Module
import { TableModule, UtilitiesModule } from '@coreui/angular';
@NgModule({
imports: [
TableModule,
UtilitiesModule
]
})
export class AppModule() { }
cTable
directive for table
element
Inputs:
prop | type | default | description |
---|---|---|---|
align |
Alignments |
undefined | table cells vertical alignment |
borderColor |
Colors |
undefined | border color for bordered table |
bordered |
boolean |
undefined | adds borders on all sides of the table and cells |
borderless |
boolean |
undefined | for a table without borders at all |
caption |
top |
undefined | puts caption on the top of the table |
color |
Colors |
undefined | sets color of whole table |
hover |
boolean |
undefined | enable a hover state on table rows within a tbody |
responsive |
boolean / breakpoint |
undefined | adds responsive wrapper to table or pick a maximum breakpoint |
small |
boolean |
undefined | makes compact table by cutting all cell padding in half |
striped |
boolean |
undefined | adds striping to any table row within the tbody |
stripedColumns |
boolean |
undefined | adds striping to any table column |
cTableActive
directive for tr
or td
elements
Inputs:
prop | type | default | description |
---|---|---|---|
cTableActive |
boolean |
undefined | add highlight to row tr or cell td |
cTableColor
directive for table
, thead
, th
, tbody
, tfoot
tr
or td
elements
Input:
prop | type | default | description |
---|---|---|---|
cTableColor |
Colors |
undefined | add color tables, rows or individual cells |
cAlign
directive for table
, thead
, th
, tbody
, tfoot
tr
or td
elements
Input:
prop | type | default | description |
---|---|---|---|
cAlign |
top bottom middle |
undefined | vertical alignment for cells table , tr or td |