Introducing PrimeReact v11-alpha 🎉Discover Now

DataView

An unstyled data container component for building list and grid layouts with full control over presentation.

Build fully custom data presentation layouts with complete control over structure and styling.

5 products
Bamboo Watch
Accessories
$65
Black Watch
Accessories
$72
Blue Band
Fitness
$79
Blue T-Shirt
Clothing
$29
Gaming Set
Electronics
$299
basic-demo

Pre-styled Versions

Choose a pre-styled library to use DataView with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with sub-components: Root, Header, Content, Footer, Empty
  • Layout state management with controlled and uncontrolled modes
  • Locale-aware sort utility for ordering data by field
  • Layout value reflected in data-layout attribute for CSS-driven layout switching

Usage#

import { DataView } from 'primereact/dataview';
<DataView.Root>
    <DataView.Header></DataView.Header>
    <DataView.Content></DataView.Content>
    <DataView.Footer></DataView.Footer>
    <DataView.Empty></DataView.Empty>
</DataView.Root>

Behavior#

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<DataView.Root as="section"></DataView.Root>
<DataView.Content as="ul"></DataView.Content>

Default elements: Root=div, Header=div, Content=div, Footer=div, Empty=div.

Render Function Children#

Root accepts a render function as children, providing access to the component instance.

<DataView.Root>{(instance) => <span>Layout: {instance.state.layout}</span>}</DataView.Root>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

/* Select a part to see its CSS selector for custom styling */

API#

DataViewRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DataViewRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DataViewRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDataViewRootInstance—
The instance to pass to the component.
ptSafeRecord<DataViewRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DataViewRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
layoutstring—
The controlled layout value.
defaultLayoutstring—
The default layout value for uncontrolled mode.
onLayoutChange(event: useDataViewLayoutChangeEvent) => void—
Callback invoked when the layout changes.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"dataview"
data-part"root"
data-layoutCurrent layout value

Defines passthrough(pt) options of DataViewRoot component.

labeltypedescription
rootDataViewRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DataViewHeader#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DataViewHeaderInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DataViewHeaderInstance) => string)—
The class name to apply to the component.
asReactNode—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDataViewHeaderInstance—
The instance to pass to the component.
ptSafeRecord<DataViewHeaderPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DataViewHeaderInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"dataview"
data-part"header"

Defines passthrough(pt) options of DataViewHeader component.

labeltypedescription
rootDataViewHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DataViewContent#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DataViewContentInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DataViewContentInstance) => string)—
The class name to apply to the component.
asReactNode—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDataViewContentInstance—
The instance to pass to the component.
ptSafeRecord<DataViewContentPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DataViewContentInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"dataview"
data-part"content"

Defines passthrough(pt) options of DataViewContent component.

labeltypedescription
rootDataViewContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DataViewFooter#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DataViewFooterInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DataViewFooterInstance) => string)—
The class name to apply to the component.
asReactNode—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDataViewFooterInstance—
The instance to pass to the component.
ptSafeRecord<DataViewFooterPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DataViewFooterInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"dataview"
data-part"footer"

Defines passthrough(pt) options of DataViewFooter component.

labeltypedescription
rootDataViewFooterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DataViewEmpty#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DataViewEmptyInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DataViewEmptyInstance) => string)—
The class name to apply to the component.
asReactNode—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDataViewEmptyInstance—
The instance to pass to the component.
ptSafeRecord<DataViewEmptyPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DataViewEmptyInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"dataview"
data-part"empty"

Defines passthrough(pt) options of DataViewEmpty component.

labeltypedescription
rootDataViewEmptyPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

DataView uses semantic div containers. Add role and aria-label attributes as needed for the specific data layout.

<DataView.Root aria-label="Product list">
    <DataView.Content role="list"></DataView.Content>
</DataView.Root>

Keyboard Support#

Not applicable. DataView is a presentational container — keyboard interaction depends on the content rendered inside.