### Get a fresh project setup
Source: https://github.com/heroui-inc/heroui-native-example/blob/main/README.md
Run this command to reset the project to a basic HeroUI Native setup, moving the current src directory to app-example-src.
```bash
npm run reset-project
```
--------------------------------
### Install dependencies
Source: https://github.com/heroui-inc/heroui-native-example/blob/main/README.md
Run this command to install all necessary project dependencies.
```bash
npm install
```
--------------------------------
### Clone the repository
Source: https://github.com/heroui-inc/heroui-native-example/blob/main/README.md
Use these commands to clone the example project repository and navigate into the project directory.
```bash
git clone https://github.com/heroui-inc/heroui-native-example.git
cd heroui-native-example
```
--------------------------------
### Start the app
Source: https://github.com/heroui-inc/heroui-native-example/blob/main/README.md
Execute this command to start the React Native development server and run the application.
```bash
npx expo start
```
--------------------------------
### Basic Dialog Example
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
A simple dialog with a title, description, and a confirmation button. Requires `Dialog`, `Button`, `View` components.
```tsx
import { Dialog, Button, Input, Label, TextField, FieldError, ScrollShadow } from 'heroui-native';
import { LinearGradient } from 'expo-linear-gradient';
import Animated, { FadeInDown, FadeOutDown, Easing } from 'react-native-reanimated';
// Basic dialog
const [open, setOpen] = useState(false);
```
--------------------------------
### App Entry and Provider Setup
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Initializes the application with necessary providers like GestureHandlerRootView, KeyboardProvider, AppThemeProvider, and HeroUINativeProvider. Configures global settings for text scaling, toast behavior, and developer tools.
```tsx
// src/app/_layout.tsx
import { HeroUINativeProvider } from 'heroui-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { KeyboardProvider, KeyboardAvoidingView } from 'react-native-keyboard-controller';
import { AppThemeProvider } from '../contexts/app-theme-context';
import { useFonts, Inter_400Regular, Inter_600SemiBold } from '@expo-google-fonts/inter';
import '../../global.css';
function AppContent() {
const contentWrapper = useCallback(
(children: React.ReactNode) => (
{children}
),
[]
);
return (
);
}
export default function Layout() {
const fonts = useFonts({ Inter_400Regular, Inter_600SemiBold /* ... */ });
if (!fonts) return null;
return (
);
}
```
--------------------------------
### Nested SubMenu Example
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Shows how to implement a nested submenu within a main menu. Requires `SubMenu` component and its associated triggers and content.
```tsx
// Nested SubMenu
```
--------------------------------
### Chip Component Examples
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates various configurations of the Chip component, including different sizes, color variants, and the inclusion of start/end content like icons. Also shows how to create a gradient chip and a chip with a status dot.
```tsx
import { Chip } from 'heroui-native';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet } from 'react-native';
// Sizes
SmallMediumLarge
```
```tsx
// Variants + colors
AccentSuccessDanger
```
```tsx
// With start/end content
NewClose
```
```tsx
// Gradient chip
Gradient
```
```tsx
// Status dot pattern
Pending
```
--------------------------------
### Avatar Component Examples
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates various Avatar component usages including sizes, image/fallback combinations, color variants, custom fallbacks with gradients, and avatar group configurations. Ensure necessary imports like Avatar, cn, and LinearGradient are present.
```tsx
import { Avatar, cn } from 'heroui-native';
import { LinearGradient } from 'expo-linear-gradient';
// Sizes with image + fallback
KWEC
// Color variants for fallback
SCWR
// Custom fallback (gradient, emoji, icon)
GB
// Avatar group with overlap and "+N" overflow
{users.slice(0, 3).map((user, index) => (
{user.initials}
))}
+2
```
--------------------------------
### Card Component Examples
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Illustrates different Card component layouts and styles, including basic cards with titles and descriptions, cards with background images and gradient overlays, and horizontal cards. Requires imports for Card, LinearGradient, Image, and Button.
```tsx
import { Card } from 'heroui-native';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet, Image } from 'react-native';
// Basic card
$450Living room SofaThis sofa is perfect for modern tropical spaces.
// Card with background image + gradient overlay
NeoHome robot
// Horizontal card (variant="tertiary")
Avocado HackathonToday, 6:30 PM
```
--------------------------------
### useVersionCheck Hook for App Store Version Comparison
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Compares the installed app version with the App Store/Play Store listing on mount. Skipped in development. Calls `onVersionChecked` with a boolean indicating if a newer native build is available.
```tsx
import { useVersionCheck } from './helpers/hooks/use-version-check';
function Layout() {
const [isVersionChecked, setIsVersionChecked] = useState(false);
const [isNewVersionAvailable, setIsNewVersionAvailable] = useState(false);
const handleVersionChecked = useCallback((isNew: boolean) => {
setIsVersionChecked(true);
setIsNewVersionAvailable(isNew);
if (isNew) {
// Prompt user to update their native app
setUpdateSheetMode('new-version');
setUpdateSheetOpen(true);
}
}, []);
useVersionCheck({ onVersionChecked: handleVersionChecked });
}
```
--------------------------------
### Clean git history
Source: https://github.com/heroui-inc/heroui-native-example/blob/main/README.md
Optional commands to remove the existing git history and initialize a new one for a fresh start.
```bash
rm -rf .git
git init
git add .
git commit -m "Initial commit"
```
--------------------------------
### Custom Checkbox Indicator with Animation
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Illustrates how to customize the Checkbox indicator using a render prop, allowing for custom icons and animations like ZoomIn. The animation is disabled for this specific example.
```tsx
// Custom indicator with render prop
{( { isSelected }) => (
{isSelected
?
: }
)}
```
--------------------------------
### Accordion Default Variant with Custom Trigger
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Example of the default Accordion variant with single selection. It uses a custom PressableFeedback for the trigger and includes a basic item. Ensure Accordion, PressableFeedback, and relevant icons are imported.
```tsx
import { Accordion, PressableFeedback, useAccordionItem } from 'heroui-native';
import Animated, { ZoomIn, ZoomOut, FadeInRight, Easing } from 'react-native-reanimated';
const CustomIndicator = () => {
const { isExpanded } = useAccordionItem();
return (
{isExpanded
?
: }
);
};
// Default variant, single selection, defaultValue opens item '2'
How do I place an order?Lorem ipsum dolor sit amet...
```
--------------------------------
### Invalid Input Field with Error Message
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
An example of an invalid TextField with a Label, Input, and FieldError. The `isInvalid` prop on TextField and Input controls the visual state, and FieldError displays the error message.
```tsx
import { TextField, Input, Label, Description, FieldError } from 'heroui-native';
// States: disabled + invalid with error message
{ setEmail(text); if (emailError) setEmailError(''); }}
autoCapitalize="none"
isInvalid={false}
selectionColor={themeColorMuted}
/>
{emailError}
```
--------------------------------
### Basic BottomSheet Implementation
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
A standard BottomSheet implementation. Ensure `isOpen` state and `setIsOpen` handler are managed correctly. Imports for `BottomSheet`, `Button`, and `useSafeAreaInsets` are required.
```tsx
import { BottomSheet, Button } from 'heroui-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const [isOpen, setIsOpen] = useState(false);
const insets = useSafeAreaInsets();
// Basic bottom sheet
Delete account?If you delete your account, you won't be able to restore it.
```
--------------------------------
### Popover with Arrow and Placement Configuration
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Use this snippet for standard popovers with arrow indicators. Configure placement, alignment, and offsets for precise positioning. Ensure `colorKit` and `useThemeColor` are imported for dynamic styling.
```tsx
import { Popover, Button, colorKit, useThemeColor } from 'heroui-native';
// Popover with arrow + placement
const themeColorAccent = useThemeColor('accent');
const arrowStroke = colorKit.setAlpha(themeColorAccent, 0.35).hex();
Fun Fact!
The first computer bug was an actual moth found in 1947.
```
--------------------------------
### Selection Groups (Multiple + Single) with Indicators
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Illustrates multiple and single selection groups within a menu, using `MenuKey` for state management. `shouldCloseOnSelect` and `disallowEmptySelection` props are demonstrated.
```tsx
// Selection groups (multiple + single) with indicators
const [textStyles, setTextStyles] = useState>(() => new Set(['bold']));
const [alignment, setAlignment] = useState>(() => new Set(['left']));
```
--------------------------------
### Basic Popover Menu with Danger Item
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates a basic popover menu with a 'danger' variant item. Ensure 'heroui-native' is imported.
```tsx
import { Menu, SubMenu, Button, Separator, type MenuKey } from 'heroui-native';
// Basic popover menu with danger item
```
--------------------------------
### Button Layout Transition Animation
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Shows how to apply layout transitions to a Button, allowing it to morph between states, such as icon-only and full-width, with animations. Requires Reanimated and useState.
```tsx
// Layout transition (morphs between icon-only and full-width)
const [isDownloading, setIsDownloading] = useState(false);
```
--------------------------------
### Button Variants and Sizes
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates the different visual variants and sizing options available for the Button component. Ensure necessary imports are present.
```tsx
import { Button, Spinner, PressableFeedback } from 'heroui-native';
import { LinearGradient } from 'expo-linear-gradient';
import { StyleSheet } from 'react-native';
import Animated, { FadeIn, LinearTransition } from 'react-native-reanimated';
// Variants
// Sizes
```
--------------------------------
### Show Various Toast Notifications with useToast
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates how to trigger different types of toast notifications including default, success, danger, persistent, and custom component toasts. Access the toast system via the `useToast()` hook.
```tsx
import { useToast, Button, type ToastComponentProps } from 'heroui-native';
function MyScreen() {
const { toast, isToastVisible } = useToast();
// Semantic variants
const showDefault = () => toast.show({
variant: 'default',
label: 'Join a team',
description: 'Junior Garcia sent you an invitation to join HeroUI team!',
icon: ,
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
const showSuccess = () => toast.show({
variant: 'success',
placement: 'top', // 'top' | 'bottom'
label: 'Plan upgraded',
description: 'You can continue using HeroUI Chat and more',
icon: ,
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
const showDanger = () => toast.show({
variant: 'danger',
label: 'Storage is full',
description: 'Remove files to release space.',
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
// Persistent toast (id allows programmatic hiding)
const showPersistent = () => toast.show({
id: 'my-toast',
variant: 'default',
placement: 'bottom',
duration: 'persistent',
label: 'Join a team',
description: 'Tap close to dismiss',
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
onHide: () => inputRef.current?.blur(),
});
// Custom component toast (loading, progress, achievement)
const renderLoadingToast = useCallback((props: ToastComponentProps) => (
), []);
const showCustom = async () => {
setIsLoading(true);
toast.show({ id: 'loading', duration: 'persistent', component: renderLoadingToast });
await loadData();
setIsLoading(false);
};
// Hide all
const hideAll = () => toast.hide('all');
return (
);
}
```
--------------------------------
### Button Custom Animation and Gradient
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates advanced customization of the Button component using a gradient background and custom press feedback animations. Ensure LinearGradient and PressableFeedback are imported.
```tsx
// Custom animation + gradient
```
--------------------------------
### Button Disabled and Loading States
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Illustrates how to disable a button or show a loading state with a spinner and text. The spinner color and size can be customized.
```tsx
// Disabled / loading
```
--------------------------------
### Configure Single Select with Default Trigger
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Sets up a single-selection dropdown using the Select component with a default trigger. The selection is managed by the `value` and `onValueChange` state variables.
```tsx
import { Select, Label, Button } from 'heroui-native';
const US_STATES = [
{ value: 'CA', label: 'California' },
{ value: 'NY', label: 'New York' },
{ value: 'TX', label: 'Texas' },
];
// Single select with default trigger
const [value, setValue] = useState(undefined);
```
--------------------------------
### BottomSheet with Blur Overlay
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates using a custom blur backdrop component for the BottomSheet overlay. This is typically used for iOS to achieve a blur effect. Ensure `BottomSheetBlurOverlay` is correctly implemented and imported.
```tsx
// With blur overlay (iOS)
{/* custom blur backdrop component */}
{/* content */}
```
--------------------------------
### Basic Switch in ControlField
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates a basic Switch component integrated within a ControlField for settings lists. It includes Label and Description components for context.
```tsx
import { Switch, ControlField, Label, Description, Surface, Separator } from 'heroui-native';
import Animated, { ZoomIn, FadeInRight, FadeInLeft } from 'react-native-reanimated';
// Basic Switch in ControlField (Settings list pattern)
Receive push notifications {/* renders Switch by default */}
This feature is unavailable
```
--------------------------------
### Select Component
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
A versatile select component supporting various presentation modes (popover, bottom-sheet, dialog), single/multiple selection, and custom triggers.
```APIDOC
## Select Component
Dropdown selection with `popover`, `bottom-sheet`, or `dialog` presentation modes. Supports single and multiple selection, placement/alignment control, searchable variants, and fully custom trigger buttons. Sub-components: `Select.Trigger`, `Select.Value`, `Select.Portal`, `Select.Overlay`, `Select.Content`, `Select.Item`, `Select.ItemIndicator`.
```tsx
import { Select, Label, Button } from 'heroui-native';
const US_STATES = [
{ value: 'CA', label: 'California' },
{ value: 'NY', label: 'New York' },
{ value: 'TX', label: 'Texas' },
];
// Single select with default trigger
const [value, setValue] = useState(undefined);
// Multiple select
// Bottom-sheet presentation with custom snap points + detached
```
```
--------------------------------
### Basic Input Component
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
A simple Input component for text entry. It requires a placeholder and can be configured with keyboard types.
```tsx
import { TextField, Input, Label, Description, FieldError } from 'heroui-native';
// Basic input
```
--------------------------------
### Button Icon-Only and With Icons
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Shows how to use the Button component for icon-only actions or with both an icon and text. Adjust icon size and color as needed.
```tsx
// Icon only
// With icons
```
--------------------------------
### Configure Multiple Select with Popover Presentation
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Implements a multiple-selection dropdown using the Select component. The presentation is set to 'popover' and items are rendered from a predefined list.
```tsx
```
--------------------------------
### Showcase Data Definitions
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Defines an array of showcase objects, each containing a title, navigation path, associated components, and a description. This data structures the content for the showcases section.
```tsx
// src/app/(home)/showcases/index.tsx
// The data array defines each showcase:
const data = [
{
title: 'Super App Paywall',
href: '/showcases/super-app-paywall',
components: ['BottomSheet', 'Tabs', 'ControlField', 'Button', 'Chip'],
description: 'Modern subscription paywall with animated bottom sheet and tab navigation.',
},
{
title: 'Raycast Model Select',
href: '/showcases/raycast',
components: ['Select', 'Button', 'Avatar'],
description: 'AI model selector with animated blur backdrop and spring transitions.',
},
{
title: 'Cooking Onboarding',
href: '/showcases/cooking-onboarding',
components: ['Popover', 'Avatar', 'Button', 'Separator'],
description: 'Multi-step onboarding with automated popover sequences.',
},
{
title: 'Linear Issue',
href: '/showcases/linear-task',
components: ['Dialog', 'Card', 'Chip', 'RadioGroup', 'Checkbox', 'Button', 'Avatar'],
description: 'Interactive task management interface inspired by Linear.',
},
{
title: 'Hero Paywall',
href: '/showcases/paywall',
components: ['Switch', 'ControlField', 'RadioGroup', 'Button'],
description: 'Animated paywall with free trial, secure checkout, and flexible plans.',
},
{
title: 'Onboarding',
href: '/showcases/onboarding',
components: ['Button', 'Card', 'Separator'],
description: 'Onboarding step with marquee carousel of shadowed cards.',
},
];
```
--------------------------------
### Toast Notifications - useToast
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Provides an imperative API for showing toast notifications with various semantic variants, placements, durations, and custom components.
```APIDOC
## Toast — `useToast`
Imperative toast notification system. Shows animated toasts at top or bottom of screen with 6 semantic variants, persistent or timed duration, custom icons, action buttons, keyboard avoidance, and fully custom `component` render prop. Access via `useToast()` hook.
```tsx
import { useToast, Button, type ToastComponentProps } from 'heroui-native';
function MyScreen() {
const { toast, isToastVisible } = useToast();
// Semantic variants
const showDefault = () => toast.show({
variant: 'default',
label: 'Join a team',
description: 'Junior Garcia sent you an invitation to join HeroUI team!',
icon: ,
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
const showSuccess = () => toast.show({
variant: 'success',
placement: 'top', // 'top' | 'bottom'
label: 'Plan upgraded',
description: 'You can continue using HeroUI Chat and more',
icon: ,
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
const showDanger = () => toast.show({
variant: 'danger',
label: 'Storage is full',
description: 'Remove files to release space.',
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
});
// Persistent toast (id allows programmatic hiding)
const showPersistent = () => toast.show({
id: 'my-toast',
variant: 'default',
placement: 'bottom',
duration: 'persistent',
label: 'Join a team',
description: 'Tap close to dismiss',
actionLabel: 'Close',
onActionPress: ({ hide }) => hide(),
onHide: () => inputRef.current?.blur(),
});
// Custom component toast (loading, progress, achievement)
const renderLoadingToast = useCallback((props: ToastComponentProps) => (
), []);
const showCustom = async () => {
setIsLoading(true);
toast.show({ id: 'loading', duration: 'persistent', component: renderLoadingToast });
await loadData();
setIsLoading(false);
};
// Hide all
const hideAll = () => toast.hide('all');
return (
);
}
```
```
--------------------------------
### Configure Bottom-Sheet Select with Customization
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Configures a Select component to use a 'bottom-sheet' presentation with custom snap points and detached mode. Includes a custom trigger button and styled content container.
```tsx
```
--------------------------------
### Dialog with Scrollable Content and ScrollShadow
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
A dialog featuring long, scrollable content using `ScrollShadow` and `ScrollView`. Includes `LinearGradient` for backdrop effect. Requires `ScrollShadow`, `ScrollView`, `Text`, `LinearGradient`.
```tsx
// Dialog with scrollable long content + ScrollShadow
```
--------------------------------
### Input Variants: Primary and Secondary
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates the 'primary' (default) and 'secondary' (surface-style) variants of the Input component within TextField containers.
```tsx
import { TextField, Input, Label, Description, FieldError } from 'heroui-native';
// Variants: primary (default) vs secondary (surface-style)
```
--------------------------------
### Component Registry Data
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Defines a list of component items, each with a title and path, used for navigation and indexing.
```typescript
// src/helpers/data/components.ts
export const COMPONENTS: ComponentItem[] = [
{ title: 'Accordion', path: 'accordion' },
{ title: 'Alert', path: 'alert' },
{ title: 'Avatar', path: 'avatar' },
{ title: 'BottomSheet', path: 'bottom-sheet' },
{ title: 'Button', path: 'button' },
{ title: 'Card', path: 'card' },
{ title: 'Checkbox', path: 'checkbox' },
{ title: 'Chip', path: 'chip' },
{ title: 'CloseButton', path: 'close-button' },
{ title: 'ControlField', path: 'control-field' },
{ title: 'Description', path: 'description' },
{ title: 'Dialog', path: 'dialog' },
{ title: 'FieldError', path: 'field-error' },
{ title: 'Input', path: 'input' },
{ title: 'InputGroup', path: 'input-group' },
{ title: 'InputOTP', path: 'input-otp' },
{ title: 'Label', path: 'label' },
{ title: 'LinkButton', path: 'link-button' },
{ title: 'ListGroup', path: 'list-group' },
{ title: 'Menu', path: 'menu' },
{ title: 'Popover', path: 'popover' },
{ title: 'PressableFeedback',path: 'pressable-feedback' },
{ title: 'RadioGroup', path: 'radio-group' },
{ title: 'ScrollShadow', path: 'scroll-shadow' },
{ title: 'SearchField', path: 'search-field' },
{ title: 'Select', path: 'select' },
{ title: 'Separator', path: 'separator' },
{ title: 'Skeleton', path: 'skeleton' },
{ title: 'Slider', path: 'slider' },
{ title: 'Spinner', path: 'spinner' },
{ title: 'Surface', path: 'surface' },
{ title: 'Switch', path: 'switch' },
{ title: 'Tabs', path: 'tabs' },
{ title: 'TagGroup', path: 'tag-group' },
{ title: 'TextArea', path: 'text-area' },
{ title: 'TextField', path: 'text-field' },
{ title: 'Toast', path: 'toast' },
];
```
--------------------------------
### Dialog with Custom Animation and Form Inputs
Source: https://context7.com/heroui-inc/heroui-native-example/llms.txt
Demonstrates a dialog with custom entering/exiting animations and form inputs, including keyboard avoidance. Uses `FadeInDown` and `FadeOutDown` from `react-native-reanimated`. Requires `TextField`, `Label`, `FieldError`, `Input`.
```tsx
// Dialog with custom animation + form inputs (positioned at top with keyboard avoidance)
```