Skip to content

Conversation

adids1221
Copy link
Contributor

Description

New customBackground prop to the Button component that allows users to render custom React elements as button backgrounds.
This prop takes precedence over the backgroundColor.

Changelog

Button - Added customBackground prop to enable custom background elements

Additional info

N/A

@adids1221 adids1221 requested a review from M-i-k-e-l September 3, 2025 11:31
@adids1221 adids1221 added the hotfix Requires a hotfix release label Sep 3, 2025
Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

A few small comments, feel free to merge after they are handled

label="Image Background"
customBackground={
<Image
source={{uri: 'https://picsum.photos/300'}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to generate a random picture every time, it can cause issues in tests (if we have or will have them)

Comment on lines 465 to 469
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use our View, you can use the absF modifier to avoid these (except the overflow).
Up to you.

...others
} = this.props;
const shadowStyle = this.getShadowStyle();
const {margins, paddings} = modifiers;
const backgroundColor = this.getBackgroundColor();
const backgroundColor = customBackground ? 'transparent' : this.getBackgroundColor();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const backgroundColor = customBackground ? 'transparent' : this.getBackgroundColor();
const backgroundColor = customBackground ? undefined : this.getBackgroundColor();

@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Sep 4, 2025
@adids1221 adids1221 enabled auto-merge (squash) September 4, 2025 12:41
@adids1221 adids1221 merged commit 8185baf into master Sep 4, 2025
1 check passed
@adids1221 adids1221 deleted the feat/button-custom-background-prop branch September 4, 2025 12:43
adids1221 added a commit that referenced this pull request Sep 4, 2025
#3799)

* feat(Button): add customBackground prop for custom background elements

* feat(ButtonScreen): add custom gradient and image background buttons examples

* fix(Button): update customBackground handling and improve button styles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotfix Requires a hotfix release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants