- {children.map((child, index) => {
+ {children.slice(0, children.length - extraAvatars).map((child, index) => {
return React.cloneElement(child, {
className: clsx(child.props.className, classes.avatar),
style: {
@@ -51,6 +61,17 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(props, ref) {
},
});
})}
+ {extraAvatars ? (
+
+ +{extraAvatars}
+
+ ) : null}
);
});
@@ -73,6 +94,10 @@ AvatarGroup.propTypes = {
* @ignore
*/
className: PropTypes.string,
+ /**
+ * Max avatars to show before +x.
+ */
+ max: PropTypes.number,
/**
* Spacing between avatars.
*/
diff --git a/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.test.js b/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.test.js
index 422a8ebc3ddb9f..f1fbf364c49361 100644
--- a/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.test.js
+++ b/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.test.js
@@ -1,11 +1,15 @@
import * as React from 'react';
+import { expect } from 'chai';
import { createMount, getClasses } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
+import { createClientRender } from 'test/utils/createClientRender';
import AvatarGroup from './AvatarGroup';
+import { Avatar } from '@material-ui/core';
describe('