Skip to content

Conversation

@agreatscott
Copy link
Contributor

@agreatscott agreatscott commented Aug 21, 2025

There's a design need to have a button with an end icon, where the two are split across the length of the button (think space-between). This PR attempts to implement that in the current Button component.

I don't love the implementation, and it's a bit messy, but it does the trick. Open to thoughts/comments.

Desired from Figma:
image

Actual storybook with this change
image

@agreatscott agreatscott requested a review from akdetrick August 21, 2025 17:25
@akdetrick
Copy link
Collaborator

akdetrick commented Aug 25, 2025

Biggest concerns:

  • startContent, startIcon, endContent, endIcon may need different flex rules
  • SplitButton will also take this prop. What does a spread splitButton look like? We probably want to pack all button internal items and make the secondary button the shrink member of the flex

I restarted the Chromatic action to take a look at the preview build

Comment on lines +104 to +108
&.nds-button--xs .nds-button-content,
&.nds-button--s .nds-button-content,
&.nds-button--m .nds-button-content {
width: 100% !important;
}
Copy link
Collaborator

@akdetrick akdetrick Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we want to happen with isSpread is for the root element (the button or anchor) takes up 100% of parent width.

Expected

(we may also want to set a self-justification for the content area so it justifies start when isSpread)
Screenshot 2025-08-25 at 2 50 51 PM

Actual

Screenshot 2025-08-25 at 2 50 58 PM

Copy link
Collaborator

@akdetrick akdetrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes requested:

Ensure the button fills parent width when isStretch

We want the entire button to have width: 100% so it fills its parent container.
It might also be nice to left align

Special handling for SplitButton

The SplitButton component takes all the same props as Button, including the new isSpread. A spread split button should look like this:

Screenshot 2025-08-25 at 2 52 50 PM

You can intercept the isSpread props to apply a 100% width to the root element of SplitButton when the prop is truthy

tl;dr

We want the layout for Button to be like this when spread (start and end content & icons in red):
Screenshot 2025-08-25 at 3 03 14 PM

For SplitButton:
Fill 100% width and let the Button size stretch
Screenshot 2025-08-25 at 3 04 43 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants