Skip to content

Add types and an RNTester example for conditional style values - #60126

Open
intergalacticspacehighway wants to merge 1 commit into
media-queries-2-platformsfrom
media-queries-3-types-example
Open

intergalacticspacehighway wants to merge 1 commit into
media-queries-2-platformsfrom
media-queries-3-types-example

Conversation

@intergalacticspacehighway

@intergalacticspacehighway intergalacticspacehighway commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary:

This is PR 3 of 3 (RFC). Stack: #60124 (core) → #60125 (platforms) → this PR.

This PR adds Flow and TypeScript types for conditional style values, and an RNTester example.

  • StyleSheet.create and StyleProp accept a conditional value for a style prop: {default: value, '@media (prefers-color-scheme: dark)': value}. The new types are ConditionalStyleValue<T> and WithConditionalStyleValues<T>.
  • objectFit, resizeMode, tintColor, userSelect and verticalAlign do not accept conditional values yet, because components convert them in JS.
  • Breaking (types only): after StyleSheet.flatten, a style value can be a ConditionalStyleValue. Code that reads it must handle the object (for example, .default) or cast.
  • RNTester has a new Media Queries example with conditional colors and a conditional width.
  • yarn flow-check of AnimatedExports.js takes about 12 s instead of 9.5 s.

Changelog:

[GENERAL] [BREAKING] - A style value from StyleSheet.flatten can be a ConditionalStyleValue (types only).

Test Plan:

  • New TypeScript test: stylesheet-conditional-values.tsx (correct usage and expected errors).
  • yarn build-types (no diff in ReactNativeApi.d.ts), yarn test-generated-typescript, yarn flow-check, ESLint and Prettier: pass.
  • The example: gh pr checkout 60126, build RNTester, and open Media Queries. The screenshots are in PR 2.

@meta-cla meta-cla 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 Nov 18, 2026
@intergalacticspacehighway
intergalacticspacehighway marked this pull request as ready for review November 19, 2026 05:18
@intergalacticspacehighway intergalacticspacehighway added the p: Expo Partner: Expo label Nov 19, 2026

This branch has not been deployed

No deployments
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. p: Expo Partner: Expo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant