feat(COMPONENT): Add matNoDataNode Directive to <mat-tree> for Handling Empty States #30458
Labels
area: cdk/tree
feature
This issue represents a new feature or feature request rather than a bug or bug fix
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Feature Description
Currently, Angular Material's component does not provide a built-in way to handle empty states (e.g., when the data source has no nodes). Developers must manually add conditional logic in their templates to display a "No records found" or similar message.
This feature request proposes adding a
matNoDataNode
directive to , similar to thematNoDataRow
directive available for tables. ThematNoDataNode
directive would allow developers to define a template that is displayed when the tree's data source is empty.Proposed Implementation:
A new directive,
matNoDataNode
, that conditionally renders a template when the tree's data source is empty.Seamless integration with the existing mat-tree API, ensuring consistency with other Angular Material components.
Use Case
he
matNoDataNode
directive would enable the following use cases:When a tree has no data, developers can use
matNoDataNode
to display a user-friendly message, such as "No records found" or "No data available."Example:
Developers can define custom templates for empty states, including icons, buttons, or additional instructions.
Example:
The text was updated successfully, but these errors were encountered: