diff --git a/packages/dataviews/CHANGELOG.md b/packages/dataviews/CHANGELOG.md index 62601c114ad395..8122bdebfb2f3c 100644 --- a/packages/dataviews/CHANGELOG.md +++ b/packages/dataviews/CHANGELOG.md @@ -11,6 +11,7 @@ - DataViews table layout: only apply hover styles when bulk actions are available. [#73248](https://github.com/WordPress/gutenberg/pull/73248) - DataViews: add support for activity layout. [#72780](https://github.com/WordPress/gutenberg/pull/72780) - DataViews: Add grid keyboard navigation. [#72997](https://github.com/WordPress/gutenberg/pull/72997) +- DataViews: Introduce CSS var to enable users to apply a different background color to DataViews containers. [#73390](https://github.com/WordPress/gutenberg/pull/73390) - Field API: introduce the `format` prop to format the `date` field type. [#72999](https://github.com/WordPress/gutenberg/pull/72999) - Field API: fix display format for date. [#73538](https://github.com/WordPress/gutenberg/pull/73538) - Documentation: improve Edit component. [#73202](https://github.com/WordPress/gutenberg/pull/73202) diff --git a/packages/dataviews/README.md b/packages/dataviews/README.md index fea8209d9fc68c..ad578a082b61e0 100644 --- a/packages/dataviews/README.md +++ b/packages/dataviews/README.md @@ -459,6 +459,12 @@ Optional. Pass an object with a list of `perPageSizes` to control the available An element to display when the `data` prop is empty. Defaults to `
No results
`. +### Styling + +These are the CSS Custom Properties that can be used to tweak the appearance of the component: + +`--wp-dataviews-color-background`: sets the background color. + ### Composition modes The `DataViews` component supports two composition modes: diff --git a/packages/dataviews/src/components/dataviews/style.scss b/packages/dataviews/src/components/dataviews/style.scss index 32de6515cb89da..c434a2420bbc53 100644 --- a/packages/dataviews/src/components/dataviews/style.scss +++ b/packages/dataviews/src/components/dataviews/style.scss @@ -14,7 +14,7 @@ flex-direction: column; font-size: $default-font-size; line-height: $default-line-height; - background-color: inherit; + background-color: var(--wp-dataviews-color-background, $white); } .dataviews__view-actions, diff --git a/packages/dataviews/src/stories/dataviews.story.tsx b/packages/dataviews/src/stories/dataviews.story.tsx index 654fdbbd657050..ef30d02dd824b4 100644 --- a/packages/dataviews/src/stories/dataviews.story.tsx +++ b/packages/dataviews/src/stories/dataviews.story.tsx @@ -82,6 +82,11 @@ const defaultLayouts = { export const Default = ( { perPageSizes = [ 10, 25, 50, 100 ], hasClickableItems = true, + backgroundColor, +}: { + perPageSizes?: number[]; + hasClickableItems?: boolean; + backgroundColor?: string; } ) => { const [ view, setView ] = useState< View >( { ...DEFAULT_VIEW, @@ -94,28 +99,45 @@ export const Default = ( { return filterSortAndPaginate( data, view, fields ); }, [ view ] ); return ( -