textAlignVertical: center not working
See original GitHub issueBug
I am trying to vertically align the text inside a Text
component. I tried pretty much everything ( textAlignVertical: 'center', alignItems:'center', alignSelf: 'center',
), but it still doesn’t work.
Environment info
React native info output:
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 225.43 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.4.0 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
Library version: 0.61.2
Steps To Reproduce
- create the componet
- set its
style
- text inside doesn’t get vertically aligned
Describe what you expected to happen:
- text inside to be vertically aligned
Reproducible sample code
// code. pretty much most basic way of doing it
<Text style={styles.Initials}>HO</Text>
// css
Initials: {
height: 64,
width: 64,
borderRadius: 32,
color: 'white',
fontWeight: '600',
fontSize: 18,
textAlign: 'center',
textAlignVertical: 'center',
alignItems:'center',
alignSelf: 'center',
backgroundColor: colors.colorPrimary,
overflow: 'hidden'
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
"textAlignVertical" is not a valid style property - Stack Overflow
The textAlignVertical style is an Android-only property. If you are developing on iOS, try using the flexbox alignment property alignItems: ...
Read more >textalignvertical not working in ios react native - Code Grepper
textalignvertical not working in ios react native ; 1. { ; 2. height: 30, ; 3. textAlignVertical: 'center', ; 4 ...Platform.select({ ; 5....
Read more >Text Style Props - React Native
With some fonts, this padding can make text look slightly misaligned when centered vertically. For best results also set textAlignVertical to ...
Read more >Bootstrap 4 Vertical Center - Medium
Getting elements to center align vertically has always been a challenge in CSS, ... Align” utilities would seem an obvious choice, but these...
Read more >align attribute - BFO
"left", "right", "center", "justify" or "justify-all" · no · td, All block elements · justify · text-align vertical-align width ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fix it with following style:
Hope it helps
This prop supported on Android only