NoData
Shortcut empty-state component for empty datasets, tables, charts, and metrics panels.
Usage
NoData
Loading demo...
Best Practices
- Use it when a data source is valid and returned zero records; use
TxOfflineStateorTxPermissionStatefor transport and access failures. - Keep copy data-specific: “No invoices yet” is more useful than “Nothing here”.
- Offer a creation or import action only when the current user can actually populate the dataset.
- Use
surface="card"inside dashboards and table panels so the empty region occupies the same container as loaded data.
API Reference
Props
TxNoData accepts every EmptyStateProps field except variant.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | preset title | Overrides the no-data title. |
description | string | preset description | Explains why the dataset is empty or how to populate it. |
icon | TxIconSource | string | null | preset illustration | Custom icon source/class, or null to hide the icon area. |
iconSize | number | size preset | Custom icon size in pixels. |
layout | 'vertical' | 'horizontal' | 'vertical' | Empty-state layout. |
align | 'start' | 'center' | 'end' | 'center' | Alignment within the wrapper. |
size | 'small' | 'medium' | 'large' | 'medium' | Density and illustration scale. |
surface | 'plain' | 'card' | 'plain' | Adds card containment when needed. |
primaryAction | EmptyStateAction | - | Generated primary action. |
secondaryAction | EmptyStateAction | - | Generated secondary action. |
actionSize | TxButtonProps['size'] | 'small' | Default generated action size. |
loading | boolean | false | Uses spinner when no custom icon is supplied. |
EmptyStateAction
| Field | Type | Default | Description |
|---|---|---|---|
label | string | required | Button label. |
type | TxButtonProps['type'] | - | Button semantic type, for example primary. |
variant | TxButtonProps['variant'] | - | Button visual variant. |
size | TxButtonProps['size'] | actionSize | Per-button size override. |
disabled | boolean | false | Disables the generated button. |
icon | string | - | Button icon class. |
Events
| Event | Params | Description |
|---|---|---|
primary | - | Forwarded from the generated primary action. |
secondary | - | Forwarded from the generated secondary action. |
Slots
| Slot | Props | Description |
|---|---|---|
icon | - | Replaces the preset illustration or custom icon. |
title | - | Replaces resolved title content. |
description | - | Replaces resolved description content. |
actions | - | Replaces generated primary/secondary action buttons. |
Overview
- Always forwards
variant="no-data"toTxEmptyState. - Does not rewrite explicit
title,description,surface,layout,align,size,icon, or action props. - Forwards
icon,title,description, andactionsslots unchanged toTxEmptyState. - Generated
primary/secondaryevents come from the wrappedTxEmptyStateaction buttons.
Technologies
- Wrapper contract:
TxNoDatais a thinTxEmptyStatewrapper that always suppliesvariant="no-data"; every otherEmptyStatePropsfield is forwarded unchanged. - State choice: Use this only for valid, loaded datasets with zero records. Connectivity, access, loading, and filtered-result states have dedicated wrappers so copy and recovery actions stay precise.
- Verified coverage:
no-data.test.tscovers forced variant forwarding, explicit props/actions, named slots, and install registration; base rendering and action events are inherited fromTxEmptyState. - Component source:
packages/tuffex/packages/components/src/no-data/src/TxNoData.vue. - Base source:
packages/tuffex/packages/components/src/empty-state/src/TxEmptyState.vue. - Types:
packages/tuffex/packages/components/src/no-data/src/types.tsexportsNoDataProps = Omit<EmptyStateProps, 'variant'>. - Coverage:
packages/tuffex/packages/components/src/no-data/__tests__/no-data.test.tsverifies variant locking, prop forwarding, slot forwarding, and install behavior.
查看源码
packages/tuffex/packages/components/src/no-data/index.ts