mirror of
https://github.com/status-im/react-native.git
synced 2025-01-18 05:23:26 +00:00
32ab5b6b41
Summary: Closes https://github.com/facebook/react-native/pull/8367 Differential Revision: D3477404 Pulled By: caabernathy fbshipit-source-id: 16c279853b5c7a2d24033ef0d987da52dd148b24
40 lines
1.1 KiB
Markdown
40 lines
1.1 KiB
Markdown
---
|
|
id: basics-component-textinput
|
|
title: TextInput
|
|
layout: docs
|
|
category: The Basics
|
|
permalink: docs/basics-component-textinput.html
|
|
next: basics-component-scrollview
|
|
---
|
|
|
|
Direct text-based user input is a foundation for many apps. Writing a post or comment on a page is a canonical example of this. [`TextInput`](/react-native/docs/textinput.html#content) is a basic component that allows the user to enter text.
|
|
|
|
This example creates a simple `TextInput` box with the `string` `Type something here` as the placeholder when the `TextInput` is empty.
|
|
|
|
```ReactNativeWebPlayer
|
|
import React, { Component } from 'react';
|
|
import { AppRegistry, Text, TextInput, View } from 'react-native';
|
|
|
|
class TextInputBasics extends Component {
|
|
render() {
|
|
return (
|
|
<View style={{paddingTop: 22}}>
|
|
<TextInput
|
|
style={{
|
|
height: 40,
|
|
margin: 5,
|
|
paddingLeft: 10,
|
|
borderColor: 'black',
|
|
borderWidth: 1
|
|
}}
|
|
placeholder="Type something here"
|
|
/>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
// App registration and rendering
|
|
AppRegistry.registerComponent('AwesomeProject', () => TextInputBasics);
|
|
```
|