At its core, creating an action button in React Native is all about making a piece of your UI tappable. You'll typically grab a core component like TouchableOpacity or Pressable, wrap your icon or text inside it, and then tell it what to do using the onPress prop. This simple pattern is the backbone of pretty much every interactive element you'll build.
Building Your First React Native Action Button

Staring at a fresh component file can feel a bit daunting. So, let's walk through building a basic action button from the ground up. We'll stick with the core components that ship with React Native, so you won't need to install any third-party libraries just yet.
Choosing Your Core Component
When you need to capture a tap, React Native gives you two main tools: TouchableOpacity and Pressable. They both get the job done, but they handle user feedback differently.
TouchableOpacity is the old standby. It gives you a classic, subtle fade-out effect when a user presses the button. It's incredibly straightforward and perfect for getting something interactive on the screen fast.
Then there's Pressable. It's a newer, more capable component that gives you fine-grained control over how your button looks and feels during different stages of an interaction. You can define specific styles for when a user's finger first touches down (onPressIn) and when it lifts off (onPressOut), which is great for creating richer, more custom feedback.
When you're building out your UI, choosing the right component often comes down to the level of feedback you need. Here's a quick look at the most common core components you'll use.
Core Components For Action Buttons
| Component | Key Feature | Best For |
|---|---|---|
TouchableOpacity | Fades the button's opacity on press. | Simple buttons where a quick, standard visual feedback is enough. |
Pressable | Highly customizable state-based feedback (onPressIn, etc). | Primary action buttons that need unique styling during interaction. |
TouchableHighlight | Darkens the background on press. | Buttons that need to stand out against a specific background color. |
Ultimately, Pressable is the more modern and flexible choice, but TouchableOpacity is still fantastic for its simplicity.
Performance Matters More Than You Think
A snappy, responsive button is non-negotiable for a good user experience. This isn't just a "nice-to-have"—it's a critical performance metric. The team at Indeed has written extensively about this, highlighting that a First Input Delay (FID) under 50ms is the goal.
Their research shows that metrics like Time to Interactive (TTI), where button readiness can carry a 45% weight, are essential for high-performance scores. This echoes what we’ve seen from Meta’s React team, which has demonstrated that their new compiler can improve interaction times by up to 2.5x for dynamic elements like action buttons.
A responsive button isn't a luxury; it's a core requirement for a modern mobile app. Users expect immediate feedback, and a laggy button can be the first sign of a poorly optimized application.
The good news is that components like Pressable are designed to feel fluid and native. They run on the native thread, ensuring user taps are handled instantly, even if the JavaScript thread is bogged down with other work.
To dive deeper into styling and see more advanced examples, check out our complete guide on creating buttons in React Native. Getting this foundation right will give you the confidence to build any kind of interactive experience your app needs.
Creating A Floating Action Button That Feels Right

Floating Action Buttons, or FABs, are a familiar sight in mobile apps. They anchor the most important action of a screen—think composing a new email or adding a task to your to-do list. When you get a FAB right, it feels completely natural and helpful. But a poorly implemented one can feel awkward and get in the way.
While component libraries offer quick solutions, building a custom FAB from scratch gives you unparalleled control over its behavior and appearance. Let's walk through how to build one, focusing on getting the positioning and platform-specific details just right.
Positioning Your FAB for a Perfect Fit
The secret to making a FAB "float" is absolute positioning. This CSS technique pulls the component out of the standard document flow, allowing you to pin it to a specific spot on the screen. My go-to strategy is to wrap the entire screen in a View styled with flex: 1, then place the FAB as the last child in that container.
Here’s the basic styling I always start with:
position: 'absolute'— This is the property that does all the heavy lifting.bottom: 30— Gives it a comfortable margin from the bottom of the screen.right: 30— Creates a nice, balanced look by matching the bottom margin.
This simple setup locks your action button react native component into the bottom-right corner, so it stays put even when the content behind it scrolls.
I can't stress this enough: always use a main container
Viewfor your screen. By placing the FAB inside this container but after all the other content, you make managingzIndexand layout so much easier. It's a simple trick that prevents a ton of headaches where the button might accidentally slip behind other elements.
Achieving the Authentic Floating Look
A FAB isn't just about position; it needs to look like it’s literally floating above the interface. This visual effect is all about the shadow, and this is where iOS and Android part ways.
For Android:
The approach is wonderfully simple. Just use the elevation style property. It’s designed specifically for Material Design’s depth effects. A value between 4 and 8 usually gives you that perfect, subtle shadow.
For iOS:
The elevation property won't do anything here. Instead, you have to build the shadow yourself using a few distinct style properties:
shadowColor: Usually just black ('#000').shadowOffset: An object like{ width: 0, height: 2 }pushes the shadow down slightly.shadowOpacity: This controls how strong the shadow is. I find 0.25 is a good, non-distracting value.shadowRadius: This determines the blur of the shadow. A value around 3.84 gives it a soft, realistic feel.
To handle this divergence cleanly, you can use React Native’s built-in Platform.select API. This lets you apply the correct styles for each OS, ensuring your FAB looks and feels native everywhere.
Adding an Icon and Final Touches
Of course, a FAB needs an icon to signal its function. The undisputed champion for icons in React Native is react-native-vector-icons. Once you have it installed, just pop an Icon component right inside your TouchableOpacity.
By combining these techniques, you've built a custom, cross-platform FAB that is positioned perfectly and styled natively. Taking this hands-on approach ensures your most important action button react native is a polished highlight of your UI, not just an afterthought.
Advanced Styling For Buttons That Stand Out

Sure, a functional button works, but a thoughtfully styled one does so much more. It draws the user's eye, clarifies the interface, and really sells the quality of your app. This is where we move beyond the defaults and start crafting a UI that feels intentional and professional.
An easy win for adding visual punch is to use gradients. Flat colors are fine, but a subtle gradient can give an action button react native component a modern, tactile feel. For this, my go-to library is almost always react-native-linear-gradient.
You simply wrap your TouchableOpacity or Pressable component with LinearGradient. It lets you pass an array of colors and control the gradient's direction with start and end props, giving you all the creative control you need to match your brand's look.
Managing Dynamic Button States
Let's be real—a button is never just sitting there. It has different states: active, disabled, or even a loading state right after a user taps it. The key to a polished UX is handling these style changes gracefully. A common mistake I see is developers cramming a bunch of conditional logic right into the style prop, which quickly becomes a nightmare to manage.
A much cleaner way to work is by defining your styles separately and applying them based on props. For example, you can pass a disabled or loading boolean prop to your custom button component.
By using props to drive style changes, you create a component that is not only reusable but also much easier to read and maintain. Instead of a tangled mess of ternary operators in your JSX, you have a clean, declarative API for your button. This is the exact method I use in large-scale projects to ensure UI consistency.
Here’s a practical breakdown of how you might manage these styles:
- Base Style: This is your button's default look and feel.
- Disabled Style: Typically involves reducing the opacity and setting
pointerEventsto'none'. - Loading Style: Could mean swapping the button's text with an
ActivityIndicator.
You can then cleanly merge these styles using StyleSheet's array syntax, like style={[styles.base, disabled && styles.disabled]}. This keeps your render method tidy and your styling logic easy to follow.
Building Reusable Button Variants
For any app that needs to scale, you’ll need more than just one button style. You'll probably have primary buttons for key actions, secondary or outlined buttons, and maybe even simple text-only buttons. The smart move here is to build a single, powerful Button component that accepts a variant prop.
Based on what you pass to variant—like 'primary', 'outline', or 'text'—you can apply a completely different set of styles. This approach centralizes all your button logic, making it dead simple to enforce design consistency across your entire app. If you want to dive deeper into this way of thinking, check out our guide on creating reusable React Native components.
This strategy of creating flexible, prop-driven components is how you build a button library that's a breeze to use and maintain. It's the foundation of any professional and cohesive app design.
Bringing Buttons to Life with Reanimated
A static button works, sure, but an animated one? That’s what makes an app feel truly special. To give our action button react native components that premium feel, we'll turn to a library I swear by: React Native Reanimated. It lets you build incredibly smooth, 60fps animations that run on the native UI thread, not the JavaScript thread.
That separation is the secret sauce. When your animations live on the UI thread, they stay fluid and responsive no matter what else is happening. Even if the JS thread is chugging away on heavy logic, your UI won't skip a beat. It's how you make an app feel polished and fast, even on older phones.
The 'Press-In, Press-Out' Micro-Interaction
One of the simplest yet most effective animations is the 'press-in, press-out' effect. It gives the user instant, tactile feedback the second their finger touches the button, making the whole interface feel more responsive and alive. It’s a small touch that has a huge impact.
Getting this done with Reanimated is surprisingly straightforward, thanks to a few core hooks:
useSharedValue: Think of this as a special state that can be read and updated from either the UI or JS thread. We’ll use it to keep track of our button's scale.useAnimatedStyle: This hook connects our styles directly to a shared value. Here, we'll link our button'stransformproperty to the scale value we just created.withTiming: This function is what actually creates the animation, smoothly transitioning a shared value over a set duration.
We just wrap our button in a Pressable and use its onPressIn and onPressOut props. When the user presses down, we trigger withTiming to scale the button down. When they release, we trigger it again to scale it back up. Simple, effective, and feels great.
Deciding what kind of animation to use often comes down to what you're trying to achieve. Is it just for feedback, or do you need to reveal more options?

As you can see, the user experience goal—whether it's providing a quick confirmation or expanding functionality—should drive your animation choice.
Building an Expanding FAB Menu
Let's tackle something a bit more ambitious: a Floating Action Button (FAB) that expands to show a menu of other actions. You see this pattern all the time in apps like Gmail or Notion, where a primary button hides several related sub-actions.
To pull this off, we need to orchestrate a few animations at once:
- First, the main FAB icon needs to transform, maybe rotating from a 'plus' to a 'close' icon.
- Next, the sub-action buttons have to appear, fanning out from the main FAB. This means animating both their position (
translateY) and their visibility (opacity). - Finally, to make it look really slick, we should stagger the animations, so each sub-button appears with a slight delay.
These kinds of dynamic animations are no longer a niche feature. Recent surveys show that a staggering 93% of developers use animation libraries to hit the buttery-smooth 60fps transitions users now expect. The impact on workflow is also massive, with teams reporting that unifying their action button logic has cut project timelines by 60-70% and reduced costs by 30-50%. You can dive into the full report on React Native trends for more insights.
What sounds like a complex dance is made manageable by Reanimated. We can tie every button's position and opacity to a single shared value representing the menu's state—'open' or 'closed'. When the user taps the FAB, we just update that one value. Reanimated takes care of the rest, ensuring all the connected animations play out in perfect sync on the UI thread.
Building every component from scratch offers complete control, but let's be realistic—sometimes, you just need to get the job done quickly. In those moments, leaning on a well-maintained, battle-tested library is the smartest play. It not only saves you a ton of development time but also gives you access to features and optimizations that have been refined across thousands of apps.
So, how do you choose? I'm going to walk you through two of my go-to libraries for action buttons: react-native-paper and react-native-floating-action. They each excel in different areas, and knowing which one to pick comes down to your project's specific needs.
When to Choose React Native Paper
First up is React Native Paper. It's important to understand that this isn't just a button library. It’s a full-blown UI component suite based on Google's Material Design system. Think of it as an entire toolkit for your app, complete with cards, inputs, app bars, and, of course, a variety of buttons.
You’ll want to reach for react-native-paper when:
- A complete design system is what you need. If your goal is a consistent, professional look and feel across your entire application without reinventing the wheel, Paper is a brilliant choice.
- Theming is a major requirement. It comes with a robust, built-in theming system that makes it incredibly easy to tweak colors, fonts, and spacing to perfectly match your brand's identity.
- You're already committed to Material Design. If your app's design language is already based on Material,
react-native-paperwill feel like a natural extension of your stack.
The main trade-off here is its size. If you only need a single Floating Action Button (FAB) and nothing else, pulling in the whole library might feel like overkill. But for most applications that require a cohesive set of UI components, the benefits far outweigh the added dependency. You can see how it compares to other options in our guide to the top React Native animation and UI libraries.
When to Choose React-Native-Floating-Action
Now, if you're looking for something more specialized, check out react-native-floating-action. This library does one thing, and it does it exceptionally well: creating beautiful, highly configurable Floating Action Buttons.
This library becomes the obvious choice when:
- A FAB is your primary focus. If your main objective is adding a FAB—especially one that expands to reveal a menu of sub-actions—this library was built from the ground up for that exact purpose.
- You need deep customization for just one component. It gives you a ton of props to fine-tune everything from colors and icons to positioning and animations, all without the baggage of a full UI kit.
- You're working with a custom design system. Because it's so focused, it’s much easier to integrate into an existing, non-Material app without running into frustrating style conflicts.
Here's a simple way to think about it:
react-native-paperis like buying a full set of professional kitchen knives—perfect when you're outfitting a brand-new kitchen.react-native-floating-actionis like buying a single, high-end chef's knife—the ideal tool when you just need the absolute best for one specific, critical job.
Let's break down the comparison even further to help you make a quick decision.
Action Button Library Comparison
| Library | Primary Use Case | Customization Level | Best For |
|---|---|---|---|
| react-native-paper | Comprehensive UI toolkit | High (via theming) | Apps needing a full Material Design system and consistency. |
| react-native-floating-action | Standalone FAB component | High (via props) | Apps needing a highly configurable FAB without a full UI library. |
Ultimately, your project's scope and design requirements should be your guide. For a full-featured app that embraces Material Design, react-native-paper offers incredible value. But if you just need a fantastic, flexible FAB that plays well with a custom design, react-native-floating-action is tough to beat.
Common Questions About React Native Action Buttons
No matter how long you've been working with React Native, a few questions about action buttons seem to pop up on every project. These aren't just beginner hang-ups; they're practical challenges that even seasoned developers run into. Let's dig into some of the most common ones I see in the wild.
How Do You Test an Action Button?
When it comes to testing, you want confidence that your button actually does what it's supposed to do within the flow of your app. For this, my go-to is a "gray-box" end-to-end framework like Detox. It’s become the industry standard for a good reason.
Unlike traditional black-box tools, Detox is smart enough to sync with your app's main thread. It waits for animations to finish and network requests to resolve before it moves on to the next step, which drastically cuts down on flaky, unreliable tests.
To make this work, you have to give Detox a way to find your button. The key is adding a testID prop to your component. This acts as a stable hook for your tests to grab onto.
A typical test flow would look something like this:
- First, you target the button with
element(by.id('your-button-test-id')). - Then, you trigger a press with the
.tap()action, just like a user would. - Finally, you assert that the app responded correctly—maybe by using
expect()to verify a new screen is now visible.
This proves your button is not only on the screen but is also wired up and functioning correctly.
Should I Disable Animations During Tests?
In almost all cases, yes. While Detox is pretty good at handling them, animations are a source of variability you just don't need in a test environment. Disabling them gives you a more controlled, predictable run.
The result? Faster and more consistent test results. You can easily set this up by checking for a test-specific environment flag and conditionally turning off your animations, so they only run for your actual users.
A core principle for reliable end-to-end testing is to eliminate as many variables as you can. Turning off non-essential UI animations is a simple but powerful way to make your tests for an action button in React Native more robust and less likely to fail for random reasons.
How Do I Make My Buttons Accessible?
Accessibility can't be an afterthought—it’s fundamental to building an app that everyone can use. For any interactive element like an action button, you need to use a handful of key props so screen readers like VoiceOver (iOS) and TalkBack (Android) can make sense of them.
Here are the essentials you should always include:
accessible={true}: This is the on-switch. It tells the accessibility services to recognize this as a single, focusable element.accessibilityLabel: This is exactly what the screen reader will announce. It should be a clear, concise description of the button's action, like "Create a new post."accessibilityRole="button": This explicitly tells the user they're interacting with a button, setting the expectation that it's tappable.accessibilityHint: This is for providing extra context. It explains what will happen after the user takes the action, such as "Navigates to the camera screen."
Getting into the habit of adding these props ensures your app is navigable and usable for everyone, regardless of ability.
At React Native Coders, we're all about sharing practical guides and hard-won insights to help you build fantastic mobile apps. Check out our other resources to sharpen your skills and stay on top of the React Native world. Learn more on our website.





















Add Comment