Skip to main content
Beta FeatureThis feature is currently in beta, and needs to be imported from @servicetitan/anvil2/beta.While we hope to minimize breaking changes, they may occur due to feedback we receive or other improvements. These will always be documented in the changelog and communicated in Slack.Please reach out in the #ask-designsystem channel with any questions or feedback!

Anatomy

Anatomy of DataTable The DataTable consists of several key structural elements:
  1. Header row – Contains column labels with optional sort indicators
  2. Header cell – Individual column header with label and optional sorting control
  3. Body rows – Data rows containing cell content
  4. Body cells – Individual data cells with formatted content
  5. Selection column – Optional checkbox column for row selection
  6. Expansion column – Optional expand/collapse control for sub-rows or sub-components. Shifts with content
  7. Footer row – Optional summary or aggregate data
  8. Pagination controls – Navigation for paginated data sets
  9. Pinned/locked column – Column that stays in place as user scrolls

Options

Sortable Columns

Enable sorting on columns to let users click the header and sort data in ascending or descending order. A sort indicator shows the current sort direction. Clicking a sortable column header cycles through: ascending → descending → unsorted. Only one column can be sorted at a time.
Sort StateIndicator
AscendingArrow up
DescendingArrow down
UnsortedNo indicator

Resizable Columns

Columns can optionally be made resizable. When this is turned on, users can resize columns by dragging the column border. Configure minimum and maximum widths to constrain resizing.

Pinned Columns

When tables have many columns requiring horizontal scroll, pin essential columns (like row identifiers or action columns). Pinned columns stay in place during horizontal scrolling, keeping important data visible.
PinningBehavior
LeftColumn sticks to left edge during horizontal scroll
RightColumn sticks to right edge during horizontal scroll

Grouped Columns

Group columns under a parent header to create a two-level header structure. Use this to organize related data. Please note that grouped columns cannot be pinned.

Pagination

When enabled, pagination controls display at the bottom of the table showing:
  • Current page range (e.g., “1-25 of 100”)
  • Navigation buttons for first, previous, next, and last page

Cell Types

The DataTable provides the following cell types:
ImageType of CellAlignment
Action cell typeActions cellLeft
Cell with chip/chipsCell with chip/chipsLeft
Cell with currencyCell with currencyRight
Custom cellCustom cellLeft
Cell with dateCell with dateRight
Cell with date-timeCell with date-timeRight
Empty cellEmpty cellLeft
Cell with numberCell with numberRight
Cell with percentageCell with percentageRight
Cell with textCell with textLeft
Cell with timeCell with timeRight

Behaviors

Editing

Columns can be made editable, which enables edit on hover per cell.

Row Selection

When selection is enabled, a checkbox column appears as the first column. Users can select individual rows or use the header checkbox to select all visible rows.
Selection StateAppearance
UnselectedEmpty checkbox
SelectedChecked checkbox
IndeterminateDash in checkbox (headers only, when some rows selected)

Row Expansion

Expand rows to show additional content in two ways:
  1. Sub-rows: Nested rows with the same column structure as the parent
  2. Sub-components: Custom content rendered below the parent row

Visual States

Header Cell States

Data table header states
StateDescription
DefaultNormal header appearance
Sorted (ascending/descending)Indicates active sort with direction indicator

Body Cell States

Default cell
Cell focused state
Cell editing state
Cell editing active
StateDescription
DefaultNormal cell appearance
FocusedFocus ring when cell is keyboard-focused
Edit hoverPencil icon visible to demonstrate an editable cell
EditingInput or dropdown visible for editable cells

Keyboard Interactions

Users can navigate the DataTable using the following keyboard controls:
KeyInteraction
TabMove focus between interactive elements
Arrow Up/DownNavigate between rows when focused on table
Arrow Left/RightNavigate between cells in a row
SpaceToggle row selection (when on checkbox)
EnterActivate sort (on header), enter edit mode (on editable cell)
F2Enter edit mode for editable cells
EscapeExit edit mode, discard changes

Accessibility

The DataTable implements accessibility features to ensure all users can interact with tabular data effectively:
  • Proper semantic HTML table structure (table, thead, tbody, tr, th, td)
  • ARIA attributes for row and column counts
  • Sortable headers announce sort state to screen readers
  • Selection checkboxes include descriptive labels
  • Expand/collapse buttons include aria-expanded and aria-controls
  • Loading states announced via aria-live regions
  • Focus management maintains logical keyboard navigation
  • Editable cells announce their editable state

Usage Guidelines

When to Use

Use the DataTable when displaying structured tabular data that requires any of the following:
  • Sorting – Users need to reorder data by different columns
  • Pagination – Data sets are too large to display all at once
  • Row selection – Users need to select rows for batch operations
  • Row expansion – Additional details need to be shown for individual rows
  • Inline editing – Users need to modify cell values directly
  • Column pinning – Key columns should remain visible during horizontal scroll

When Not to Use

Avoid using DataTable in these scenarios:
  • Simple lists – Use ListView or Listbox for simple selectable lists without tabular structure

Column Organization

Do
Position the most important columns first (left side) where users naturally look. Place identifier columns (like customer name or ID) before detail columns.
Don’t
Avoid hiding critical data in columns that require horizontal scrolling to view.

Batch Operations

Use row selection when users need to perform batch operations on multiple rows, such as:
  • Bulk delete
  • Bulk status changes
  • Export selected items
Do
  • - Provide clear feedback about how many items are selected
  • - Use the selection state to enable/disable batch action buttons
  • - Consider providing a “Select All” option in the header
Don’t
  • - Enable selection without providing actions that use the selection
  • - Hide the selection column after users have made selections

Sorting

Enable sorting only on columns where it provides value to users.
Do
  • - Enable sorting on text columns users might want to alphabetize
  • - Enable sorting on numeric columns for ranking or comparison
  • - Enable sorting on date columns for chronological ordering
  • - Provide default sorting when the data has a natural order
Don’t
  • - Enable sorting on columns with identical values
  • - Enable sorting on complex composite columns where sort order isn’t intuitive

Pagination

Choose Appropriate Page Sizes

Do
  • - Use 25 rows as the default
  • - Enable users to change page size with Pagination
  • - Match page size to typical use cases (smaller for quick scans, larger for detailed review)
Don’t
  • - Use very small page sizes (like 5 or 10) that require excessive navigation
  • - Use very large page sizes that cause performance issues

Row Expansion

Sub-Rows vs Sub-Components

Use Sub-RowsUse Sub-Components
Child data has same structure as parentChild content differs from table structure
Hierarchical data relationshipsDetail views, additional context
Grouped data (e.g., items in an order)Custom layouts (tabs, forms, lists)

Keep Expanded Content Focused

Do
  • - Show only relevant additional information in expanded areas
  • - Keep expanded content scannable and organized
Don’t
  • - Put entire page layouts in expanded rows
  • - Require users to expand rows to see essential information

Custom Body Cells

When none of the existing body cell types fit a use case, render custom components to body cells.

Alternatives

DataTable vs ListView

DataTableListView
Structured columns with headersSingle-column list of items
Built-in sorting by columnsNo built-in sorting
Pagination for large datasetsTypically shows all items
Row selection with checkboxesItem selection with checkboxes
Best for complex data relationshipsBest for simple lists of actions or selections
Choose DataTable when data has multiple attributes that benefit from column structure. Choose ListView when displaying a simple list of selectable items.
Last modified on January 23, 2026