+
Icon Left
+
+ }
+ metaData={{ key: 'primary-button' }}
+ onSelect={() => {}}
+ id="left-icon"
+ >
+ - {}} />
+
- {}} />
+
- {}} />
+
+
+
Icon Right
+
+ }
+ isReversed
+ metaData={{ key: 'primary-button' }}
+ onSelect={() => {}}
+ id="right-icon"
+ >
+ - {}} />
+
- {}} />
+
- {}} />
+
+
+
Icon Only
+
+ }
+ isIconOnly
+ metaData={{ key: 'primary-button' }}
+ onSelect={() => {}}
+ id="icon-only"
+ >
+ - {}} />
+
- {}} />
+
- {}} />
+
+
+
+);
+
+export default RightIconSplitButton;
diff --git a/packages/terra-dropdown-button/CHANGELOG.md b/packages/terra-dropdown-button/CHANGELOG.md
index 11e6021bcc2..4687e03fd45 100644
--- a/packages/terra-dropdown-button/CHANGELOG.md
+++ b/packages/terra-dropdown-button/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+* Added
+ * Added support for icons in `SplitButton`.
+
## 1.40.0 - (February 15, 2024)
* Changed
diff --git a/packages/terra-dropdown-button/package.json b/packages/terra-dropdown-button/package.json
index d33ed711611..741e3474557 100644
--- a/packages/terra-dropdown-button/package.json
+++ b/packages/terra-dropdown-button/package.json
@@ -57,5 +57,8 @@
"LICENSE",
"NOTICE",
"README.md"
- ]
+ ],
+ "devDependencies": {
+ "terra-icon": "^3.60.0"
+ }
}
diff --git a/packages/terra-dropdown-button/src/SplitButton.jsx b/packages/terra-dropdown-button/src/SplitButton.jsx
index b47ece58a8a..c14a9050d4f 100644
--- a/packages/terra-dropdown-button/src/SplitButton.jsx
+++ b/packages/terra-dropdown-button/src/SplitButton.jsx
@@ -23,6 +23,10 @@ const propTypes = {
* The options to display in the dropdown. Should be comprised of the subcomponent `Item`.
*/
children: PropTypes.node.isRequired,
+ /**
+ * An optional icon. Nested inline with the text when provided.
+ */
+ icon: PropTypes.element,
/**
* Determines whether the component should have block styles applied. The dropdown will match the component's width.
*/
@@ -35,6 +39,14 @@ const propTypes = {
* Determines whether the primary button and expanding the dropdown should be disabled.
*/
isDisabled: PropTypes.bool,
+ /**
+ * Whether or not the button should only display as an icon.
+ */
+ isIconOnly: PropTypes.bool,
+ /**
+ * Reverses the position of the icon and text.
+ */
+ isReversed: PropTypes.bool,
/**
* Sets the text that will be shown on the primary button which is outside the dropdown.
*/
@@ -190,9 +202,12 @@ class SplitButton extends React.Component {
render() {
const {
children,
+ isReversed,
+ icon,
isBlock,
isCompact,
isDisabled,
+ isIconOnly,
primaryOptionLabel,
onSelect,
variant,
@@ -235,6 +250,30 @@ class SplitButton extends React.Component {
theme.className,
);
+ const buttonTextClassnames = (icon && isReversed) ? cx([
+ 'text-first',
+ ]) : undefined;
+
+ const iconClassnames = (!isIconOnly) && !isReversed ? cx([
+ 'icon-first',
+ ]) : undefined;
+
+ const buttonText = !isIconOnly ?