Examples › Scrollable vs. auto-height
Toggle the switch below to see the difference between a scrollable and an auto-height DataTable:
The DataTable component embeds a Mantine ScrollArea and has a default height of '100%'.
Thus, setting the component height or placing it inside a height-restricted container will make it vertically scrollable, with a sticky header. Otherwise, the table simply grows to fit its content.
Using minHeight and maxHeight
Besides height, you can also set minHeight and maxHeight (as numbers in pixels or CSS size strings). They’re particularly useful in combination with a relative height— for instance, the table below takes up half of the browser window height, but never less than 200 and never more than 400 pixels (resize the browser window to see it in action):
minHeight is also useful to leave enough room for the empty state indicator or the loader when an auto-height table has few or no records.
You can also set a maxHeight without a height: the table will grow with its content and become vertically scrollable once the content exceeds the maximum height.
Customizing the underlying ScrollArea
You can customize the underlying scroll area by passing scrollAreaProps to the DataTable component. It accepts Mantine ScrollArea props such as type, scrollbarSize, scrollHideDelay or offsetScrollbars (except classNames, styles and onScrollPositionChange, which are used internally; to get a reference to the scroll viewport, use the scrollViewportRef property instead of viewportRef). For instance, here’s how you could hide the scrollbars:
Here is the result:
To react to scrolling, use the onScroll, onScrollToTop, onScrollToBottom, onScrollToLeft and onScrollToRight callbacks (see the infinite scrolling example). To scroll the table programmatically, use the scrollViewportRef property to get hold of the scrollable viewport element (see scrolling a row into view).
Head over to the next example to discover more features.












