How to Add a Gradient to Your Expo App

DavidDavid October 22, 2026 7 min read

How to add a gradient to your Expo app, in short

Use expo-linear-gradient. Install it with npx expo install expo-linear-gradient, import it with import { LinearGradient } from 'expo-linear-gradient', and render <LinearGradient colors={['#4c669f', '#3b5998', '#192f6a']} style={{ flex: 1 }} />. It is a native view that blends between the colors you give it in a straight line, and you size and position it with style exactly like a View.

That one component covers the gradients most indie apps ship: a hero background on the onboarding screen, a call-to-action button, a dark fade over a photo so the caption stays readable, a premium badge on the paywall. What decides whether it looks designed or accidental is direction, stop placement, and knowing when you do not need the package at all. That is what this guide covers.

Step 1: Install expo-linear-gradient

  1. Install: npx expo install expo-linear-gradient. Using expo install picks the version that matches your SDK.
  2. Import: import { LinearGradient } from 'expo-linear-gradient'. It is a named export, not a default export, which is a common source of an undefined component error.
  3. Start testing in Expo Go. The reference lists it as included in Expo Go, on Android, iOS, tvOS and web.
  4. There is no permission and no app.json config plugin to add. It is purely a view, so nothing changes in your App Store privacy answers.

Step 2: Render your first gradient

The smallest working example: <LinearGradient colors={['#4c669f', '#192f6a']} style={{ flex: 1 }} />. LinearGradient accepts the normal View props, so style, padding, borderRadius and children all work. Anything you put inside it renders on top of the gradient. The reference's own example uses that for a sign-in button: a LinearGradient with padding and a borderRadius, wrapping a white Text label.

  • colors must contain at least two colors. For a single solid color, the reference says to use backgroundColor on a plain View instead.
  • TypeScript expects colors to be a readonly tuple of two or more values. Pass the array inline, or declare it with as const, for example const brand = ['#4c669f', '#192f6a'] as const. A plain string[] from a theme file will raise a type error.
  • Any color format React Native understands works, including hex, rgba() and 'transparent'.
  • The gradient has no size of its own. If you see nothing, it is almost always a missing height or flex on the style.

Step 3: Control direction with start and end

start and end are points expressed as fractions of the gradient's own size, from 0 to 1. You can pass them as an object { x, y } or as an array [x, y]. x: 0 is the left edge and x: 1 the right; y: 0 is the top and y: 1 the bottom. In the library source the defaults are start { x: 0.5, y: 0 } and end { x: 0.5, y: 1 }, which is why a gradient with no start or end runs from top to bottom.

Common directions with start and end

Directionstartend
Top to bottom (default){ x: 0.5, y: 0 }{ x: 0.5, y: 1 }
Left to right{ x: 0, y: 0.5 }{ x: 1, y: 0.5 }
Top-left to bottom-right{ x: 0, y: 0 }{ x: 1, y: 1 }
Bottom to top{ x: 0.5, y: 1 }{ x: 0.5, y: 0 }

Step 4: Place color stops with locations

By default the colors are spread evenly. locations lets you choose where each one sits. It is an array of numbers from 0 to 1, the same length as colors, in ascending order. The reference's example: with two colors and locations={[0.5, 0.8]}, the first color is solid for the first half, blends into the second color between 50% and 80%, and the second color is solid from 80% to the end.

  • Keep locations the same length as colors. In the library source, a mismatch logs a console warning and the extra locations are cut off, so the result may not be what you designed.
  • Values must go from least to greatest.
  • Hard edges are a design choice, not a bug: two stops at almost the same location give a sharp band, useful for a two-tone header.
  • On Android, dither (default true) reduces visible color banding in smooth gradients. The reference notes that setting it to false may improve rendering performance, so only turn it off if you have measured a problem.

Step 5: Overlays, buttons and cards

The pattern you will reach for most is the readability overlay: an image fills a card, and a gradient fades from transparent to dark at the bottom so white text on top stays legible. Put the image and the gradient in the same parent, give the gradient position: 'absolute' with left: 0, right: 0, bottom: 0 and a fixed height, then use colors={['transparent', 'rgba(0,0,0,0.8)']}. The reference's own example does the same thing at the top of the screen with colors={['rgba(0,0,0,0.8)', 'transparent']} and a height of 300.

  • Gradient button: wrap the gradient in a Pressable rather than making the gradient itself tappable, and put borderRadius on the gradient's style so the corners clip. Keep an accessible label on the Pressable.
  • Card background: LinearGradient takes children, so it can replace the outer View of a card directly.
  • Theme-aware gradients: keep a light and a dark pair of colors and pick one with useColorScheme. A gradient tuned for a white background can look muddy on black. See [how to add dark mode to your Expo app](/blog/how-to-add-dark-mode-to-your-expo-app) for the theme setup.
  • Onboarding and launch screens: a gradient is a good first screen after the splash, but the native splash itself is an image, not a component. See [how to add a splash screen to your Expo app](/blog/how-to-add-a-splash-screen-to-your-expo-app) for that part.

Step 6: Gradient text with MaskedView

expo-linear-gradient fills a rectangle; it does not color text. For gradient text, combine it with @react-native-masked-view/masked-view. Install it with npx expo install @react-native-masked-view/masked-view. It is included in Expo Go, and it shows only the pixels of its children that overlap the element you pass as maskElement.

The shape: <MaskedView maskElement={<Text style={styles.title}>Launch day</Text>}><LinearGradient colors={['#ff7a59', '#8a2be2']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}><Text style={[styles.title, { opacity: 0 }]}>Launch day</Text></LinearGradient></MaskedView>. The mask works off the alpha channel, so the visible text color in the mask does not matter, only its shape. The invisible copy inside the gradient is there to give the gradient the same size as the text.

When you do not need expo-linear-gradient

React Native now has a built-in option. The Expo reference points out that the View style property backgroundImage supports CSS gradient syntax such as linear-gradient() and radial-gradient() on Android, iOS and web, which can replace the package for simple gradient backgrounds without adding a dependency. The React Native reference shows it as style={{ backgroundImage: 'linear-gradient(45deg, blue, red)' }}.

Which gradient option to pick

NeedUseWhy
Simple background, current React Nativestyle backgroundImageNo extra dependency, CSS syntax you may already know
Radial gradientstyle backgroundImageexpo-linear-gradient only draws linear gradients
Same code across older SDKs, or tvOSexpo-linear-gradientLong-standing Expo module with a stable prop API
Gradient textexpo-linear-gradient plus MaskedViewA gradient view under a text-shaped mask

Our take: for a new app on a current SDK, try backgroundImage first for plain backgrounds, and reach for expo-linear-gradient when you need gradient text, children layered in a reusable component, or behavior that matches older code. Whichever you choose, use one approach across the app so the next change is predictable.

Mistakes that make gradients look wrong

  • Importing it as a default export instead of import { LinearGradient } from 'expo-linear-gradient'.
  • Giving the gradient no height or flex, so it renders at zero size.
  • Passing a single color. Use backgroundColor on a View for that.
  • A locations array that is a different length from colors, or not in ascending order.
  • Expecting start and end positions to behave the same on web, where only the angle changes.
  • Typing colors as string[] in a theme file and fighting TypeScript, instead of using as const.
  • Putting a gradient behind text without checking contrast in both light and dark mode.

Have Claude Code set it up for you

Open your project in the Claude Code desktop app and be specific. Left to its own judgment, AI-written code tends to hard-code a new color array in every file, so the gradients drift apart as you tweak the design. A prompt that keeps it tidy:

Then add a line to your [CLAUDE.md](/blog/claude-md-for-expo-apps) such as "All gradients come from src/theme/gradients.ts; never inline a colors array" so a later session does not scatter new ones around. Check the result in Expo Go on a real phone in both light and dark mode, since a gradient that looks right in the simulator can band or lose contrast on a real screen.

The short version

To add a gradient to your Expo app: install expo-linear-gradient, render LinearGradient with at least two colors and a size, set the direction with start and end, and place stops with locations. Use it as a background, a button, or an overlay on images. For gradient text, layer it under MaskedView. For simple backgrounds on a current SDK, the built-in backgroundImage style may be all you need.

If you are building your first iOS app with Claude Code and Expo and want a second pair of eyes on it before App Review, bring it to App Store Launch Club. Members share their builds for feedback, and the [curriculum](/curriculum) covers the full path from first build to first users. Join at applaunchclub.co for $9 a month.

Free app-building tips, straight to your inbox

Short, practical drops on app ideas, validating fast, store listings, and passing app review. No spam, unsubscribe anytime.

Frequently asked questions

How do I make a gradient background in Expo?

Install expo-linear-gradient with npx expo install, then render <LinearGradient colors={['#4c669f', '#192f6a']} style={{ flex: 1 }} />. Put your screen content inside it as children.

Does expo-linear-gradient work in Expo Go?

Yes. The reference lists it as included in Expo Go, and it works on Android, iOS, tvOS and web.

How do I make a horizontal gradient in Expo?

Set start={{ x: 0, y: 0.5 }} and end={{ x: 1, y: 0.5 }}. Without start and end, the gradient runs from top to bottom.

What does the locations prop do in LinearGradient?

It sets where each color stop sits, as numbers from 0 to 1 in ascending order. It must be the same length as colors. If you leave it out, the colors are spread evenly.

Why does TypeScript reject my colors array?

colors is typed as a readonly tuple of at least two colors. Pass the array inline or declare it with as const instead of as a plain string[].

How do I make gradient text in Expo?

Wrap a LinearGradient in MaskedView from @react-native-masked-view/masked-view and pass your Text as the maskElement. Android support for masked-view is marked experimental, so test it on a real device.

Can I make a gradient in React Native without a library?

Yes. The View style property backgroundImage supports CSS syntax like linear-gradient() and radial-gradient() on Android, iOS and web, which covers simple gradient backgrounds without an extra package.

Last reviewed by David on October 22, 2026

David

Written by

David

Founder and app builder

Keep reading

ExpoClaude Code

How to Add Notification Actions to Your Expo App

To add notification actions to an Expo app, register a category with Notifications.setNotificationCategoryAsync, give it action buttons (and optionally a text reply), set categoryIdentifier on the notification, then read response.actionIdentifier in a response listener. Here is every action option, how to handle taps when the app was closed, the Android and iOS differences, and a Claude Code prompt that wires it all up.

David 8 min
Read article
ExpoClaude Code

How to Schedule Local Notifications in Your Expo App

To schedule local notifications in an Expo app, install expo-notifications, set a notification handler, ask for permission, create an Android channel, then call scheduleNotificationAsync with your content and a trigger like DAILY, WEEKLY or DATE. Here is every trigger type, how to cancel and list what is scheduled, why Android reminders arrive late, and a Claude Code prompt that builds the whole reminder flow.

David 8 min
Read article

Ready to build it yourself?

Join App Store Launch Club, the #1 community for building and launching apps, for $9/month.

← Back to the blog