react / react/react-native

letterSpacing property not working properly

Abierto
#54,823 7 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Needs: Triage :mag:
Lenguaje dominante
C++
Estrellas
127k
Forks
25.3k
Merge medio
1 d 23 h
PR fusionados (30 d)
4

Descripción

Description

When Applying the letterSpacing to style in Text component, it applies the spacing after the character instead of adding space between the characters.

Here is the sample vanila code.

<Text
        style={{
          backgroundColor: 'blue',
          color: 'white',
          fontSize: 18,
          alignSelf: 'center',

          letterSpacing: 30,
          fontVariant: ['tabular-nums'],
        }}
      >
        1/3
      </Text>

Output:

Image

I also tried to apply the fontVariant: ['tabular-nums'], assuming that it may keep the character width same if that's the issue.
But seems that doesn't fix the error.

And this gap keeps increasing when you increase the letterSpacing.

Try 2:

<Text
        style={{
          backgroundColor: 'blue',
          color: 'white',
          fontSize: 18,
          alignSelf: 'center',

          letterSpacing: 90, // <- increased
          fontVariant: ['tabular-nums'],
        }}
      >
        1/3
      </Text>

Output:

Image

And thus How I conclude that it may adds the space after each character instead of gap.

Here is my package.json file's dependencies.

"dependencies": {
    "@medusajs/js-sdk": "2.8.7",
    "@medusajs/types": "2.8.7",
    "@react-native-clipboard/clipboard": "^1.16.3",
    "@react-native-community/geolocation": "^3.4.0",
    "@react-native-documents/picker": "^11.0.0",
    "@react-native-documents/viewer": "^2.0.2",
    "@react-native-firebase/analytics": "^23.4.1",
    "@react-native-firebase/app": "^23.4.1",
    "@react-native-firebase/crashlytics": "^23.4.1",
    "@react-native-firebase/remote-config": "^23.4.1",
    "@react-navigation/bottom-tabs": "^7.4.6",
    "@react-navigation/drawer": "^7.5.7",
    "@react-navigation/native": "^7.1.17",
    "@react-navigation/native-stack": "^7.3.25",
    "@shopify/flash-list": "^2.1.0",
    "@tanstack/react-query": "^5.85.2",
    "dayjs": "^1.11.19",
    "formik": "^2.4.9",
    "i18next": "^25.5.2",
    "jwt-decode": "^4.0.0",
    "lodash": "^4.17.21",
    "patch-package": "^8.0.0",
    "postinstall-postinstall": "^2.1.0",
    "qs": "6.12.0",
    "react": "19.1.0",
    "react-i18next": "^15.7.3",
    "react-native": "0.80.2",
    "react-native-config": "^1.5.6",
    "react-native-fast-image": "^8.6.3",
    "react-native-flash-message": "^0.4.2",
    "react-native-gesture-handler": "^2.28.0",
    "react-native-image-crop-picker": "^0.51.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-keyboard-controller": "^1.19.6",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-mmkv": "^3.3.0",
    "react-native-navigation-bar-color": "^2.0.2",
    "react-native-otp-entry": "^1.8.5",
    "react-native-permissions": "^5.4.4",
    "react-native-reanimated": "^4.0.2",
    "react-native-reanimated-carousel": "^4.0.3",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^5.6.0",
    "react-native-screens": "^4.14.1",
    "react-native-svg": "^15.12.1",
    "react-native-video": "^6.16.1",
    "react-native-worklets": "^0.4.1",
    "yup": "^1.7.1",
    "zustand": "^5.0.7"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@commitlint/cli": "^19.8.1",
    "@commitlint/config-conventional": "^19.8.1",
    "@react-native-community/cli": "19.1.1",
    "@react-native-community/cli-platform-android": "19.1.1",
    "@react-native-community/cli-platform-ios": "19.1.1",
    "@react-native/babel-preset": "0.80.2",
    "@react-native/eslint-config": "0.80.2",
    "@react-native/metro-config": "0.80.2",
    "@react-native/typescript-config": "0.80.2",
    "@tanstack/eslint-plugin-query": "^5.83.1",
    "@types/jest": "^29.5.13",
    "@types/lodash": "^4.17.20",
    "@types/react": "^19.1.0",
    "@types/react-test-renderer": "^19.1.0",
    "babel-plugin-module-resolver": "^5.0.2",
    "cspell": "^9.3.2",
    "eslint": "^8.19.0",
    "eslint-plugin-import": "^2.32.0",
    "husky": "^9.1.7",
    "jest": "^29.6.3",
    "lint-staged": "^16.1.5",
    "prettier": "2.8.8",
    "react-native-dotenv": "^3.4.11",
    "react-test-renderer": "19.1.0",
    "reactotron-react-native": "^5.1.15",
    "typescript": "5.0.4"
  },
Steps to reproduce
  1. Just paste the code blocks I added in the react native project created with same version as mine.
React Native Version

0.80.2

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
  OS: macOS 26.1
  CPU: (10) arm64 Apple M4
  Memory: 162.77 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.11.0
    path: ~/.nvm/versions/node/v22.11.0/bin/node
  Yarn:
    version: 3.2.3
    path: ~/.nvm/versions/node/v22.11.0/bin/yarn
  npm:
    version: 10.9.0
    path: ~/.nvm/versions/node/v22.11.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/aditya/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.1
      - iOS 26.1
      - macOS 26.1
      - tvOS 26.1
      - visionOS 26.1
      - watchOS 26.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 26.1.1/17B100
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.8
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/aditya/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 19.1.1
    wanted: 19.1.1
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.2
    wanted: 0.80.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

info React Native v0.82.1 is now available (your project is running on v0.80.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.82.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.80.2&to=0.82.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
Not a crash
MANDATORY Reproducer

https://snack.expo.dev/@aditya_thummar/moody-indigo-yogurt

Screenshots and Videos
Image

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el informe con el Snack enlazado y los ejemplos del componente Text tanto en Android como en iOS, probando valores de letterSpacing de 30 y 90. Rastrea la ruta de renderizado de Text para determinar por qué aparece espacio después de los caracteres y, a continuación, verifica que los espacios renderizados coincidan con el comportamiento previsto de letter-spacing.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
react-native
Área
mobile
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.