Search the documentation

Type to search page titles, component names and descriptions.

    Data Display

    ResourceList

    Rows that each link to one record.

    import { ResourceList } from 'faifo-design'

    ResourceList lists records as rows with one keyboard link each, optional selection and paging. currentId marks the open item when the list is the master of a master-detail workspace.

    #When to use

    • Use it for a queue worked one item at a time.
    • Use a table when the reader compares values across columns.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Resource list

    One keyboard link per row with optional selection and paging composition.

    Show codeHide code
    import { Badge, ResourceList } from 'faifo-design'
    
    type OrderRow = {
      id: string
      customer: string
      total: string
      state: 'Ready' | 'Review' | 'Blocked'
    }
    
    const orders: OrderRow[] = [
      { id: 'SO-1042', customer: 'Công ty Ánh Dương', total: '18.450.000 ₫', state: 'Ready' },
      { id: 'SO-1041', customer: 'Khách sạn Mùa Hạ', total: '6.800.000 ₫', state: 'Review' },
      { id: 'SO-1039', customer: 'Nguyễn Minh Châu', total: '2.150.000 ₫', state: 'Blocked' },
    ]
    
    const toneOf = (state: OrderRow['state']) =>
      state === 'Ready' ? ('positive' as const) : state === 'Review' ? ('warning' as const) : ('danger' as const)
    
    export const Example = () => (
      <ResourceList
        label="Orders"
        rows={orders}
        id={(row) => row.id}
        href={(row) => `/orders/${row.id}`}
        primary={(row) => `${row.id} · ${row.customer}`}
        secondary={(row) => row.total}
        meta={(row) => <Badge label={row.state} tone={toneOf(row.state)} />}
        selectedIds={['SO-1042']}
        pager={{ summary: '1–3 of 148', nextHref: '/orders?page=2' }}
      />
    )

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #ResourceListComponent

    PropertyDescriptionTypeDefault
    labelrequired–string–
    rowsrequired–readonly Row[]–
    idrequired–(row: Row) => string–
    hrefrequired–(row: Row) => string–
    primaryrequired–(row: Row) => JSXChild–
    secondary–(row: Row) => JSXChild–
    meta–(row: Row) => JSXChild–
    selectedIds–readonly string[]–
    currentIdThe item open beside the list (master-detail): marked for sight and as aria-current.string | null–
    selectionName–string'ids'
    selectionForm–string–
    loading–boolean–
    loadingLabel–string'Loading resources'
    emptyTitle–string'No resources'
    emptyMessage–string'No results match this view.'
    pager–PagerBarProps–

    #Types

    #ResourceListProps

    The properties of ResourceList, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • resource-list
    • resource-list-item
    • resource-list-select
    • resource-list-link