Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

DataView

Browse a collection in list, grid or table mode with search, sorting and pages.

Category
Data and hierarchy
Import
@neural-ui/core/data-view
Selector
neu-data-view
import { NeuDataViewComponent } from '@neural-ui/core/data-view';

Usage

items contains application data. Provide neuDataViewItem to render structured records; default rendering is not a domain-specific card. searchFields enables local matching and sortOptions names sortable fields. Omit total/currentPage for local paging; set both and handle pageChange to load a remote page. modeChange proposes the selected mode; apply it to mode. Templates replace content, not the paging engine.

Examples

Try this application-owned interaction. Its event handling and initial data are included in Code.

Examples
  • AtlasEU ยท 240 โ‚ฌ
  • BirchUS ยท 180 โ‚ฌ
  • CedarEU ยท 420 โ‚ฌ

Events: 0

Try and configure

Change the public options, try the result and inspect the updated template. Code contains the complete executable implementation.

Try and configure
  • AtlasEU ยท 240 โ‚ฌ
  • BirchUS ยท 180 โ‚ฌ
  • CedarEU ยท 420 โ‚ฌ

Events: 0

template.html
<neu-data-view
  (pageChange)="onPageChange($event)"
  [items]="items()"
  [mode]="'list'"
  (modeChange)="mode.set($event)"
  [modeLabels]="modes()"
  [loading]="false"
  [searchable]="true"
  [searchFields]="['name', 'region', 'amount']"
  [sortOptions]="sortOptions()"
  [pagination]="true"
  [pageSize]="3"
  [viewSwitcher]="true"
  [trackBy]="track"
  [viewAriaLabel]="'View mode'"
  [previousLabel]="'Previous'"
  [nextLabel]="'Next'"
  (pageChange)="record('pageChange', $event)"
  (searchChange)="record('searchChange', $event)"
  (sortChange)="record('sortChange', $event)"
  [emptyLabel]="'No projects'"
  [loadingLabel]="'Loading projects'"
  [paginationAriaLabel]="'Project pages'"
  [searchAriaLabel]="'Search projects'"
  [searchPlaceholder]="'Search projects'"
  [sortAriaLabel]="'Sort projects'"
><ng-template neuDataViewItem let-item let-index="index"
    ><article class="remaining-data-item">
      <strong>{{ item.name }}</strong
      ><span>{{ item.region }} ยท {{ item.amount }} โ‚ฌ</span>
    </article></ng-template
  ></neu-data-view
>

State and events

items contains application data. Provide neuDataViewItem to render structured records; default rendering is not a domain-specific card. searchFields enables local matching and sortOptions names sortable fields. Omit total/currentPage for local paging; set both and handle pageChange to load a remote page. modeChange proposes the selected mode; apply it to mode. Templates replace content, not the paging engine.

Accessibility and keyboard

Tab reaches search, sorting, mode buttons and paginator. Enter/Space activates the buttons; custom item controls use their native behavior.

Key
Action
Tab Reach search, sorting, view-mode controls and pagination.
Enter Activate the focused button. Item templates retain their own control behaviour.
Space Activate the focused button. Item templates retain their own control behaviour.

API

Inputs, models and Outputs are extracted from the installed Core package. Named public types link to their definitions. Templates below include executable examples.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
currentPagenumber | undefinedundefined[currentPage]Applied one-based page for remote paging; omit it for local pagination.
emptyLabelstring'No items found'[emptyLabel]Label for empty collection. Translate it for your application.
itemsreadonly unknown[][][items]Applied item collection. Stable keys and accessors identify entries; the component does not mutate the array.
loadingbooleanfalse[loading]Displays the loading state while the application supplies data.
loadingLabelstring'Loading...'[loadingLabel]Message or announcement for loading options.
modeNeuDataViewMode'list'[mode]Display items in list or grid layout.
modeLabelsPartial<Record<NeuDataViewMode, string>>{}[modeLabels]Localized visible labels for list, grid and table modes.
modesreadonly NeuDataViewMode[]['list', 'grid', 'table'][modes]Ordered set of view modes offered by the switcher.
nextLabelstring'Next'[nextLabel]Label for next navigation. Translate it for your application.
pageSizenumber9[pageSize]Applied positive number of records per page.
paginationbooleantrue[pagination]Show page navigation for the collection.
paginationAriaLabelstring'Data view pagination'[paginationAriaLabel]Accessible name of the pagination region.
previousLabelstring'Previous'[previousLabel]Label for previous navigation. Translate it for your application.
searchablebooleantrue[searchable]Shows the built-in search field.
searchAriaLabelstring'Search items'[searchAriaLabel]Accessible label or placeholder of the search field.
searchFieldsreadonly string[][][searchFields]Record property paths included in the local global search.
searchPlaceholderstring'Search...'[searchPlaceholder]Accessible label or placeholder of the search field.
sortAriaLabelstring'Sort items'[sortAriaLabel]Accessible name of the collection sort selector.
sortOptionsreadonly NeuDataViewSortOption[][][sortOptions]Available sort entries with label, value naming the item field, and optional direction.
totalnumber | undefinedundefined[total]Total record count, not the number of pages.
trackBy(index: number, item: unknown) => unknown(index) => indexDerived default[trackBy]Stable identity function receiving absolute index and item.
viewAriaLabelstring'View mode'[viewAriaLabel]Accessible name of the view-mode button group.
viewSwitcherbooleantrue[viewSwitcher]Show the control that offers the configured view modes.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
modeChangeNeuDataViewMode(modeChange)="onModeChange($event)"Proposes a view mode. Apply it to mode to accept the change.
pageChangeNeuDataViewPageEvent(pageChange)="onPageChange($event)"Reports the selected one-based page and applied pageSize.
searchChangestring(searchChange)="onSearchChange($event)"Reports the current query; use it to request remote results when needed.
sortChangestring(sortChange)="onSortChange($event)"Reports the selected sort field.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuDataViewFooterDirectiveView example Public template directive (entrypoint)ng-template[neuDataViewFooter]
NeuDataViewHeaderDirectiveView example Public template directive (entrypoint)ng-template[neuDataViewHeader]
NeuDataViewItemDirectiveView example Public template directive (entrypoint)ng-template[neuDataViewItem]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

NeuDataViewItemDirective

NeuDataViewItemDirective

NeuDataViewItemDirective
  • AtlasEU ยท 240 โ‚ฌ
  • BirchUS ยท 180 โ‚ฌ
  • CedarEU ยท 420 โ‚ฌ

Events: 0

NeuDataViewHeaderDirective

NeuDataViewHeaderDirective

NeuDataViewHeaderDirective

Project directory

  • {"id":"atlas","name":"Atlas","region":"EU","amount":240}
  • {"id":"birch","name":"Birch","region":"US","amount":180}
  • {"id":"cedar","name":"Cedar","region":"EU","amount":420}

Events: 0

NeuDataViewFooterDirective

NeuDataViewFooterDirective

NeuDataViewFooterDirective
  • {"id":"atlas","name":"Atlas","region":"EU","amount":240}
  • {"id":"birch","name":"Birch","region":"US","amount":180}
  • {"id":"cedar","name":"Cedar","region":"EU","amount":420}

6 projects in this collection

Events: 0

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Use the supported public tokens listed below. Surrounding layout belongs to your application; validate the result in light and dark modes and narrow containers.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-primary-dark Dark brand shade; outline and ghost Button text in the light theme Shared by other Core consumers; scope the override. #005fcc
--neu-primary-fg Foreground drawn over the primary background Shared by other Core consumers; scope the override. #ffffff
--neu-primary-solid Solid brand action background Shared by other Core consumers; scope the override. #006ee6
--neu-primary-solid-fg Foreground of solid brand actions Shared by other Core consumers; scope the override. #ffffff
--neu-primary-solid-hover Hover background of solid brand actions Shared by other Core consumers; scope the override. #005fcc
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff