Skip to content

feat(JS): background-size, position and repeat styles#52284

Closed
intergalacticspacehighway wants to merge 10 commits into
react:mainfrom
intergalacticspacehighway:feat/background-styles-js
Closed

feat(JS): background-size, position and repeat styles#52284
intergalacticspacehighway wants to merge 10 commits into
react:mainfrom
intergalacticspacehighway:feat/background-styles-js

Conversation

@intergalacticspacehighway

@intergalacticspacehighway intergalacticspacehighway commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

Summary:

This PR adds support for background size, position and repeat styles. It follows the CSS spec. Currently we default to background-origin: padding-box and background-clip : border-box to match the web's behavior. We can introduce these styles later. I have split the PR intro three parts for review. This PR includes JS parsing and style propagation to native changes. I wanted to introduce one style at a time, but CSS spec is such that size, position and repeat are intertwined.

Changelog:

[GENERAL][ADDED] - Background size, position and repeat styles.

Test Plan:

Merge the iOS and android PR into this, this PR includes BackgroundImageExample. I have also added testcases for parsing syntax in JS.

Screen.Recording.2025-06-26.at.10.47.17.AM.mp4

background image example

example js nits

beautiful multiple gradient example
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 26, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 26, 2025

const validValues = ['repeat', 'space', 'round', 'no-repeat'] as const;

export default function processBackgroundRepeat(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we want to do this parsing in native using the new CSSParser infra, and not rely on JS viewconfigs.

cc @NickGerleman

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, i wanted to mention that. Is it in use already?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, just reading through some of the history there, until we complete another refactor on Android, we will still need JS parsing of these types there.

@cortinico cortinico added p: Expo Partner: Expo Partner labels Sep 10, 2025
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@jorge-cab has imported this pull request. If you are a Meta employee, you can view this in D82973282.

meta-codesync Bot pushed a commit that referenced this pull request Oct 24, 2025
Summary:
This PR adds support for background size, position and repeat styles. It follows the [CSS](https://www.w3.org/TR/css-backgrounds-3/#backgrounds) spec. Currently we default to `background-origin: padding-box` and `background-clip : border-box` to match the web's behavior. We can introduce these styles later. I have split the PR intro three parts for review. This PR includes iOS only changes. I wanted to introduce one style at a time, but CSS spec is such that size, position and repeat are intertwined.

## Changelog:
[IOS][ADDED] - Background size, position and repeat styles.
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #52283

Test Plan:
Merge the [JS](#52284) PR, run `pod install` and test RNTester example, it includes `BackgroundImageExample`. I have also added testcases for syntax parsing in JS.

https://github.com/user-attachments/assets/b7192fdf-52ba-4eb0-a1be-d47c72d87e92

Reviewed By: joevilches

Differential Revision: D82993888

Pulled By: jorge-cab

fbshipit-source-id: af545acaf4b9d116b5905f912c494d2e77324380
meta-codesync Bot pushed a commit that referenced this pull request Oct 24, 2025
Summary:
This PR adds support for background size, position and repeat styles. It follows the [CSS](https://www.w3.org/TR/css-backgrounds-3/#backgrounds) spec. Currently we default to `background-origin: padding-box` and `background-clip : border-box` to match the web's behavior. We can introduce these styles later. I have split the PR intro three parts for review. This PR includes android only changes. I wanted to introduce one style at a time, but CSS spec is such that size, position and repeat are intertwined.

## Changelog:
[ANDROID][ADDED] - Background size, position and repeat styles.
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #52282

Test Plan:
Merge the [JS](#52284) PR, rebuild android app and test RNTester app, it includes `BackgroundImageExample`. I have also added testcases for parsing syntax in JS.

https://github.com/user-attachments/assets/b7192fdf-52ba-4eb0-a1be-d47c72d87e92

Reviewed By: joevilches

Differential Revision: D82993837

Pulled By: jorge-cab

fbshipit-source-id: 52859e51d2c4bab27823d3eb913993fdfbb4c04d
@meta-codesync meta-codesync Bot closed this in 3d08683 Oct 24, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 24, 2025
@meta-codesync

meta-codesync Bot commented Oct 24, 2025

Copy link
Copy Markdown

@jorge-cab merged this pull request in 3d08683.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants