Skip to content

Instantly share code, notes, and snippets.

@d88naimi
Created September 7, 2021 18:27
Show Gist options
  • Save d88naimi/ab6a84c02946f1c9ddf4f51ff756dbe0 to your computer and use it in GitHub Desktop.
Save d88naimi/ab6a84c02946f1c9ddf4f51ff756dbe0 to your computer and use it in GitHub Desktop.
import React from "react";
import styles from "./ButtonGroup.less";
import cx from "classnames";
export function ButtonGroup(props) {
let opts = {
className: cx(styles.ButtonGroup, props.className)
};
return (
<div {...opts}>
{React.Children.map(props.children, child => {
if (child) {
return React.cloneElement(child, {
className: cx(styles.child, child.props.className)
});
}
})}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment