Table
<wa-table>
Presents structured data in rows and columns.
Examples
Sorting
Set sort-key on header cells. Activating a header emits wa-sort-change with Web Awesome's current sort descriptor. When the table's data property is set, the table replaces it with a sorted array before the event bubbles; rendering remains controlled by the application.
Loading
Use loading, skeleton-rows, and skeleton-effect to replace rows with a loading representation.
Sticky content
Sticky features are useful when a table is placed in a scrolling container.
Expandable rows
Use wa-table-row-exp to associate detail rows with a summary row. Leave room in the first cell for the toggle button.
Row states
Rows support selected and the current semantic variants brand, neutral, success, warning, and danger.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://cdn.yoummday.com/packages/@yoummday/webawesome/0.5.1/dist/components/table/table.js';
After installing Web Awesome via npm, import this component:
import '@yoummday/webawesome/dist/components/table/table.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/table/table.js';
To import this component for React 18 or below, use the following code:
import WaTable from '@yoummday/webawesome/dist/react/table/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | Body rows and expandable row groups. |
head
|
One or more header rows. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
data |
Optional records to sort when a sortable header is activated. The component does not render these records.
Type
TableRecord[] | undefined
|
|
fixedLayoutfixed-layout |
Uses a fixed-width table layout.
Type
boolean
Default
false
|
|
loadingloading |
Replaces the slotted rows with a skeleton table.
Type
boolean
Default
false
|
|
skeletonEffectskeleton-effect |
The animation used by loading skeletons.
Type
'pulse' | 'sheen' | 'none'
Default
'pulse'
|
|
skeletonRowsskeleton-rows |
The number of body skeleton rows shown while loading.
Type
number
Default
7
|
|
stickyFirstColumnsticky-first-column |
Keeps the first column visible while scrolling horizontally.
Type
boolean
Default
false
|
|
stickyHeadsticky-head |
Keeps the header visible while the table scrolls beneath it.
Type
boolean
Default
false
|
|
stickyLastColumnsticky-last-column |
Keeps the last column visible while scrolling horizontally.
Type
boolean
Default
false
|
|
Events
Learn more about events.
| Name | Description |
|---|---|
wa-sort-change |
Emitted when a sortable header is activated. When data is set, it is sorted before the event leaves the table. |
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
body |
The table's body row group. |
::part(body)
|
head |
The table's header row group. |
::part(head)
|
skeleton |
Skeletons rendered while loading. |
::part(skeleton)
|
table |
The table's outer wrapper. |
::part(table)
|
base |
An alias for the table's outer wrapper. |
::part(base)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.