Skip to content

Conversation

@darylrowland
Copy link
Contributor

Added textAlignment property to the TextInput component so that text can be aligned center, left, right or justified.

@vjeux
Copy link
Contributor

vjeux commented Apr 3, 2015

textAlign should be in the style attribute, not as a prop of the component. Also, it doesn't merge anymore :(

@phamhieu
Copy link

phamhieu commented Apr 4, 2015

Right now, does TextInput support center align with style attribute?

I tried text-align: center; but nothing happen.

@ee0pdt
Copy link

ee0pdt commented Apr 6, 2015

@phamhieu I think you need to use camel case here, i.e. textAlign: center;

@phamhieu
Copy link

phamhieu commented Apr 6, 2015

Just test. Still not work. My code for references.

return (<TextInput 
                style={styles.inputText}
                value = {content}
                autoFocus = {true}
                onChangeText = {(text) => this.setState({'inputText': text}) }
                onEndEditing = {() => this.setState({'showTextInput': false}) } >
              </TextInput>);
inputText: {
    height: 28,
    width: SCREEN_WIDTH,
    backgroundColor: TEXT_BG,
    fontSize: 20,
    textAlign: 'center',
    color: 'white',
  },

result:
screen shot 2015-04-06 at 1 49 51 pm

@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 Apr 7, 2015
@darylrowland
Copy link
Contributor Author

I've just fixed this in a much better way in a new pull request - #772

Turns out that all that was wrong was that the textAlign css property needed remapping to textAlignment. So luckily a one line change fixes it... nice :)

@brentvatne brentvatne changed the title Added support for textAlignment property to TextInput [TextInput] Added support for textAlignment property Jun 1, 2015
@brentvatne brentvatne closed this Jun 1, 2015
@marcshilling
Copy link

This is fixed in 0.7.0rc

Just wanted to bring this up since I see some people doing it wrong here, textAlign is a prop directly on <TextInput>. Setting it as a style will not work.

jfrolich pushed a commit to jfrolich/react-native that referenced this pull request Apr 22, 2020
* try thing

* Delete yarn.lock

* bump react-multiversal to avoid yarn bug yarnpkg/yarn#7212

* back trick
ayushjainrksh referenced this pull request in MLH-Fellowship/react-native Jul 2, 2020
* Document .native.js extension

see also facebook/react-native-website#345

* Update platform-specific-code.md
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants