Skip to content

[w3c] ☂️ Web Styles (Part 1) umbrella issue #34425

Description

@necolas

Add support for Web styles to components

This is the umbrella issue for basic React DOM / Web style additions to React Native components, as described in this proposal: "RFC: Reduce fragmentation across platforms".

Each of the tasks listed below can be tackled with individual PRs that link back to this issue. Not every task has a known solution or implementation yet, so feel free to discuss implementation details in the comments. Each new style property should take priority over any existing equivalents.

Styles

Basic extensions (All available in React Native 0.71)

Examples:

<View
  style={{
    aspectRatio: '16 / 9',
    transform: 'scaleX(2) translateX(20px)'
  }}
>

<Text
  style={{
    fontVariant: 'small-caps common-ligatures',
    fontWeight: 900
  }}
>

Equivalents

Available in React Native 0.71

Available in React Native 0.72

  • Add CSS Logical Properties
    • Logical margin (Fabric-only)
      • Map marginInlineStart to marginStart.
      • Map marginInlineEnd to marginEnd.
      • Map marginBlockStart to marginTop.
      • Map marginBlockEnd to marginBottom.
      • Map marginBlock to marginVertical.
      • Map marginInline to marginHorizontal.
    • Logical padding (Fabric-only)
      • Map paddingInlineStart to paddingStart.
      • Map paddingInlineEnd to paddingEnd.
      • Map paddingBlockStart to paddingTop.
      • Map paddingBlockEnd to paddingBottom.
      • Map paddingBlock to paddingVertical.
      • Map paddingInline to paddingHorizontal.
    • Logical insets (Fabric-only) 9669c10
      • inset is equivalent to top & bottom & right & left.
      • insetBlock is equivalent to top & bottom.
      • insetBlockEnd is equivalent to bottom.
      • insetBlockStart is equivalent to top.
      • insetInline is equivalent to right & left.
      • insetInlineEnd is equivalent to right or left.
      • insetInlineStart is equivalent to right or left.
    • feat: Add logical border block color properties  #35999
    • borderBlockColor is equivalent to borderTopColor & borderBottomColor.
    • borderBlockEndColor is equivalent to borderBottomColor.
    • borderBlockStartColor is equivalent to borderTopColor.

Outstanding (version to be determined)

  • borderStyle value of 'none'.
  • transformOrigin feat: transform-origin #37606
  • Add CSS Logical Properties.
    • borderInlineColor is equivalent to borderEndColor & borderStartColor.
    • borderInlineEndColor is equivalent to borderEndColor.
    • borderInlineStartColor is equivalent to borderStartColor.
    • borderBlockStyle is equivalent to borderTopStyle & borderBottomStyle.
    • borderBlockEndStyle is equivalent to borderBottomStyle.
    • borderBlockStartStyle is equivalent to borderTopStyle.
    • borderInlineStyle is equivalent to borderEndStyle & borderStartStyle.
    • borderInlineEndStyle is equivalent to borderEndStyle.
    • borderInlineStartStyle is equivalent to borderStartStyle.
    • borderBlockWidth is equivalent to borderTopWidth & borderBottomWidth.
    • borderBlockEndWidth is equivalent to borderBottomWidth.
    • borderBlockStartWidth is equivalent to borderTopWidth.
    • borderInlineWidth is equivalent to borderEndWidth & borderStartWidth.
    • borderInlineEndWidth is equivalent to borderEndWidth.
    • borderInlineStartWidth is equivalent to borderStartWidth.

Examples:

<View
  style={{
    pointerEvents: 'none'
  }}
>

<Text
  style={{
    userSelect: 'none',
    verticalAlign: 'middle'
  }}
>

<Image
  style={{
    objectFit: 'cover'
  }}
>

New features

Available in React Native 0.71

<View
  style={{
    boxShadow: '1px 1px 1px 1px #eee',
    backgroundColor: 'hsla(50,50,50,0.5)',
    backgroundImage: 'url(https://image.png)',
    pointerEvents: 'none',
    transform: 'scale(0.9)',
    width: '5rem'
  }}
>

<Text
  style={{
    textShadow: '1px 1px 1px #eee',
    userSelect: 'none',
    verticalAlign: 'middle'
  }}
>

<Image
  style={{
    objectFit: 'cover'
  }}
>

Activity

  1. necolas commented on Aug 15, 2022

    @necolas
    Author

    See companion issue related to props #34424

  2. nandorojo commented on Aug 15, 2022

    @nandorojo

    Would flex gap apply here, or does that fall out of scope since it's still missing in Yoga?

    From experience, the lack of gap support is one of the worst parts of styling on native vs. web. Shadows are up there too, but I use them less often.

    It would be great to add objectPosition for images too.

  3. necolas commented on Aug 15, 2022

    @necolas
    Author

    Would flex gap apply here, or does that fall out of scope since it's still missing in Yoga?

    Yes, that needs to be added to Yoga which is a whole other project.

    It would be great to add objectPosition for images too.

    Done.

  4. meftunca commented on Aug 15, 2022

    @meftunca

    please support for 'transform-origin' and 'display:grid'

  5. burakgormek commented on Aug 15, 2022

    @burakgormek

    Percentage values for translate would be good. We already have this on web.
    Not sure if it's related to yoga, like flex gap.

    translateX(50%), translateY(100%)

  6. escaton commented on Aug 15, 2022

    @escaton

    Yes, that needs to be added to Yoga which is a whole other project.

    already done, waiting for merge for 6 months

  7. changed the title [-][w3c] Web Styles umbrella issue[/-] [+][w3c] ☂️ Web Styles umbrella issue[/+] on Aug 16, 2022
  8. pinned this issue on Aug 17, 2022
  9. gabrieldonadel commented on Aug 21, 2022

    @gabrieldonadel
    Collaborator
    • Add expanded support for CSS Colors, e.g., hsla(). Potentially via Colorjs.io.

    Hi @necolas, which CSS Color Module Level do we wanna meet? React native already supports rgb(), rgba(), #rgb, #rrggbb, #rgba, #rrggbbaa, hsl(), hsla(), colors as int values (in RGB mode) and named colors, what else do we want to support? hwb()? lab()?

  10. necolas commented on Aug 22, 2022

    @necolas
    Author

    Level 4, as Colorjs.io does. Functions should also support space-separated values, not just comma separated.

  11. necolas commented on Aug 29, 2022

    @necolas
    Author

    I added a new section for improving cross-platform compatibility of Animated.

    It should be relatively easy to make Animated a separate package that works on web for React Native for Web. This would allow developers to have the same version of Animated running and avoid me needing to update Animated at arbitrary points in time, which is also tedious and error prone, as I have to check for new sources of crashes and copy-paste-edit dozens of files that use different module syntaxes and internal import paths to RN public APIs, like StyleSheet.

  12. necolas commented on Aug 31, 2022

    @necolas
    Author

    already react/yoga#1116, waiting for merge for 6 months

    The RN team had planned to move to a new layout engine, but probably not anymore. So since there is an existing PR and it has a chance of being merged soon, I'll add gap too.

  13. 82 remaining items

  14. necolas commented on Jun 27, 2023

    @necolas
    Author

    There's a bug in Animated when using the string syntax for transforms. The string syntax needs to be converted back to an array of objects for AnimatedTransform to work properly.

    Edit: nvm, someone was stringifying an animated object instead of updating their string interpolation code

  15. Pranav-yadav commented on Jun 27, 2023

    @Pranav-yadav
    Contributor

    There's a bug in Animated when using the string syntax for transforms. The string syntax needs to be converted back to an array of objects for AnimatedTransform to work properly.

    @necolas
    Should a similar approach as in necolas/react-native-web@ed83baa fix this issue in react-native?

    Also, haven't looked at it though seems like the new AnimatedObject #36935 also doesn't take care of this.

  16. pinned this issue on Jul 10, 2023
  17. unpinned this issue on Oct 12, 2023
  18. nandorojo commented on Feb 7, 2024

    @nandorojo

    Could we add position: sticky here as well?

  19. necolas commented on Jun 28, 2025

    @necolas
    Author

    Closing as completed

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ☂️ UmbrellaTo label issues that serve as coordination point and drivers for tasks in the react-native repoAPI: StyleSheetHelp Wanted :octocat:Issues ideal for external contributors.Needs TypeScript UpdatePlatform: AllAn issue that impacts all the platforms

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions