2016-06-20 22:05:20 +00:00
---
id: basics-component-textinput
title: TextInput
layout: docs
2016-06-22 21:19:25 +00:00
category: The Basics
2016-06-20 22:05:20 +00:00
permalink: docs/basics-component-textinput.html
2016-06-21 20:24:21 +00:00
next: basics-component-scrollview
2016-06-20 22:05:20 +00:00
---
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.
2016-06-22 17:00:12 +00:00
This example creates a simple `TextInput` box with the `string` `Type something here` as the placeholder when the `TextInput` is empty.
2016-06-20 22:05:20 +00:00
2016-06-22 22:02:02 +00:00
```ReactNativeWebPlayer
2016-06-20 22:05:20 +00:00
import React from 'react';
2016-06-22 17:00:12 +00:00
import { AppRegistry, Text, TextInput, View } from 'react-native';
2016-06-20 22:05:20 +00:00
2016-06-22 17:00:12 +00:00
const AwesomeProject = () => {
2016-06-20 22:05:20 +00:00
return (
2016-06-22 17:00:12 +00:00
< View style = {{paddingTop: 22 } } >
< TextInput
style={{
height: 40,
margin: 5,
paddingLeft: 10,
borderColor: 'black',
borderWidth: 1
}}
placeholder="Type something here"
/>
< / View >
2016-06-20 22:05:20 +00:00
);
}
// App registration and rendering
2016-06-22 17:00:12 +00:00
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
2016-06-20 22:05:20 +00:00
```