Examples › Asynchronous data loading

Customize the loader properties in the interactive example below:

Name
Street address
City
State
No records

Code:

return (
  <DataTable
    withTableBorder
    minHeight={180}
    columns={[{ accessor: 'name' }, { accessor: 'streetAddress' }, { accessor: 'city' }, { accessor: 'state' }]}
    records={records}
    fetching={fetching}
  />
);

Simply set a fetching: true property to the DataTable to indicate data loading state by overlaying a Loader over the DataTable rows.
You can customize the loader appearance with:

  • loaderSize: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
  • loaderType: 'oval' | 'bars' | 'dots'
  • loaderColor
    The loader color.
  • loaderBackgroundBlur: number
    The loader background blur, in pixels. No blur by default.
return (
  <DataTable
    withTableBorder
    minHeight={180}
    columns={[{ accessor: 'name' }, { accessor: 'streetAddress' }, { accessor: 'city' }, { accessor: 'state' }]}
    records={records}
    fetching={fetching}
    loaderType={customizeLoaderType ? loaderType : undefined}
    loaderSize={customizeLoaderSize ? loaderSize : undefined}
    loaderColor={customizeLoaderColor ? loaderColor : undefined}
    loaderBackgroundBlur={customizeLoaderBackgroundBlur ? loaderBackgroundBlur : undefined}
  />
);

Using a custom loader component

If you’re not happy with standard Mantine Loader types, you can pass your own component to the customLoader property.
In this case, do not set loaderSize, loaderType and loaderColor properties.

Name
Street address
City
State
No records

Here is the code:

return (
  <DataTable
    withTableBorder
    minHeight={180}
    columns={[{ accessor: 'name' }, { accessor: 'streetAddress' }, { accessor: 'city' }, { accessor: 'state' }]}
    records={records}
    fetching={fetching}
    customLoader={
      <svg width={80} height={80} viewBox="0 0 40 40">
        {/* some svg elements... */}
      </svg>
    }
  />
);

Head over to the next example to discover more features.