DataViews

import { DataViews } from '@wordpress/dataviews';

View on Storybook

View source on GitHub

PropsPermalink to this section

NameDefaultDescription
view Required

| ViewList | ViewGrid | ViewTable | ViewPickerGrid | ViewPickerTable | ViewPickerActivity | ViewActivity

onChangeView Required

( view: View ) => void

fields Required

Field< Item >[]

searchtrue

boolean

searchLabelundefined

string

actions[]

Action< Item >[]

data Required

Item[]

isLoadingfalse

boolean

paginationInfo Required

{ totalItems: number; totalPages: number; }

defaultLayouts{ table: {}, grid: {}, list: {} }

SupportedLayouts

selection

string[]

onChangeSelection

( items: string[] ) => void

onClickItem

( item: Item ) => void

renderItemLink

( props: { item: Item; } & ComponentProps< 'a' > ) => ReactElement

isItemClickable() => true

( item: Item ) => boolean

header

ReactNode

getItemLevel

( item: Item ) => number

children

ReactNode

config{ perPageSizes: [ 10, 20, 50, 100 ] }

{ perPageSizes: number[]; }

empty

ReactNode

onReset

( () => void ) | false

getItemId( item: ItemWithId ) => item.id

unknown

ExamplesPermalink to this section

Layout TablePermalink to this section

const LayoutTable = () => <DataViews
    containerHeight="auto"
    groupBy={false}
    groupByLabel
    hasClickableItems
    perPageSizes={[ 10, 25, 50, 100 ]}
    showMedia />;

Layout GridPermalink to this section

const LayoutGrid = () => <DataViews
    containerHeight="auto"
    groupBy={false}
    groupByLabel
    hasClickableItems
    perPageSizes={[ 10, 25, 50, 100 ]}
    showMedia />;

Layout ListPermalink to this section

const LayoutList = () => <DataViews
    containerHeight="auto"
    fullWidth={false}
    groupBy={false}
    groupByLabel
    hasClickableItems
    perPageSizes={[ 10, 25, 50, 100 ]}
    showMedia />;

Layout ActivityPermalink to this section

const LayoutActivity = () => <DataViews
    containerHeight="auto"
    fullWidth={false}
    groupBy={false}
    groupByLabel
    hasClickableItems
    perPageSizes={[ 10, 25, 50, 100 ]}
    showMedia />;

Layout CustomPermalink to this section

const LayoutCustom = () => <DataViews containerHeight="auto" />;

EmptyPermalink to this section

const Empty = () => <DataViews containerHeight="auto" customEmpty={false} isLoading={false} />;

Minimal UIPermalink to this section

const MinimalUI = () => <DataViews containerHeight="auto" />;

Free CompositionPermalink to this section

const FreeComposition = () => <DataViews containerHeight="auto" />;

With CardPermalink to this section

const WithCard = () => <DataViews containerHeight="auto" />;

Infinite ScrollPermalink to this section

const InfiniteScroll = () => <DataViews containerHeight="auto" />;