Data Display
Tree
Hierarchies as native links, with a tabular form.
import { Tree, TreeGrid } from 'faifo-design'Tree shows a hierarchy whose nodes are links. TreeGrid adds columns for hierarchies whose rows
carry independent values.
#When to use
- Use
Treefor navigation through categories or locations. - Reserve
TreeGridfor genuinely tabular hierarchies such as a chart of accounts.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Tree and tree grid
Hierarchy uses native links; tabular hierarchy is reserved for independent multi-column data.
| Account | Balance |
|---|---|
| 100 · Assets | 120.000.000 ₫ |
| 110 · Cash | 42.000.000 ₫ |
Show codeHide code
import { Grid, Tree, TreeGrid } from 'faifo-design'
export const Example = () => (
<Grid
columns={2}
items={[
<Tree
label="Workspace pages"
nodes={[
{
id: 'sales',
label: 'Sales',
expanded: true,
children: [
{ id: 'orders', label: 'Orders', href: '/orders', active: true },
{ id: 'reports', label: 'Reports', href: '/reports' },
],
},
]}
/>,
<TreeGrid
label="Account hierarchy"
primaryLabel="Account"
rows={[
{
row: { id: '100', name: 'Assets', balance: '120.000.000 ₫' },
level: 1,
hasChildren: true,
},
{ row: { id: '110', name: 'Cash', balance: '42.000.000 ₫' }, level: 2 },
]}
id={(row) => row.id}
primary={(row) => `${row.id} · ${row.name}`}
rowHref={(row) => `#account-${row.id}`}
columns={[{ key: 'balance', label: 'Balance', cell: (row) => row.balance }]}
/>,
]}
/>
)#API
Generated from the package source. A property without a description has none in the source yet.
#TreeComponent
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | – | string | – |
nodesrequired | – | readonly TreeNode[] | – |
#TreeGridComponent
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | – | string | – |
rowsrequired | – | readonly TreeGridRow<Row>[] | – |
idrequired | – | (row: Row) => string | – |
primaryrequired | – | (row: Row) => JSXChild | – |
primaryLabel | Localized heading for the hierarchy column. | string | 'Name' |
columnsrequired | – | readonly TreeGridColumn<Row>[] | – |
rowHref | Opens the row's record: the whole row becomes one link, like DataTable.rowHref. | (row: Row) => string | – |
#Types
#TreeGridColumn
| Property | Description | Type | Default |
|---|---|---|---|
keyrequired | – | string | – |
labelrequired | – | string | – |
cellrequired | – | (row: Row) => JSXChild | – |
#TreeGridRow
| Property | Description | Type | Default |
|---|---|---|---|
rowrequired | – | Row | – |
levelrequired | – | number | – |
expanded | – | boolean | – |
hasChildren | – | boolean | – |
#TreeNode
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | JSXChild | – |
href | – | string | – |
active | – | boolean | – |
expanded | – | boolean | – |
children | – | readonly TreeNode[] | – |
#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
treetree-itemtree-linktree-gridtree-grid-rowtree-grid-link