-
+
+
@@ -58,6 +55,6 @@ export default function SimpleTable() {
))}
-
+
);
}
diff --git a/docs/src/pages/components/tables/SimpleTable.tsx b/docs/src/pages/components/tables/SimpleTable.tsx
index 372dd709621e70..f182b843ad4f53 100644
--- a/docs/src/pages/components/tables/SimpleTable.tsx
+++ b/docs/src/pages/components/tables/SimpleTable.tsx
@@ -3,15 +3,12 @@ import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
+import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
const useStyles = makeStyles({
- root: {
- width: '100%',
- overflowX: 'auto',
- },
table: {
minWidth: 650,
},
@@ -33,7 +30,7 @@ export default function SimpleTable() {
const classes = useStyles();
return (
-
+
@@ -58,6 +55,6 @@ export default function SimpleTable() {
))}
-
+
);
}
diff --git a/docs/src/pages/components/tables/SpanningTable.js b/docs/src/pages/components/tables/SpanningTable.js
index 5151e7829b9d1f..7dc1b226758d5b 100644
--- a/docs/src/pages/components/tables/SpanningTable.js
+++ b/docs/src/pages/components/tables/SpanningTable.js
@@ -3,6 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
+import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
@@ -10,10 +11,6 @@ import Paper from '@material-ui/core/Paper';
const TAX_RATE = 0.07;
const useStyles = makeStyles({
- root: {
- width: '100%',
- overflowX: 'auto',
- },
table: {
minWidth: 700,
},
@@ -50,7 +47,7 @@ export default function SpanningTable() {
const classes = useStyles();
return (
-
+
@@ -92,6 +89,6 @@ export default function SpanningTable() {
-
+
);
}
diff --git a/docs/src/pages/components/tables/SpanningTable.tsx b/docs/src/pages/components/tables/SpanningTable.tsx
index 28a86dd358b628..b3b82c0fe5f0eb 100644
--- a/docs/src/pages/components/tables/SpanningTable.tsx
+++ b/docs/src/pages/components/tables/SpanningTable.tsx
@@ -3,6 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
+import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';
@@ -10,10 +11,6 @@ import Paper from '@material-ui/core/Paper';
const TAX_RATE = 0.07;
const useStyles = makeStyles({
- root: {
- width: '100%',
- overflowX: 'auto',
- },
table: {
minWidth: 700,
},
@@ -57,7 +54,7 @@ export default function SpanningTable() {
const classes = useStyles();
return (
-
+
@@ -98,6 +95,6 @@ export default function SpanningTable() {
-
+
);
}
diff --git a/docs/src/pages/components/tables/StickyHeadTable.js b/docs/src/pages/components/tables/StickyHeadTable.js
index 3c53bc6fa4e06d..697d3e3fc8c9f6 100644
--- a/docs/src/pages/components/tables/StickyHeadTable.js
+++ b/docs/src/pages/components/tables/StickyHeadTable.js
@@ -4,6 +4,7 @@ import Paper from '@material-ui/core/Paper';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
+import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TablePagination from '@material-ui/core/TablePagination';
import TableRow from '@material-ui/core/TableRow';
@@ -61,9 +62,8 @@ const useStyles = makeStyles({
root: {
width: '100%',
},
- tableWrapper: {
+ container: {
maxHeight: 440,
- overflow: 'auto',
},
});
@@ -83,7 +83,7 @@ export default function StickyHeadTable() {
return (
-
+
@@ -115,7 +115,7 @@ export default function StickyHeadTable() {
})}
-
+
-
+
@@ -131,7 +131,7 @@ export default function StickyHeadTable() {
})}
-
+
{
+ component?: React.ElementType;
+}
+
+export type TableContainerBaseProps = React.HTMLAttributes;
+
+export type TableContainerClassKey = 'root';
+
+declare const TableContainer: React.ComponentType;
+
+export default TableContainer;
diff --git a/packages/material-ui/src/TableContainer/TableContainer.js b/packages/material-ui/src/TableContainer/TableContainer.js
new file mode 100644
index 00000000000000..c8f55aa8f47ac2
--- /dev/null
+++ b/packages/material-ui/src/TableContainer/TableContainer.js
@@ -0,0 +1,41 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import clsx from 'clsx';
+import withStyles from '../styles/withStyles';
+
+export const styles = {
+ /* Styles applied to the root element. */
+ root: {
+ width: '100%',
+ overflowX: 'auto',
+ },
+};
+
+const TableContainer = React.forwardRef(function TableContainer(props, ref) {
+ const { classes, className, component: Component = 'div', ...other } = props;
+
+ return ;
+});
+
+TableContainer.propTypes = {
+ /**
+ * The table itself, normally ``
+ */
+ children: PropTypes.node,
+ /**
+ * Override or extend the styles applied to the component.
+ * See [CSS API](#css) below for more details.
+ */
+ classes: PropTypes.object.isRequired,
+ /**
+ * @ignore
+ */
+ className: PropTypes.string,
+ /**
+ * The component used for the root node.
+ * Either a string to use a DOM element or a component.
+ */
+ component: PropTypes.elementType,
+};
+
+export default withStyles(styles, { name: 'MuiTableContainer' })(TableContainer);
diff --git a/packages/material-ui/src/TableContainer/TableContainer.test.js b/packages/material-ui/src/TableContainer/TableContainer.test.js
new file mode 100644
index 00000000000000..3d50d34fdd4adc
--- /dev/null
+++ b/packages/material-ui/src/TableContainer/TableContainer.test.js
@@ -0,0 +1,23 @@
+import React from 'react';
+import { createMount, getClasses } from '@material-ui/core/test-utils';
+import describeConformance from '../test-utils/describeConformance';
+import TableContainer from './TableContainer';
+
+describe('', () => {
+ let mount;
+ let classes;
+
+ before(() => {
+ mount = createMount({ strict: true });
+ classes = getClasses();
+ });
+
+ describeConformance(, () => ({
+ classes,
+ inheritComponent: 'div',
+ mount,
+ refInstanceof: window.HTMLDivElement,
+ testComponentPropWith: 'span',
+ after: () => mount.cleanUp(),
+ }));
+});
diff --git a/packages/material-ui/src/TableContainer/index.d.ts b/packages/material-ui/src/TableContainer/index.d.ts
new file mode 100644
index 00000000000000..16d9e906fa092b
--- /dev/null
+++ b/packages/material-ui/src/TableContainer/index.d.ts
@@ -0,0 +1,2 @@
+export { default } from './TableContainer';
+export * from './TableContainer';
diff --git a/packages/material-ui/src/TableContainer/index.js b/packages/material-ui/src/TableContainer/index.js
new file mode 100644
index 00000000000000..891964a7c8afa3
--- /dev/null
+++ b/packages/material-ui/src/TableContainer/index.js
@@ -0,0 +1 @@
+export { default } from './TableContainer';
diff --git a/packages/material-ui/src/index.d.ts b/packages/material-ui/src/index.d.ts
index a11cf436726f6a..62c46df0b06fb3 100644
--- a/packages/material-ui/src/index.d.ts
+++ b/packages/material-ui/src/index.d.ts
@@ -350,6 +350,9 @@ export * from './TableBody';
export { default as TableCell } from './TableCell';
export * from './TableCell';
+export { default as TableContainer } from './TableContainer';
+export * from './TableContainer';
+
export { default as TableFooter } from './TableFooter';
export * from './TableFooter';
diff --git a/packages/material-ui/src/index.js b/packages/material-ui/src/index.js
index 1d8e32a4b52af4..763e94632cefe6 100644
--- a/packages/material-ui/src/index.js
+++ b/packages/material-ui/src/index.js
@@ -298,6 +298,9 @@ export * from './TableBody';
export { default as TableCell } from './TableCell';
export * from './TableCell';
+export { default as TableContainer } from './TableContainer';
+export * from './TableContainer';
+
export { default as TableFooter } from './TableFooter';
export * from './TableFooter';
diff --git a/packages/material-ui/src/styles/overrides.d.ts b/packages/material-ui/src/styles/overrides.d.ts
index bdd0472b06306d..12f6625d785434 100644
--- a/packages/material-ui/src/styles/overrides.d.ts
+++ b/packages/material-ui/src/styles/overrides.d.ts
@@ -83,6 +83,7 @@ import { SwitchClassKey } from '../Switch';
import { TabClassKey } from '../Tab';
import { TableBodyClassKey } from '../TableBody';
import { TableCellClassKey } from '../TableCell';
+import { TableContainerClassKey } from '../TableContainer';
import { TableClassKey } from '../Table';
import { TableFooterClassKey } from '../TableFooter';
import { TableHeadClassKey } from '../TableHead';
@@ -185,6 +186,7 @@ export interface ComponentNameToClassKey {
MuiTable: TableClassKey;
MuiTableBody: TableBodyClassKey;
MuiTableCell: TableCellClassKey;
+ MuiTableContainer: TableContainerClassKey;
MuiTableFooter: TableFooterClassKey;
MuiTableHead: TableHeadClassKey;
MuiTablePagination: TablePaginationClassKey;
diff --git a/packages/material-ui/src/styles/props.d.ts b/packages/material-ui/src/styles/props.d.ts
index 607c7e951a52da..1ea5598e0222af 100644
--- a/packages/material-ui/src/styles/props.d.ts
+++ b/packages/material-ui/src/styles/props.d.ts
@@ -84,6 +84,7 @@ import { SvgIconProps } from '../SvgIcon';
import { SwitchProps } from '../Switch';
import { TableBodyProps } from '../TableBody';
import { TableCellProps } from '../TableCell';
+import { TableContainerProps } from '../TableContainer';
import { TableHeadProps } from '../TableHead';
import { TablePaginationProps } from '../TablePagination';
import { TableProps } from '../Table';
@@ -190,6 +191,7 @@ export interface ComponentsPropsList {
MuiTable: TableProps;
MuiTableBody: TableBodyProps;
MuiTableCell: TableCellProps;
+ MuiTableContainer: TableContainerProps;
MuiTableHead: TableHeadProps;
MuiTablePagination: TablePaginationProps;
MuiTableRow: TableRowProps;