- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Table
Apply responsive styles to a native HTML table.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| INV006 | Pending | Bank Transfer | $200.00 |
| INV007 | Unpaid | Credit Card | $300.00 |
| Total | $2,500.00 | ||
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmTableImports } from '@spartan-ng/helm/table';
@Component({
selector: 'spartan-table-preview',
imports: [HlmTableImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full',
},
template: `
<div hlmTableContainer>
<table hlmTable>
<caption hlmTableCaption>A list of your recent invoices.</caption>
<thead hlmTableHeader>
<tr hlmTableRow>
<th hlmTableHead class="w-[100px]">Invoice</th>
<th hlmTableHead>Status</th>
<th hlmTableHead>Method</th>
<th hlmTableHead class="text-right">Amount</th>
</tr>
</thead>
<tbody hlmTableBody>
@for (invoice of _invoices; track invoice.invoice) {
<tr hlmTableRow>
<td hlmTableCell class="font-medium">{{ invoice.invoice }}</td>
<td hlmTableCell>{{ invoice.paymentStatus }}</td>
<td hlmTableCell>{{ invoice.paymentMethod }}</td>
<td hlmTableCell class="text-right">{{ invoice.totalAmount }}</td>
</tr>
}
</tbody>
<tfoot hlmTableFooter>
<tr hlmTableRow>
<td hlmTableCell [attr.colSpan]="3">Total</td>
<td hlmTableCell class="text-right">$2,500.00</td>
</tr>
</tfoot>
</table>
</div>
`,
})
export class TablePreview {
protected _invoices = [
{
invoice: 'INV001',
paymentStatus: 'Paid',
totalAmount: '$250.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV002',
paymentStatus: 'Pending',
totalAmount: '$150.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV003',
paymentStatus: 'Unpaid',
totalAmount: '$350.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV004',
paymentStatus: 'Paid',
totalAmount: '$450.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV005',
paymentStatus: 'Paid',
totalAmount: '$550.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV006',
paymentStatus: 'Pending',
totalAmount: '$200.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV007',
paymentStatus: 'Unpaid',
totalAmount: '$300.00',
paymentMethod: 'Credit Card',
},
];
}Installation
ng g @spartan-ng/cli:ui tablenx g @spartan-ng/cli:ui tableUsage
import { HlmTableImports } from '@spartan-ng/helm/table';<div hlmTableContainer>
<table hlmTable>
<caption hlmTableCaption>
A list of your recent invoices.
</caption>
<thead hlmTableHeader>
<tr hlmTableRow>
<th hlmTableHead class="w-[100px]">Invoice</th>
<th hlmTableHead>Status</th>
<th hlmTableHead>Method</th>
<th hlmTableHead class="text-right">Amount</th>
</tr>
</thead>
<tbody hlmTableBody>
@for (invoice of _invoices; track invoice.invoice) {
<tr hlmTableRow>
<td hlmTableCell class="font-medium">{{ invoice.invoice }}</td>
<td hlmTableCell>{{ invoice.paymentStatus }}</td>
<td hlmTableCell>{{ invoice.paymentMethod }}</td>
<td hlmTableCell class="text-right">{{ invoice.totalAmount }}</td>
</tr>
}
</tbody>
<tfoot hlmTableFooter>
<tr hlmTableRow>
<td hlmTableCell [attr.colSpan]="3">Total</td>
<td hlmTableCell class="text-right">$2,500.00</td>
</tr>
</tfoot>
</table>
</div>Examples
Footer
Use <tfoot hlmTableFooter> to add a footer to the table.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| Total | $2,500.00 | ||
import { SlicePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmTableImports } from '@spartan-ng/helm/table';
@Component({
selector: 'spartan-table-footer',
imports: [HlmTableImports, SlicePipe],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full',
},
template: `
<div hlmTableContainer>
<table hlmTable>
<caption hlmTableCaption>A list of your recent invoices.</caption>
<thead hlmTableHeader>
<tr hlmTableRow>
<th hlmTableHead class="w-[100px]">Invoice</th>
<th hlmTableHead>Status</th>
<th hlmTableHead>Method</th>
<th hlmTableHead class="text-right">Amount</th>
</tr>
</thead>
<tbody hlmTableBody>
@for (invoice of _invoices | slice: 0 : 3; track invoice.invoice) {
<tr hlmTableRow>
<td hlmTableCell class="font-medium">{{ invoice.invoice }}</td>
<td hlmTableCell>{{ invoice.paymentStatus }}</td>
<td hlmTableCell>{{ invoice.paymentMethod }}</td>
<td hlmTableCell class="text-right">{{ invoice.totalAmount }}</td>
</tr>
}
</tbody>
<tfoot hlmTableFooter>
<tr hlmTableRow>
<td hlmTableCell [attr.colSpan]="3">Total</td>
<td hlmTableCell class="text-right">$2,500.00</td>
</tr>
</tfoot>
</table>
</div>
`,
})
export class TableFooter {
protected _invoices = [
{
invoice: 'INV001',
paymentStatus: 'Paid',
totalAmount: '$250.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV002',
paymentStatus: 'Pending',
totalAmount: '$150.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV003',
paymentStatus: 'Unpaid',
totalAmount: '$350.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV004',
paymentStatus: 'Paid',
totalAmount: '$450.00',
paymentMethod: 'Credit Card',
},
{
invoice: 'INV005',
paymentStatus: 'Paid',
totalAmount: '$550.00',
paymentMethod: 'PayPal',
},
{
invoice: 'INV006',
paymentStatus: 'Pending',
totalAmount: '$200.00',
paymentMethod: 'Bank Transfer',
},
{
invoice: 'INV007',
paymentStatus: 'Unpaid',
totalAmount: '$300.00',
paymentMethod: 'Credit Card',
},
];
}Actions
A table showing actions for each row using a Dropdown component.
| Product | Price | Actions |
|---|---|---|
| Wireless Mouse | $29.99 | |
| Mechanical Keyboard | $129.99 | |
| USB-C Hub | $49.99 |
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideMoreHorizontal } from '@ng-icons/lucide';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDropdownMenuImports } from '@spartan-ng/helm/dropdown-menu';
import { HlmTableImports } from '@spartan-ng/helm/table';
@Component({
selector: 'spartan-table-actions',
imports: [HlmTableImports, HlmButtonImports, HlmDropdownMenuImports, NgIcon],
providers: [provideIcons({ lucideMoreHorizontal })],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full',
},
template: `
<div hlmTableContainer>
<table hlmTable>
<thead hlmTableHeader>
<tr hlmTableRow>
<th hlmTableHead>Product</th>
<th hlmTableHead>Price</th>
<th hlmTableHead class="text-right">Actions</th>
</tr>
</thead>
<tbody hlmTableBody>
@for (product of _products; track product.name) {
<tr hlmTableRow>
<td hlmTableCell class="font-medium">{{ product.name }}</td>
<td hlmTableCell>{{ product.price }}</td>
<td hlmTableCell class="text-right">
<button hlmBtn variant="ghost" size="icon-sm" [hlmDropdownMenuTrigger]="menu" align="end">
<ng-icon name="lucideMoreHorizontal" />
<span class="sr-only">Open menu</span>
</button>
</td>
</tr>
}
</tbody>
</table>
</div>
<ng-template #menu>
<hlm-dropdown-menu>
<button hlmDropdownMenuItem>Edit</button>
<button hlmDropdownMenuItem>Duplicate</button>
<hlm-dropdown-menu-separator />
<button hlmDropdownMenuItem variant="destructive">Delete</button>
</hlm-dropdown-menu>
</ng-template>
`,
})
export class TableActions {
protected _products = [
{
name: 'Wireless Mouse',
price: '$29.99',
},
{
name: 'Mechanical Keyboard',
price: '$129.99',
},
{
name: 'USB-C Hub',
price: '$49.99',
},
];
}Data Table
For more complex tables, have a look at the data table , which is powered by the incredible work of TanStack-Table .
See the Data Table documentation for more information.
You can also see an example of a data table in the Tasks demo.
RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
| الفاتورة | الحالة | الطريقة | المبلغ |
|---|---|---|---|
| INV001 | مدفوع | بطاقة ائتمانية | $250.00 |
| INV002 | قيد الانتظار | PayPal | $150.00 |
| INV003 | غير مدفوع | تحويل بنكي | $350.00 |
| INV004 | مدفوع | بطاقة ائتمانية | $450.00 |
| INV005 | مدفوع | PayPal | $550.00 |
| INV006 | قيد الانتظار | تحويل بنكي | $200.00 |
| INV007 | غير مدفوع | بطاقة ائتمانية | $300.00 |
| المجموع | $2,500.00 | ||
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmTableImports } from '@spartan-ng/helm/table';
type Invoice = {
invoice: string;
paymentStatus: 'paid' | 'pending' | 'unpaid';
totalAmount: string;
paymentMethod: 'creditCard' | 'paypal' | 'bankTransfer';
};
@Component({
selector: 'spartan-table-rtl',
imports: [HlmTableImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full',
},
template: `
<div hlmTableContainer>
<table hlmTable [dir]="_dir()">
<caption hlmTableCaption>{{ _t()['caption'] }}</caption>
<thead hlmTableHeader>
<tr hlmTableRow>
<th hlmTableHead class="w-[100px]">{{ _t()['invoice'] }}</th>
<th hlmTableHead>{{ _t()['status'] }}</th>
<th hlmTableHead>{{ _t()['method'] }}</th>
<th hlmTableHead class="text-end">{{ _t()['amount'] }}</th>
</tr>
</thead>
<tbody hlmTableBody>
@for (invoice of _invoices; track invoice.invoice) {
<tr hlmTableRow>
<td hlmTableCell class="font-medium">{{ invoice.invoice }}</td>
<td hlmTableCell>{{ _t()[invoice.paymentStatus] }}</td>
<td hlmTableCell>{{ _t()[invoice.paymentMethod] }}</td>
<td hlmTableCell class="text-end">{{ invoice.totalAmount }}</td>
</tr>
}
</tbody>
<tfoot hlmTableFooter>
<tr hlmTableRow>
<td hlmTableCell [attr.colSpan]="3">{{ _t()['total'] }}</td>
<td hlmTableCell class="text-end">$2,500.00</td>
</tr>
</tfoot>
</table>
</div>
`,
})
export class TableRtl {
protected _invoices: Invoice[] = [
{
invoice: 'INV001',
paymentStatus: 'paid',
totalAmount: '$250.00',
paymentMethod: 'creditCard',
},
{
invoice: 'INV002',
paymentStatus: 'pending',
totalAmount: '$150.00',
paymentMethod: 'paypal',
},
{
invoice: 'INV003',
paymentStatus: 'unpaid',
totalAmount: '$350.00',
paymentMethod: 'bankTransfer',
},
{
invoice: 'INV004',
paymentStatus: 'paid',
totalAmount: '$450.00',
paymentMethod: 'creditCard',
},
{
invoice: 'INV005',
paymentStatus: 'paid',
totalAmount: '$550.00',
paymentMethod: 'paypal',
},
{
invoice: 'INV006',
paymentStatus: 'pending',
totalAmount: '$200.00',
paymentMethod: 'bankTransfer',
},
{
invoice: 'INV007',
paymentStatus: 'unpaid',
totalAmount: '$300.00',
paymentMethod: 'creditCard',
},
];
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
caption: 'A list of your recent invoices.',
invoice: 'Invoice',
status: 'Status',
method: 'Method',
amount: 'Amount',
paid: 'Paid',
pending: 'Pending',
unpaid: 'Unpaid',
creditCard: 'Credit Card',
paypal: 'PayPal',
bankTransfer: 'Bank Transfer',
total: 'Total',
},
},
ar: {
dir: 'rtl',
values: {
caption: 'قائمة بفواتيرك الأخيرة.',
invoice: 'الفاتورة',
status: 'الحالة',
method: 'الطريقة',
amount: 'المبلغ',
paid: 'مدفوع',
pending: 'قيد الانتظار',
unpaid: 'غير مدفوع',
creditCard: 'بطاقة ائتمانية',
paypal: 'PayPal',
bankTransfer: 'تحويل بنكي',
total: 'المجموع',
},
},
he: {
dir: 'rtl',
values: {
caption: 'רשימת החשבוניות האחרונות שלך.',
invoice: 'חשבונית',
status: 'סטטוס',
method: 'שיטה',
amount: 'סכום',
paid: 'שולם',
pending: 'ממתין',
unpaid: 'לא שולם',
creditCard: 'כרטיס אשראי',
paypal: 'PayPal',
bankTransfer: 'העברה בנקאית',
total: 'סה"כ',
},
},
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
}Helm API
HlmTableContainer
Selector: div[hlmTableContainer]
ExportAs: hlmTableContainer
HlmTable
Selector: table[hlmTable]
ExportAs: hlmTable
HlmTHead
Selector: thead[hlmTHead],thead[hlmTableHeader]
ExportAs: hlmTHead
HlmTBody
Selector: tbody[hlmTBody],tbody[hlmTableBody]
ExportAs: hlmTBody
HlmTFoot
Selector: tfoot[hlmTFoot],tfoot[hlmTableFooter]
ExportAs: hlmTFoot
HlmTr
Selector: tr[hlmTr],tr[hlmTableRow]
ExportAs: hlmTr
HlmTh
Selector: th[hlmTh],th[hlmTableHead]
ExportAs: hlmTh
HlmTd
Selector: td[hlmTd],td[hlmTableCell]
ExportAs: hlmTd
HlmCaption
Selector: caption[hlmCaption],caption[hlmTableCaption]
ExportAs: hlmCaption
On This Page