1--- 2title: Styling a React Native button 3sidebar_title: Styling buttons 4description: Learn how to style a button in a React Native app. 5--- 6 7import ImageSpotlight from '~/components/plugins/ImageSpotlight'; 8import { SnackInline } from '~/ui/components/Snippet'; 9 10React Native exports a [`<Button>`](https://reactnative.dev/docs/button) component that exposes the native button element for Android, iOS, and the web. The `<Button>` component accepts `title` and `onPress` props but it does not accept a `style` prop, which makes it hard to customize the style. 11 12The closest you can get to styling a `<Button>` exported from React Native is with the `color` prop. Below is an example of two buttons on Android, iOS, and the web. 13 14The first button is the default `<Button>` and the second is another default `<Button>` with its `color` prop set to `"red"`. 15 16<ImageSpotlight style={{ maxWidth: 960 }} src="/static/images/faq-button-style-button.png" alt="" /> 17 18To create a button with a custom style, you can turn to the [`<Pressable>`](https://reactnative.dev/docs/pressable) component. 19`<Pressable>` lets us fully customize the appearance of a pressable element (like a button), in addition to allowing us to customize its behavior. 20 21Here's an example of using `<Pressable>` to create a button component: 22 23<SnackInline> 24 25{/* prettier-ignore */} 26```jsx 27import React from 'react'; 28import { Text, StyleSheet, Pressable } from 'react-native'; 29 30export default function Button(props) { 31 const { onPress, title = 'Save' } = props; 32 return ( 33 <Pressable style={styles.button} onPress={onPress}> 34 <Text style={styles.text}>{title}</Text> 35 </Pressable> 36 ); 37} 38 39const styles = StyleSheet.create({ 40 button: { 41 alignItems: 'center', 42 justifyContent: 'center', 43 paddingVertical: 12, 44 paddingHorizontal: 32, 45 borderRadius: 4, 46 elevation: 3, 47 backgroundColor: 'black', 48 }, 49 text: { 50 fontSize: 16, 51 lineHeight: 21, 52 fontWeight: 'bold', 53 letterSpacing: 0.25, 54 color: 'white', 55 }, 56}); 57``` 58 59</SnackInline> 60 61And here's the result of this code: 62 63<ImageSpotlight 64 style={{ maxWidth: 640 }} 65 src="/static/images/faq-button-style-pressable.png" 66 alt="Custom styled button component using Pressable" 67/> 68 69React Native's `<Button>` component does not accept a `style` prop, and its `color` prop is limited and appears differently across Android, iOS, and the web. With the `<Pressable>` component, we can create custom buttons that fit our app's design. Those styles will also be the same across Android, iOS, and the web, which will give our apps a consistent look on every platform. 70