Search the documentation

Type to search page titles, component names and descriptions.

    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 Tree for navigation through categories or locations.
    • Reserve TreeGrid for 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.

    AccountBalance
    100 · Assets120.000.000 ₫
    110 · Cash42.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

    PropertyDescriptionTypeDefault
    labelrequired–string–
    nodesrequired–readonly TreeNode[]–

    #TreeGridComponent

    PropertyDescriptionTypeDefault
    labelrequired–string–
    rowsrequired–readonly TreeGridRow<Row>[]–
    idrequired–(row: Row) => string–
    primaryrequired–(row: Row) => JSXChild–
    primaryLabelLocalized heading for the hierarchy column.string'Name'
    columnsrequired–readonly TreeGridColumn<Row>[]–
    rowHrefOpens the row's record: the whole row becomes one link, like DataTable.rowHref.(row: Row) => string–

    #Types

    #TreeGridColumn

    PropertyDescriptionTypeDefault
    keyrequired–string–
    labelrequired–string–
    cellrequired–(row: Row) => JSXChild–

    #TreeGridRow

    PropertyDescriptionTypeDefault
    rowrequired–Row–
    levelrequired–number–
    expanded–boolean–
    hasChildren–boolean–

    #TreeNode

    PropertyDescriptionTypeDefault
    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.

    • tree
    • tree-item
    • tree-link
    • tree-grid
    • tree-grid-row
    • tree-grid-link