import { DataViews } from '@wordpress/dataviews';
Links
View on Storybook
View source on GitHub
Props
| Name | Default | Description |
|---|
view Required | | | ViewList
| ViewGrid
| ViewTable
| ViewPickerGrid
| ViewPickerTable
| ViewPickerActivity
| ViewActivity
|
onChangeView Required | | ( view: View ) => void
|
fields Required | | Field< Item >[]
|
search | true | boolean
|
searchLabel | undefined | string
|
actions | [] | Action< Item >[]
|
data Required | | Item[]
|
isLoading | false | 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
|
Examples
Layout Table
const LayoutTable = () => <DataViews
containerHeight="auto"
groupBy={false}
groupByLabel
hasClickableItems
perPageSizes={[ 10, 25, 50, 100 ]}
showMedia />;
Layout Grid
const LayoutGrid = () => <DataViews
containerHeight="auto"
groupBy={false}
groupByLabel
hasClickableItems
perPageSizes={[ 10, 25, 50, 100 ]}
showMedia />;
Layout List
const LayoutList = () => <DataViews
containerHeight="auto"
fullWidth={false}
groupBy={false}
groupByLabel
hasClickableItems
perPageSizes={[ 10, 25, 50, 100 ]}
showMedia />;
Layout Activity
const LayoutActivity = () => <DataViews
containerHeight="auto"
fullWidth={false}
groupBy={false}
groupByLabel
hasClickableItems
perPageSizes={[ 10, 25, 50, 100 ]}
showMedia />;
Layout Custom
const LayoutCustom = () => <DataViews containerHeight="auto" />;
Empty
const Empty = () => <DataViews containerHeight="auto" customEmpty={false} isLoading={false} />;
Minimal UI
const MinimalUI = () => <DataViews containerHeight="auto" />;
Free Composition
const FreeComposition = () => <DataViews containerHeight="auto" />;
With Card
const WithCard = () => <DataViews containerHeight="auto" />;
const InfiniteScroll = () => <DataViews containerHeight="auto" />;