Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e61bcc0
feat(EuiBasicTable): add `useEuiBasicTablePanelProps` beta utility to…
tkajtoch Jun 4, 2026
7afc7cb
feat(EuiBasicTable): add `panelled` prop that enables the panelled (b…
tkajtoch Jun 4, 2026
01ea8f4
refactor(EuiBasicTable): move PaginationBar component and its types t…
tkajtoch Jun 4, 2026
2cd9c29
[REVERT ME] Add panelled look and feel demo story
tkajtoch Jun 4, 2026
a38c529
chore: revert the PaginationBar rename and move to ensure 100% compat…
tkajtoch Jun 4, 2026
538f1ef
test: update snapshots
tkajtoch Jun 5, 2026
226129a
docs(EuiInMemoryTable): add `panelled` prop docs
tkajtoch Jun 5, 2026
ea5b7f6
chore: add changelog
tkajtoch Jun 5, 2026
9a79dff
Update packages/eui/changelogs/upcoming/9717.md
tkajtoch Jun 5, 2026
a210ca6
feat(EuiBasicTable): render the new wrapping div only when `panelled …
tkajtoch Jun 5, 2026
3ab0a8d
feat(EuiBasicTable): render the new wrapping div only when `panelled …
tkajtoch Jun 5, 2026
27aa83f
chore: expose `panelled` in Storybook
tkajtoch Jun 5, 2026
734905c
chore: connect `panelled` switch to the storybook control
tkajtoch Jun 5, 2026
cdc4434
chore: add panelled story to EuiBasicTable
tkajtoch Jun 5, 2026
dab725a
chore: simplify panel styles
tkajtoch Jun 5, 2026
9f8dc73
chore: add VRTs
tkajtoch Jun 5, 2026
58285bb
chore: move `panelled` control to EuiBasicTable-inherited props category
tkajtoch Jun 5, 2026
19bff06
chore: update changelog
tkajtoch Jun 5, 2026
3afe50b
docs(EuiInMemoryTable): add custom panels example
tkajtoch Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/eui/changelogs/upcoming/9717.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added a new optional `panelled` prop (boolean, defaults to `false`) to `EuiInMemoryTable` and `EuiBasicTable` that enables the panelled layout
- Added `useEuiBasicTablePanelProps` utility hook that provides props and styles necessary to create custom table panels such as toolbars
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,9 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
>
π˜‚π˜‚
</span>
<div>
<div
class="euiSpacer euiSpacer--m emotion-euiSpacer-m"
/>
<div
class="css-1gb0nlc-root-PaginationBar"
>
<div
class="euiFlexGroup eui-xScroll emotion-euiFlexGroup-wrap-s-spaceBetween-center-row"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PaginationBar renders 1`] = `
<div>
<div
class="euiSpacer euiSpacer--m emotion-euiSpacer-m"
/>
<div
class="css-1gb0nlc-root-PaginationBar"
>
<div
class="euiFlexGroup eui-xScroll emotion-euiFlexGroup-wrap-s-spaceBetween-center-row"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const meta: Meta<EuiBasicTableProps<User>> = {
noItemsMessage: '',
scrollableInline: false,
stickyScrollbar: false,
panelled: false,
},
};
moveStorybookControlsToCategory(
Expand Down Expand Up @@ -616,3 +617,10 @@ export const Scrollable: Story = {
columns: scrollableColumns,
},
};

export const Panelled: Story = {
args: {
...Playground.args,
panelled: true,
},
};
65 changes: 64 additions & 1 deletion packages/eui/src/components/basic_table/basic_table.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import {
euiCantAnimate,
highContrastModeStyles,
preventForcedColors,
euiMinBreakpoint,
} from '../../global_styling';
import { UseEuiTheme } from '../../services';
import type { UseEuiTheme } from '../../services';
import type { EuiTableProps } from '../table';
import { EUI_BASIC_TABLE_PANEL_CLASS_NAME } from './use_panel_props';

const tableLoadingLine = keyframes`
from {
Expand Down Expand Up @@ -73,6 +76,66 @@ export const euiBasicTableBodyLoading = (euiThemeContext: UseEuiTheme) => {
`;
};

/**
* @internal
*/
export const euiBasicTableWrapperPanelledStyles =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is structured this way because EuiBasicTable is a class component and adding a RenderWithEuiTheme wrapper as the first node would be rather heavy in terms of snapshot changes needed. I tried using the withEuiTheme HOC but that resulted in something similar.

We'll rewrite these table components to function components someday...

(responsiveBreakpoint: EuiTableProps['responsiveBreakpoint']) =>
(theme: UseEuiTheme) => {
const { euiTheme } = theme;

const styles = css`
border: ${euiTheme.border.thin};
border-block-end-width: 0;
/* Offset for the wrapper border to be rendered without being obstructed
* by the child EuiTable's border */
padding-block-start: ${euiTheme.border.width.thin};
border-radius: ${euiTheme.border.radius.medium};

.euiTable {
border-radius: ${euiTheme.border.radius.medium};
}

/* Reset top border radius when there are panels above. */
.${EUI_BASIC_TABLE_PANEL_CLASS_NAME} + .euiBasicTable & {
border-start-start-radius: 0;
border-start-end-radius: 0;

.euiTable {
border-start-start-radius: 0;
border-start-end-radius: 0;
}
}

/* Reset bottom border radius when there are panels below.
* &:not(:last-child) detects whether the pagination bar is displayed */
&:not(:last-child),
&:has(+ .${EUI_BASIC_TABLE_PANEL_CLASS_NAME}) {
border-end-start-radius: 0;
border-end-end-radius: 0;

.euiTable {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
}
`;

if (responsiveBreakpoint === true) {
return null;
}

if (!responsiveBreakpoint) {
return styles;
}

return css`
${euiMinBreakpoint(theme, responsiveBreakpoint)} {
${styles}
}
`;
};

// Fix to make the loading indicator position correctly in Safari
// For whatever annoying reason, Safari doesn't respect `position: relative;`
// on `tbody` without `position: relative` on the parent `table`
Expand Down
37 changes: 35 additions & 2 deletions packages/eui/src/components/basic_table/basic_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { fireEvent } from '@testing-library/react';
import { render, screen } from '../../test/rtl';
import { render, renderHook, screen } from '../../test/rtl';
import { requiredProps } from '../../test';
import { shouldRenderCustomStyles } from '../../test/internal';

Expand All @@ -19,7 +19,7 @@ import {
getItemId,
} from './basic_table';

import { SortDirection } from '../../services';
import { SortDirection, useEuiTheme } from '../../services';
import {
EuiTableFieldDataColumnType,
EuiTableActionsColumnType,
Expand Down Expand Up @@ -1002,4 +1002,37 @@ describe('EuiBasicTable', () => {

expect(container.firstChild).toMatchSnapshot();
});

describe('panelled', () => {
it('renders the panelled wrapper when `panelled = true`', () => {
const props = {
...requiredProps,
items: basicItems,
columns: basicColumns,
panelled: true,
};
const { getByTestSubject } = render(<EuiBasicTable {...props} />);
const { euiTheme } = renderHook(useEuiTheme).result.current;

const wrapper = getByTestSubject('euiBasicTablePanelledWrapper');
expect(wrapper).toBeInTheDocument();

expect(wrapper).toHaveStyleRule('border', euiTheme.border.thin);
expect(wrapper).toHaveStyleRule(
'border-radius',
euiTheme.border.radius.medium
);
});

it('defaults to `panelled = false`', () => {
const props = {
...requiredProps,
items: basicItems,
columns: basicColumns,
};

const { queryByTestSubject } = render(<EuiBasicTable {...props} />);
expect(queryByTestSubject('euiBasicTablePanelledWrapper')).toBeNull();
});
});
});
42 changes: 39 additions & 3 deletions packages/eui/src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import { euiTableCaptionStyles } from '../table/table.styles';
import { CollapsedItemActions } from './collapsed_item_actions';
import { ExpandedItemActions } from './expanded_item_actions';

import { Pagination, PaginationBar } from './pagination_bar';
import { PaginationBar, type Pagination } from './pagination_bar';
import { EuiIcon } from '../icon';
import { EuiScreenReaderOnly } from '../accessibility';
import { EuiI18n } from '../i18n';
Expand All @@ -80,6 +80,7 @@ import { EuiTableSortMobileProps } from '../table/mobile/table_sort_mobile';

import {
euiBasicTableBodyLoading,
euiBasicTableWrapperPanelledStyles,
safariLoadingWorkaround,
} from './basic_table.styles';
import { EuiToolTip } from '../tool_tip';
Expand Down Expand Up @@ -248,6 +249,15 @@ interface BasicTableProps<T extends object>
* Provides an infinite loading indicator
*/
loading?: boolean;
/**
* Enable the panelled style of the table.
*
* Panelled style adds contrast between the table navigation controls
* and table content itself. It should be used in tables rendered outside
* EUI containers like `<EuiPanel>` or `<EuiFlyout>`.
* @default false
*/
panelled?: boolean;
Comment thread
mgadewoll marked this conversation as resolved.
Resolved
/**
* Message to display if table is empty
*/
Expand Down Expand Up @@ -526,6 +536,7 @@ export class EuiBasicTable<T extends object = any> extends Component<
scrollableInline,
stickyScrollbar,
stickyHeader,
panelled,
...rest
} = this.props;

Expand Down Expand Up @@ -556,9 +567,10 @@ export class EuiBasicTable<T extends object = any> extends Component<
scrollableInline,
stickyScrollbar,
stickyHeader,
panelled,
} = this.props;

return (
const content = (
<>
<EuiTableHeaderMobile responsiveBreakpoint={responsiveBreakpoint}>
{this.renderSelectAll(true)}
Expand All @@ -584,6 +596,21 @@ export class EuiBasicTable<T extends object = any> extends Component<
</OverrideCopiedTabularContent>
</>
);

if (panelled) {
return (
<div
css={
panelled && euiBasicTableWrapperPanelledStyles(responsiveBreakpoint)
}
data-test-subj="euiBasicTablePanelledWrapper"
>
{content}
</div>
);
}

return content;
}

renderTableMobileSort() {
Expand Down Expand Up @@ -1437,7 +1464,14 @@ export class EuiBasicTable<T extends object = any> extends Component<
}

renderPaginationBar() {
const { error, pagination, tableCaption, onChange } = this.props;
const {
error,
pagination,
tableCaption,
onChange,
panelled,
responsiveBreakpoint,
} = this.props;
if (!error && pagination && pagination.totalItemCount > 0) {
if (!onChange) {
throw new Error(`The Basic Table is configured with pagination but [onChange] is
Expand All @@ -1453,6 +1487,8 @@ export class EuiBasicTable<T extends object = any> extends Component<
{(tablePagination: string) => (
<PaginationBar
pagination={pagination}
panelled={panelled}
responsiveBreakpoint={responsiveBreakpoint}
onPageSizeChange={this.onPageSizeChange.bind(this)}
onPageChange={this.onPageChange.bind(this)}
aria-controls={this.tableId}
Expand Down
Loading