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