Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

intergalacticspacehighway
Copy link
Contributor

@intergalacticspacehighway intergalacticspacehighway commented Jun 26, 2025

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
Member

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
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
Member

Choose a reason for hiding this comment

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

Seems like it's still gated behind a feature flag for now:

inline void fromRawValue(
const PropsParserContext& context,
const RawValue& value,
std::vector<BoxShadow>& result) {
if (ReactNativeFeatureFlags::enableNativeCSSParsing()) {
parseUnprocessedBoxShadow(context, value, result);
} else {
parseProcessedBoxShadow(context, value, result);
}
}

Copy link
Member

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.

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. 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.

3 participants