= ({
'euiTableCellContent--alignRight': align === RIGHT_ALIGNMENT,
'euiTableCellContent--alignCenter': align === CENTER_ALIGNMENT,
});
+ const styleObj = resolveWidthAsStyle(style, width);
return (
-
+ |
{children}
diff --git a/src/components/table/table_header_cell.test.tsx b/src/components/table/table_header_cell.test.tsx
index 34e8a366dc4..e5431519c35 100644
--- a/src/components/table/table_header_cell.test.tsx
+++ b/src/components/table/table_header_cell.test.tsx
@@ -33,3 +33,35 @@ describe('align', () => {
expect(render(component)).toMatchSnapshot();
});
});
+
+describe('width and style', () => {
+ test('accepts style attribute', () => {
+ const component = (
+ Test
+ );
+
+ expect(render(component)).toMatchSnapshot();
+ });
+
+ test('accepts width attribute', () => {
+ const component = Test;
+
+ expect(render(component)).toMatchSnapshot();
+ });
+
+ test('accepts width attribute as number', () => {
+ const component = Test;
+
+ expect(render(component)).toMatchSnapshot();
+ });
+
+ test('resolves style and width attribute', () => {
+ const component = (
+
+ Test
+
+ );
+
+ expect(render(component)).toMatchSnapshot();
+ });
+});
diff --git a/src/components/table/table_header_cell.tsx b/src/components/table/table_header_cell.tsx
index e743907d028..330cbc9bc61 100644
--- a/src/components/table/table_header_cell.tsx
+++ b/src/components/table/table_header_cell.tsx
@@ -8,6 +8,7 @@ import classNames from 'classnames';
import { EuiScreenReaderOnly } from '../accessibility';
import { CommonProps, NoArgCallback } from '../common';
import { EuiIcon } from '../icon';
+import { resolveWidthAsStyle } from './utils';
import {
HorizontalAlignment,
@@ -56,6 +57,7 @@ type Props = CommonProps &
};
onSort?: NoArgCallback;
scope?: TableHeaderCellScope;
+ width?: string | number;
};
export const EuiTableHeaderCell: FunctionComponent = ({
@@ -73,6 +75,8 @@ export const EuiTableHeaderCell: FunctionComponent = ({
// Soon to be deprecated for {...mobileOptions}
isMobileHeader,
hideForMobile,
+ style,
+ width,
...rest
}) => {
const classes = classNames('euiTableHeaderCell', className, {
@@ -85,6 +89,8 @@ export const EuiTableHeaderCell: FunctionComponent = ({
'euiTableCellContent--alignCenter': align === CENTER_ALIGNMENT,
});
+ const styleObj = resolveWidthAsStyle(style, width);
+
if (onSort) {
const buttonClasses = classNames('euiTableHeaderButton', {
'euiTableHeaderButton-isSorted': isSorted,
@@ -114,6 +120,7 @@ export const EuiTableHeaderCell: FunctionComponent = ({
role="columnheader"
aria-sort={ariaSortValue}
aria-live="polite"
+ style={styleObj}
{...rest}>
|