# Button **Category**: native **URL**: https://v3.heroui.com/docs/native/components/button **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(buttons)/button.mdx > Interactive component that triggers an action when pressed. ## Import ```tsx import { Button } from 'heroui-native'; ``` ## Anatomy ```tsx ``` * **Button**: Main container that handles press interactions, animations, and variants. Renders string children as label or accepts compound components for custom layouts. * **Button.Label**: Text content of the button. Inherits size and variant styling from parent Button context. ## Usage ### Basic Usage The Button component accepts string children that automatically render as label. ```tsx ``` ### With Compound Parts Use Button.Label for explicit control over the label component. ```tsx ``` ### With Icons Combine icons with labels for enhanced visual communication. ```tsx ``` ### Icon Only Create square icon-only buttons using the isIconOnly prop. ```tsx ``` ### Sizes Control button dimensions with three size options. ```tsx ``` ### Variants Choose from seven visual variants for different emphasis levels. ```tsx ``` ### Feedback Variants Choose between highlight, ripple, or no feedback effects for press interactions. ```tsx { /* Highlight feedback (default) */ } ; { /* Ripple feedback */ } ; { /* No feedback overlay (only scale animation) */ } ; { /* Customize highlight animation */ } ; { /* Customize ripple animation */ } ; ``` ### Loading State with Spinner Transform button to loading state with spinner animation. ```tsx const themeColorAccentForeground = useThemeColor('accent-foreground'); ; ``` ### Custom Background with LinearGradient Add gradient backgrounds using absolute positioned elements. Use `pressableFeedbackVariant="none"` to disable the default highlight overlay, or add a custom ripple effect. ```tsx import { Button, PressableFeedback } from 'heroui-native'; import { LinearGradient } from 'expo-linear-gradient'; import { StyleSheet } from 'react-native'; { /* Gradient with no feedback overlay */ } ; { /* Gradient with custom ripple effect */ } ; ``` ## Example ```tsx import { Button, useThemeColor } from 'heroui-native'; import { Ionicons } from '@expo/vector-icons'; import { View } from 'react-native'; export default function ButtonExample() { const [ themeColorAccentForeground, themeColorAccentSoftForeground, themeColorDangerForeground, themeColorDefaultForeground, ] = useThemeColor([ 'accent-foreground', 'accent-soft-foreground', 'danger-foreground', 'default-foreground', ]); return ( ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/button.tsx). ## API Reference ### Button Button extends all props from [PressableFeedback](./pressable-feedback) component with additional button-specific props. | prop | type | default | description | | --------------------------------- | --------------------------------------------------------------------------------------------- | ------------- | -------------------------------------------------------------- | | `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'outline' \| 'ghost' \| 'danger' \| 'danger-soft'` | `'primary'` | Visual variant of the button | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the button | | `isIconOnly` | `boolean` | `false` | Whether the button displays an icon only (square aspect ratio) | | `pressableFeedbackVariant` | `'highlight' \| 'ripple' \| 'none'` | `'highlight'` | Variant of pressable feedback effect | | `pressableFeedbackHighlightProps` | `PressableFeedbackHighlightProps` | - | Props for PressableFeedback.Highlight component | | `pressableFeedbackRippleProps` | `PressableFeedbackRippleProps` | - | Props for PressableFeedback.Ripple component | For inherited props including `animation` (for root scale animation), `isDisabled`, `className`, `children`, and all Pressable props, see [PressableFeedback API Reference](./pressable-feedback#api-reference). ### Button.Label | prop | type | default | description | | -------------- | ----------------- | ------- | ------------------------------------- | | `children` | `React.ReactNode` | - | Content to be rendered as label | | `className` | `string` | - | Additional CSS classes | | `...TextProps` | `TextProps` | - | All standard Text props are supported | ## Hooks ### useButton Hook to access the Button context values. Returns the button's size, variant, and disabled state. ```tsx import { useButton } from 'heroui-native'; const { size, variant, isDisabled } = useButton(); ``` #### Return Value | property | type | description | | ------------ | --------------------------------------------------------------------------------------------- | ------------------------------ | | `size` | `'sm' \| 'md' \| 'lg'` | Size of the button | | `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'outline' \| 'ghost' \| 'danger' \| 'danger-soft'` | Visual variant of the button | | `isDisabled` | `boolean` | Whether the button is disabled | **Note:** This hook must be used within a `Button` component. It will throw an error if called outside of the button context. # CloseButton **Category**: native **URL**: https://v3.heroui.com/docs/native/components/close-button **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(buttons)/close-button.mdx > Button component for closing dialogs, modals, or dismissing content. ## Import ```tsx import { CloseButton } from 'heroui-native'; ``` ## Usage ### Basic Usage The CloseButton component renders a close icon button with default styling. ```tsx ``` ### Custom Icon Color Customize the icon color using the `iconProps` prop. ```tsx ``` ### Custom Icon Size Adjust the icon size using the `iconProps` prop. ```tsx ``` ### Custom Children Replace the default close icon with custom content. ```tsx ``` ### Disabled State Disable the button to prevent interactions. ```tsx ``` ## Example ```tsx import { CloseButton, useThemeColor } from 'heroui-native'; import { Ionicons } from '@expo/vector-icons'; import { View } from 'react-native'; import { withUniwind } from 'uniwind'; const StyledIonicons = withUniwind(Ionicons); export default function CloseButtonExample() { const themeColorForeground = useThemeColor('foreground'); const themeColorDanger = useThemeColor('danger'); return ( ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/close-button.tsx). ## API Reference ### CloseButton CloseButton extends all props from [Button](./button) component. It defaults to `variant='tertiary'`, `size='sm'`, and `isIconOnly=true`. | prop | type | default | description | | ----------- | ---------------------- | ------- | ------------------------------------------------ | | `iconProps` | `CloseButtonIconProps` | - | Props for customizing the close icon | | `children` | `React.ReactNode` | - | Custom content to replace the default close icon | For inherited props including `isDisabled`, `className`, `animation`, `pressableFeedbackVariant`, `pressableFeedbackHighlightProps`, `pressableFeedbackRippleProps`, and all Pressable props, see [Button API Reference](./button#api-reference). #### CloseButtonIconProps | prop | type | default | description | | ------- | -------- | ---------------------- | ----------------- | | `size` | `number` | `20` | Size of the icon | | `color` | `string` | Uses theme muted color | Color of the icon | # Chip **Category**: native **URL**: https://v3.heroui.com/docs/native/components/chip **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(data-display)/chip.mdx > Displays a compact element in a capsule shape. ## Import ```tsx import { Chip } from 'heroui-native'; ``` ## Anatomy ```tsx ... ``` * **Chip**: Main container that displays a compact element * **Chip.Label**: Text content of the chip ## Usage ### Basic Usage The Chip component displays text or custom content in a capsule shape. ```tsx Basic Chip ``` ### Sizes Control the chip size with the `size` prop. ```tsx Small Medium Large ``` ### Variants Choose between different visual styles with the `variant` prop. ```tsx Primary Secondary Tertiary Soft ``` ### Colors Apply different color themes with the `color` prop. ```tsx Accent Default Success Warning Danger ``` ### With Icons Add icons or custom content alongside text using compound components. ```tsx Featured Close ``` ### Custom Styling Apply custom styles using className or style props. ```tsx Custom ``` ### Disable All Animations Disable all animations including children by using the `"disable-all"` value for the `animation` prop. ```tsx { /* Disable all animations including children */ } No Animations; ``` ## Example ```tsx import { Chip } from 'heroui-native'; import { View, Text } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; export default function ChipExample() { return ( Small Medium Large Primary Success Premium Remove Custom ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/chip.tsx). ## API Reference ### Chip | prop | type | default | description | | ------------------- | ------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Content to render inside the chip | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the chip | | `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'soft'` | `'primary'` | Visual variant of the chip | | `color` | `'accent' \| 'default' \| 'success' \| 'warning' \| 'danger'` | `'accent'` | Color theme of the chip | | `className` | `string` | - | Additional CSS classes to apply | | `animation` | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | `...PressableProps` | `PressableProps` | - | All Pressable props are supported | ### Chip.Label | prop | type | default | description | | -------------- | ----------------- | ------- | -------------------------------------- | | `children` | `React.ReactNode` | - | Text or content to render as the label | | `className` | `string` | - | Additional CSS classes to apply | | `...TextProps` | `TextProps` | - | All standard Text props are supported | ## Hooks ### useChip Hook to access the Chip context values. Returns the chip's size, variant, and color. ```tsx import { useChip } from 'heroui-native'; const { size, variant, color } = useChip(); ``` #### Return Value | property | type | description | | --------- | ------------------------------------------------------------- | -------------------------- | | `size` | `'sm' \| 'md' \| 'lg'` | Size of the chip | | `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'soft'` | Visual variant of the chip | | `color` | `'accent' \| 'default' \| 'success' \| 'warning' \| 'danger'` | Color theme of the chip | **Note:** This hook must be used within a `Chip` component. It will throw an error if called outside of the chip context. # Alert **Category**: native **URL**: https://v3.heroui.com/docs/native/components/alert **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(feedback)/alert.mdx > Displays important messages and notifications to users with status indicators. ## Import ```tsx import { Alert } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ``` * **Alert**: Main container with `role="alert"` and status-based styling. Provides status context to sub-components via a primitive context. * **Alert.Indicator**: Renders a status-appropriate icon by default. Accepts custom children to override the default icon. Supports `iconProps` for customising size and color. * **Alert.Content**: Wrapper for the title and description. Provides layout structure for text content. * **Alert.Title**: Heading text with status-based color. Connected to root via `aria-labelledby`. * **Alert.Description**: Body text rendered with muted color. Connected to root via `aria-describedby`. ## Usage ### Basic Usage The Alert component uses compound parts to display a notification with an icon, title, and description. ```tsx New features available Check out our latest updates including dark mode support and improved accessibility features. ``` ### Status Variants Set the `status` prop to control the icon and title color. Available statuses are `default`, `accent`, `success`, `warning`, and `danger`. ```tsx Success ... Scheduled maintenance ... Unable to connect ... ``` ### Title Only Omit `Alert.Description` for a compact single-line alert. ```tsx Profile updated successfully ``` ### With Action Buttons Place additional elements like buttons alongside the content. ```tsx Update available A new version of the application is available. ``` ### Custom Indicator Replace the default status icon by passing custom children to `Alert.Indicator`. ```tsx Processing your request Please wait while we sync your data. ``` ### Custom Styling Apply custom styles using the `className` prop on the root and compound parts. ```tsx ... ... ``` ## Example ```tsx import { Alert, Button, CloseButton } from 'heroui-native'; import { View } from 'react-native'; export default function AlertExample() { return ( Update available A new version of the application is available. Please refresh to get the latest features and bug fixes. Unable to connect to server Unable to connect to the server. Check your internet connection and try again. Profile updated successfully ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/alert.tsx). ## API Reference ### Alert | prop | type | default | description | | -------------- | ------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Children elements to render inside the alert | | `status` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | `'default'` | Status controlling the icon and color treatment | | `id` | `string \| number` | - | Unique identifier for the alert. Auto-generated when not provided | | `className` | `string` | - | Additional CSS classes | | `style` | `ViewStyle` | - | Additional styles applied to the root container | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### Alert.Indicator | prop | type | default | description | | -------------- | ----------------- | ------- | ------------------------------------------------------------------ | | `children` | `React.ReactNode` | - | Custom children to render instead of the default status icon | | `className` | `string` | - | Additional CSS classes | | `iconProps` | `AlertIconProps` | - | Props passed to the default status icon (size and color overrides) | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### AlertIconProps | prop | type | default | description | | ------- | -------- | ------------ | ---------------------- | | `size` | `number` | `18` | Icon size in pixels | | `color` | `string` | status color | Icon color as a string | ### Alert.Content | prop | type | default | description | | -------------- | ----------------- | ------- | --------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Children elements (typically Alert.Title and Alert.Description) | | `className` | `string` | - | Additional CSS classes | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### Alert.Title | prop | type | default | description | | -------------- | ----------------- | ------- | -------------------------------------------------- | | `children` | `React.ReactNode` | - | Title text content | | `className` | `string` | - | Additional CSS classes | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ### Alert.Description | prop | type | default | description | | -------------- | ----------------- | ------- | -------------------------------------------------- | | `children` | `React.ReactNode` | - | Description text content | | `className` | `string` | - | Additional CSS classes | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ## Hooks ### useAlert Hook to access the alert root context. Must be used within an `Alert` component. ```tsx import { useAlert } from 'heroui-native'; const { status, nativeID } = useAlert(); ``` #### Returns | property | type | description | | ---------- | ------------------------------------------------------------- | ------------------------------------------------------------ | | `status` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | Current alert status for sub-component styling | | `nativeID` | `string` | Unique identifier used for accessibility and ARIA attributes | # SkeletonGroup **Category**: native **URL**: https://v3.heroui.com/docs/native/components/skeleton-group **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(feedback)/skeleton-group.mdx > Coordinates multiple skeleton loading placeholders with centralized animation control. ## Import ```tsx import { SkeletonGroup } from 'heroui-native'; ``` ## Anatomy ```tsx ``` * **SkeletonGroup**: Root container that provides centralized control for all skeleton items * **SkeletonGroup.Item**: Individual skeleton item that inherits props from the parent group ## Usage ### Basic Usage The SkeletonGroup component manages multiple skeleton items with shared loading state and animation. ```tsx ``` ### With Container Layout Use className on the group to control layout of skeleton items. ```tsx ``` ### With isSkeletonOnly for Pure Skeleton Layouts Use `isSkeletonOnly` when the group contains only skeleton placeholders with layout wrappers (like View) that have no content to render in the loaded state. This prop hides the entire group when `isLoading` is false, preventing empty containers from affecting your layout. ```tsx {/* This View is only for layout, no content */} ``` ### With Animation Variants Control animation style for all items in the group. ```tsx ``` ### With Custom Animation Configuration Configure shimmer or pulse animations for the entire group. ```tsx ``` ### With Enter/Exit Animations Apply Reanimated transitions when the group appears or disappears. ```tsx ``` ## Example ```tsx import { Card, SkeletonGroup, Avatar } from 'heroui-native'; import { useState } from 'react'; import { Text, View, Image } from 'react-native'; export default function SkeletonGroupExample() { const [isLoading, setIsLoading] = useState(true); return ( John Doe @johndoe This is the first line of the post content. Second line with more interesting content to read. Last line is shorter. ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/skeleton-group.tsx). ## API Reference ### SkeletonGroup | prop | type | default | description | | ----------------------- | -------------------------------- | ----------- | ---------------------------------------------------------------------- | | `children` | `React.ReactNode` | - | SkeletonGroup.Item components and layout elements | | `isLoading` | `boolean` | `true` | Whether the skeleton items are currently loading | | `isSkeletonOnly` | `boolean` | `false` | Hides entire group when isLoading is false (for skeleton-only layouts) | | `variant` | `'shimmer' \| 'pulse' \| 'none'` | `'shimmer'` | Animation variant for all items in the group | | `animation` | `SkeletonRootAnimation` | - | Animation configuration | | `className` | `string` | - | Additional CSS classes for the group container | | `style` | `StyleProp` | - | Custom styles for the group container | | `...Animated.ViewProps` | `AnimatedProps` | - | All Reanimated Animated.View props are supported | #### SkeletonRootAnimation Animation configuration for SkeletonGroup component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------------ | ---------------------------------------- | --------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `entering.value` | `EntryOrExitLayoutType` | `FadeIn` | Custom entering animation | | `exiting.value` | `EntryOrExitLayoutType` | `FadeOut` | Custom exiting animation | | `shimmer.duration` | `number` | `1500` | Animation duration in milliseconds | | `shimmer.speed` | `number` | `1` | Speed multiplier for the animation | | `shimmer.highlightColor` | `string` | - | Highlight color for the shimmer effect | | `shimmer.easing` | `EasingFunction` | `Easing.linear` | Easing function for the animation | | `pulse.duration` | `number` | `1000` | Animation duration in milliseconds | | `pulse.minOpacity` | `number` | `0.5` | Minimum opacity value | | `pulse.maxOpacity` | `number` | `1` | Maximum opacity value | | `pulse.easing` | `EasingFunction` | `Easing.inOut(Easing.ease)` | Easing function for the animation | ### SkeletonGroup.Item | prop | type | default | description | | ----------------------- | -------------------------------- | --------- | ------------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Content to show when not loading | | `isLoading` | `boolean` | inherited | Whether the skeleton is currently loading (overrides group setting) | | `variant` | `'shimmer' \| 'pulse' \| 'none'` | inherited | Animation variant (overrides group setting) | | `animation` | `SkeletonRootAnimation` | inherited | Animation configuration (overrides group setting) | | `className` | `string` | - | Additional CSS classes for styling the item | | `...Animated.ViewProps` | `AnimatedProps` | - | All Reanimated Animated.View props are supported | ## Special Notes ### Props Inheritance SkeletonGroup.Item components inherit all animation-related props from their parent SkeletonGroup: * `isLoading` * `variant` * `animation` Individual items can override any inherited prop by providing their own value. # Skeleton **Category**: native **URL**: https://v3.heroui.com/docs/native/components/skeleton **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(feedback)/skeleton.mdx > Displays a loading placeholder with shimmer or pulse animation effects. ## Import ```tsx import { Skeleton } from 'heroui-native'; ``` ## Anatomy The Skeleton component is a simple wrapper that renders a placeholder for content that is loading. It does not have any child components. ```tsx ``` ## Usage ### Basic Usage The Skeleton component creates an animated placeholder while content is loading. ```tsx ``` ### With Content Show skeleton while loading, then display content when ready. ```tsx Loaded Content ``` ### Animation Variants Control the animation style with the `variant` prop. ```tsx ``` ### Custom Shimmer Configuration Customize the shimmer effect with duration, speed, and highlight color. ```tsx ... ``` ### Custom Pulse Configuration Configure pulse animation with duration and opacity range. ```tsx ... ``` ### Shape Variations Create different skeleton shapes using className for styling. ```tsx ``` ### Custom Enter/Exit Animations Apply custom Reanimated transitions when skeleton appears or disappears. ```tsx ... ``` ## Example ```tsx import { Avatar, Card, Skeleton } from 'heroui-native'; import { useState } from 'react'; import { Image, Text, View } from 'react-native'; export default function SkeletonExample() { const [isLoading, setIsLoading] = useState(true); return ( John Doe @johndoe ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/skeleton.tsx). ## API Reference ### Skeleton | prop | type | default | description | | ----------------------- | -------------------------------- | ----------- | ------------------------------------------------------------ | | `children` | `React.ReactNode` | - | Content to show when not loading | | `isLoading` | `boolean` | `true` | Whether the skeleton is currently loading | | `variant` | `'shimmer' \| 'pulse' \| 'none'` | `'shimmer'` | Animation variant | | `animation` | `SkeletonRootAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `className` | `string` | - | Additional CSS classes for styling | | `...Animated.ViewProps` | `AnimatedProps` | - | All Reanimated Animated.View props are supported | #### SkeletonRootAnimation Animation configuration for Skeleton component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------------ | ---------------------------------------- | --------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `entering.value` | `EntryOrExitLayoutType` | `FadeIn` | Custom entering animation | | `exiting.value` | `EntryOrExitLayoutType` | `FadeOut` | Custom exiting animation | | `shimmer.duration` | `number` | `1500` | Animation duration in milliseconds | | `shimmer.speed` | `number` | `1` | Speed multiplier for the animation | | `shimmer.highlightColor` | `string` | - | Highlight color for the shimmer effect | | `shimmer.easing` | `EasingFunction` | `Easing.linear` | Easing function for the animation | | `pulse.duration` | `number` | `1000` | Animation duration in milliseconds | | `pulse.minOpacity` | `number` | `0.5` | Minimum opacity value | | `pulse.maxOpacity` | `number` | `1` | Maximum opacity value | | `pulse.easing` | `EasingFunction` | `Easing.inOut(Easing.ease)` | Easing function for the animation | # Spinner **Category**: native **URL**: https://v3.heroui.com/docs/native/components/spinner **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(feedback)/spinner.mdx > Displays an animated loading indicator. ## Import ```tsx import { Spinner } from 'heroui-native'; ``` ## Anatomy ```tsx ... ``` * **Spinner**: Main container that controls loading state, size, and color. Renders a default animated indicator if no children provided. * **Spinner.Indicator**: Optional sub-component for customizing animation configuration and icon appearance. Accepts custom children to replace the default icon. ## Usage ### Basic Usage The Spinner component displays a rotating loading indicator. ```tsx ``` ### Sizes Control the spinner size with the `size` prop. ```tsx ``` ### Colors Use predefined color variants or custom colors. ```tsx ``` ### Loading State Control the visibility of the spinner with the `isLoading` prop. ```tsx ``` ### Animation Speed Customize the rotation speed using the `animation` prop on the Indicator component. ```tsx ``` ### Custom Icon Replace the default spinner icon with custom content. ```tsx const themeColorForeground = useThemeColor('foreground') ``` ## Example ```tsx import { Spinner } from 'heroui-native'; import { Ionicons } from '@expo/vector-icons'; import React from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; export default function SpinnerExample() { const [isLoading, setIsLoading] = React.useState(true); return ( Loading content... Processing... setIsLoading(!isLoading)}> {isLoading ? 'Tap to stop' : 'Tap to start'} ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/spinner.tsx). ## API Reference ### Spinner | prop | type | default | description | | -------------- | ----------------------------------------------------------- | ----------- | -------------------------------------------------- | | `children` | `React.ReactNode` | `undefined` | Content to render inside the spinner | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the spinner | | `color` | `'default' \| 'success' \| 'warning' \| 'danger' \| string` | `'default'` | Color theme of the spinner | | `isLoading` | `boolean` | `true` | Whether the spinner is loading | | `className` | `string` | `undefined` | Custom class name for the spinner | | `animation` | `SpinnerRootAnimation` | - | Animation configuration | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### SpinnerRootAnimation Animation configuration for Spinner component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ---------------- | ---------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `entering.value` | `EntryOrExitLayoutType` | `FadeIn`
`.duration(200)`
`.easing(Easing.out(Easing.ease))` | Custom entering animation | | `exiting.value` | `EntryOrExitLayoutType` | `FadeOut`
`.duration(100)` | Custom exiting animation | ### Spinner.Indicator | prop | type | default | description | | ----------------------- | --------------------------- | ----------- | ------------------------------------------------------------ | | `children` | `React.ReactNode` | `undefined` | Content to render inside the indicator | | `iconProps` | `SpinnerIconProps` | `undefined` | Props for the default icon | | `className` | `string` | `undefined` | Custom class name for the indicator element | | `animation` | `SpinnerIndicatorAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `...Animated.ViewProps` | `Animated.ViewProps` | - | All Reanimated Animated.View props are supported | #### SpinnerIndicatorAnimation Animation configuration for Spinner.Indicator component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ----------------- | ---------------------------- | --------------- | ----------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `rotation.speed` | `number` | `1.1` | Rotation speed multiplier | | `rotation.easing` | `WithTimingConfig['easing']` | `Easing.linear` | Animation easing configuration | ### SpinnerIconProps | prop | type | default | description | | -------- | ------------------ | ---------------- | ------------------ | | `width` | `number \| string` | `24` | Width of the icon | | `height` | `number \| string` | `24` | Height of the icon | | `color` | `string` | `'currentColor'` | Color of the icon |
# Checkbox **Category**: native **URL**: https://v3.heroui.com/docs/native/components/checkbox **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/checkbox.mdx > A selectable control that allows users to toggle between checked and unchecked states. ## Import ```tsx import { Checkbox } from 'heroui-native'; ``` ## Anatomy ```tsx ... ``` * **Checkbox**: Main container that handles selection state and user interaction. Renders default indicator with animated checkmark if no children provided. Automatically detects surface context for proper styling. Features press scale animation that can be customized or disabled. Supports render function children to access state (`isSelected`, `isInvalid`, `isDisabled`). * **Checkbox.Indicator**: Optional checkmark container with default slide, scale, opacity, and border radius animations when selected. Renders animated check icon with SVG path drawing animation if no children provided. All animations can be individually customized or disabled. Supports render function children to access state. ## Usage ### Basic Usage The Checkbox component renders with a default animated indicator if no children are provided. It automatically detects whether it's on a surface background for proper styling. ```tsx ``` ### With Custom Indicator Use a render function in the Indicator to show/hide custom icons based on state. ```tsx {({ isSelected }) => (isSelected ? : null)} ``` ### Invalid State Show validation errors with the `isInvalid` prop, which applies danger color styling. ```tsx ``` ### Custom Animations Customize or disable animations for both the root checkbox and indicator. ```tsx { /* Disable all animations (root and indicator) */ } ; { /* Disable only root animation */ } ; { /* Disable only indicator animation */ } ; { /* Custom animation configuration */ } ; ``` ## Example ```tsx import { Checkbox, Description, ControlField, Label, Separator, Surface, } from "heroui-native"; import React from 'react'; import { View, Text } from 'react-native'; interface CheckboxFieldProps { isSelected: boolean; onSelectedChange: (value: boolean) => void; title: string; description: string; } const CheckboxField: React.FC = ({ isSelected, onSelectedChange, title, description, }) => { return ( {description} ); }; export default function BasicUsage() { const [fields, setFields] = React.useState({ newsletter: true, marketing: false, terms: false, }); const fieldConfigs: Record< keyof typeof fields, { title: string; description: string } > = { newsletter: { title: 'Subscribe to newsletter', description: 'Get weekly updates about new features and tips', }, marketing: { title: 'Marketing communications', description: 'Receive promotional emails and special offers', }, terms: { title: 'Accept terms and conditions', description: 'Agree to our Terms of Service and Privacy Policy', }, }; const handleFieldChange = (key: keyof typeof fields) => (value: boolean) => { setFields((prev) => ({ ...prev, [key]: value })); }; const fieldKeys = Object.keys(fields) as Array; return ( {fieldKeys.map((key, index) => ( {index > 0 && } ))} ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/checkbox.tsx). ## API Reference ### Checkbox | prop | type | default | description | | ----------------------- | ---------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------- | | `children` | `React.ReactNode \| ((props: CheckboxRenderProps) => React.ReactNode)` | `undefined` | Child elements or render function to customize the checkbox | | `isSelected` | `boolean` | `undefined` | Whether the checkbox is currently selected | | `onSelectedChange` | `(isSelected: boolean) => void` | `undefined` | Callback fired when the checkbox selection state changes | | `isDisabled` | `boolean` | `false` | Whether the checkbox is disabled and cannot be interacted with | | `isInvalid` | `boolean` | `false` | Whether the checkbox is invalid (shows danger color) | | `variant` | `'primary' \| 'secondary'` | `'primary'` | Variant style for the checkbox | | `hitSlop` | `number` | `6` | Hit slop for the pressable area | | `animation` | `CheckboxRootAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `className` | `string` | `undefined` | Additional CSS classes to apply | | `...PressableProps` | `PressableProps` | - | All standard React Native Pressable props are supported (except disabled) | #### CheckboxRenderProps | prop | type | description | | ------------ | --------- | -------------------------------- | | `isSelected` | `boolean` | Whether the checkbox is selected | | `isInvalid` | `boolean` | Whether the checkbox is invalid | | `isDisabled` | `boolean` | Whether the checkbox is disabled | #### CheckboxRootAnimation Animation configuration for checkbox root component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | -------------------- | ---------------------------------------- | ------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `scale.value` | `[number, number]` | `[1, 0.96]` | Scale values \[unpressed, pressed] | | `scale.timingConfig` | `WithTimingConfig` | `{ duration: 150 }` | Animation timing configuration | ### Checkbox.Indicator | prop | type | default | description | | ----------------------- | ---------------------------------------------------------------------- | ----------- | ------------------------------------------------------------ | | `children` | `React.ReactNode \| ((props: CheckboxRenderProps) => React.ReactNode)` | `undefined` | Content or render function for the checkbox indicator | | `className` | `string` | `undefined` | Additional CSS classes for the indicator | | `iconProps` | `CheckboxIndicatorIconProps` | `undefined` | Custom props for the default animated check icon | | `animation` | `CheckboxIndicatorAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `...AnimatedViewProps` | `AnimatedProps` | - | All standard React Native Animated View props are supported | #### CheckboxIndicatorIconProps Props for customizing the default animated check icon. | prop | type | description | | --------------- | -------- | ------------------------------------------------ | | `size` | `number` | Icon size | | `strokeWidth` | `number` | Icon stroke width | | `color` | `string` | Icon color (defaults to theme accent-foreground) | | `enterDuration` | `number` | Duration of enter animation (check appearing) | | `exitDuration` | `number` | Duration of exit animation (check disappearing) | #### CheckboxIndicatorAnimation Animation configuration for checkbox indicator component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | --------------------------- | ----------------------- | ------------------- | ----------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `opacity.value` | `[number, number]` | `[0, 1]` | Opacity values \[unselected, selected] | | `opacity.timingConfig` | `WithTimingConfig` | `{ duration: 100 }` | Animation timing configuration | | `borderRadius.value` | `[number, number]` | `[8, 0]` | Border radius values \[unselected, selected] | | `borderRadius.timingConfig` | `WithTimingConfig` | `{ duration: 50 }` | Animation timing configuration | | `translateX.value` | `[number, number]` | `[-4, 0]` | TranslateX values \[unselected, selected] | | `translateX.timingConfig` | `WithTimingConfig` | `{ duration: 100 }` | Animation timing configuration | | `scale.value` | `[number, number]` | `[0.8, 1]` | Scale values \[unselected, selected] | | `scale.timingConfig` | `WithTimingConfig` | `{ duration: 100 }` | Animation timing configuration | ## Hooks ### useCheckbox Hook to access checkbox context values within custom components or compound components. ```tsx import { useCheckbox } from 'heroui-native'; const CustomIndicator = () => { const { isSelected, isInvalid, isDisabled } = useCheckbox(); // ... your implementation }; ``` **Returns:** `UseCheckboxReturn` | property | type | description | | ------------------ | ---------------------------------------------- | -------------------------------------------------------------- | | `isSelected` | `boolean \| undefined` | Whether the checkbox is currently selected | | `onSelectedChange` | `((isSelected: boolean) => void) \| undefined` | Callback function to change the checkbox selection state | | `isDisabled` | `boolean` | Whether the checkbox is disabled and cannot be interacted with | | `isInvalid` | `boolean` | Whether the checkbox is invalid (shows danger color) | | `nativeID` | `string \| undefined` | Native ID for the checkbox element | **Note:** This hook must be used within a `Checkbox` component. It will throw an error if called outside of the checkbox context. # ControlField **Category**: native **URL**: https://v3.heroui.com/docs/native/components/control-field **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/control-field.mdx > A field component that combines a label, description (or other content), and a control component (Switch or Checkbox) into a single pressable area. ## Import ```tsx import { ControlField } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ... ``` * **ControlField**: Root container that manages layout and state propagation * **Label**: Primary text label for the control (from [Label](./label) component) * **Description**: Secondary descriptive helper text (from [Description](./description) component) * **ControlField.Indicator**: Container for the form control component ([Switch](./switch), [Checkbox](./checkbox), [Radio](./radio)) * **FieldError**: Validation error message display (from [FieldError](./field-error) component) ## Usage ### Basic Usage ControlField wraps form controls to provide consistent layout and state management. ```tsx ``` ### With Description Add helper text below the label using the Description component. ```tsx Receive push notifications about your account activity ``` ### With Error Message Display validation errors using the ErrorMessage component. ```tsx By checking this box, you agree to our Terms of Service This field is required ``` ### Disabled State Control interactivity with the disabled prop. ```tsx This field is disabled ``` ### Disabling All Animations Disable all animations including children by using `"disable-all"`. This cascades down to all child components. ```tsx Description text ``` ## Example ```tsx import { Checkbox, Description, FieldError, ControlField, Label, Switch, } from 'heroui-native'; import React from 'react'; import { ScrollView, View } from 'react-native'; export default function ControlFieldExample() { const [notifications, setNotifications] = React.useState(false); const [terms, setTerms] = React.useState(false); const [newsletter, setNewsletter] = React.useState(true); return ( Receive push notifications about your account activity By checking this box, you agree to our Terms of Service This field is required ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/control-field.tsx). ## API Reference ### ControlField | prop | type | default | description | | ----------------- | -------------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------- | | children | `React.ReactNode \| ((props: ControlFieldRenderProps) => React.ReactNode)` | - | Content to render inside the form control, or a render function | | isSelected | `boolean` | `undefined` | Whether the control is selected/checked | | isDisabled | `boolean` | `false` | Whether the form control is disabled | | isInvalid | `boolean` | `false` | Whether the form control is invalid | | isRequired | `boolean` | `false` | Whether the form control is required | | className | `string` | - | Custom class name for the root element | | onSelectedChange | `(isSelected: boolean) => void` | - | Callback when selection state changes | | animation | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | ...PressableProps | `PressableProps` | - | All React Native Pressable props are supported | ### Label The `Label` component automatically consumes form state (`isDisabled`, `isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [Label component documentation](./label). ### Description The `Description` component automatically consumes form state (`isDisabled`, `isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [Description component documentation](./description). ### ControlField.Indicator | prop | type | default | description | | ------------ | ----------------------------------- | ---------- | ---------------------------------------------------------- | | children | `React.ReactNode` | - | Control component to render (Switch, Checkbox, Radio) | | variant | `'checkbox' \| 'radio' \| 'switch'` | `'switch'` | Variant of the control to render when no children provided | | className | `string` | - | Custom class name for the indicator element | | ...ViewProps | `ViewProps` | - | All React Native View props are supported | **Note**: When children are provided, the component automatically passes down `isSelected`, `onSelectedChange`, `isDisabled`, and `isInvalid` props from the ControlField context if they are not already present on the child component. When using the `radio` variant, the Radio component renders in standalone mode (outside of a RadioGroup). ### FieldError The `FieldError` component automatically consumes form state (`isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [FieldError component documentation](./field-error). The error message visibility is controlled by the `isInvalid` state of the parent ControlField. ## Hooks ### useControlField **Returns:** | property | type | description | | ------------------ | ---------------------------------------------- | ---------------------------------------------- | | `isSelected` | `boolean \| undefined` | Whether the control is selected/checked | | `onSelectedChange` | `((isSelected: boolean) => void) \| undefined` | Callback when selection state changes | | `isDisabled` | `boolean` | Whether the form control is disabled | | `isInvalid` | `boolean` | Whether the form control is invalid | | `isPressed` | `SharedValue` | Reanimated shared value indicating press state | # Description **Category**: native **URL**: https://v3.heroui.com/docs/native/components/description **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/description.mdx > Text component for providing accessible descriptions and helper text for form fields and other UI elements. ## Import ```tsx import { Description } from 'heroui-native'; ``` ## Anatomy ```tsx ... ``` * **Description**: Text component that displays description or helper text with muted styling. Can be linked to form fields via `nativeID` for accessibility support. ## Usage ### Basic Usage Display description text with default muted styling. ```tsx This is a helpful description. ``` ### With Form Fields Provide accessible descriptions for form fields using the `nativeID` prop. ```tsx We'll never share your email with anyone else. ``` ### Accessibility Linking Link descriptions to form fields for screen reader support by using `nativeID` and `aria-describedby`. ```tsx Use at least 8 characters with a mix of letters, numbers, and symbols. ``` ### Hiding on Invalid State Control whether the description should be hidden when the form field is invalid using the `hideOnInvalid` prop. ```tsx We'll never share your email with anyone else. Please enter a valid email address ``` When `hideOnInvalid` is `true`, the description will be hidden when the field is invalid. When `false` (default), the description remains visible even when invalid. ## Example ```tsx import { Description, TextField } from 'heroui-native'; import { View } from 'react-native'; export default function DescriptionExample() { return ( We'll never share your email with anyone else. Use at least 8 characters with a mix of letters, numbers, and symbols. ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/description.tsx). ## API Reference ### Description | prop | type | default | description | | --------------- | ----------------------------------- | ------- | ------------------------------------------------------------------------------------------ | | `children` | `React.ReactNode` | - | Description text content | | `className` | `string` | - | Additional CSS classes to apply | | `nativeID` | `string` | - | Native ID for accessibility. Used to link description to form fields via aria-describedby. | | `isInvalid` | `boolean` | - | Whether the description is in an invalid state (overrides context) | | `isDisabled` | `boolean` | - | Whether the description is disabled (overrides context) | | `hideOnInvalid` | `boolean` | `false` | Whether to hide the description when invalid | | `animation` | `DescriptionAnimation \| undefined` | - | Animation configuration for description transitions | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | # FieldError **Category**: native **URL**: https://v3.heroui.com/docs/native/components/field-error **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/field-error.mdx > Displays validation error message content with smooth animations. ## Import ```tsx import { FieldError } from 'heroui-native'; ``` ## Anatomy ```tsx Error message content ``` * **FieldError**: Main container that displays error messages with smooth animations. Accepts string children which are automatically wrapped with Text component, or custom React components for more complex layouts. Controls visibility through the `isInvalid` prop and supports custom entering/exiting animations. ## Usage ### Basic Usage The FieldError component displays error messages when validation fails. ```tsx This field is required ``` ### Controlled Visibility Control when the error appears using the `isInvalid` prop. When used inside a form field component (like TextField), FieldError automatically consumes the form-item-state context. ```tsx const [isInvalid, setIsInvalid] = useState(false); Please enter a valid email address; ``` ### With Form Fields FieldError automatically consumes form state from TextField via the form-item-state context. ```tsx import { FieldError, Label, TextField } from 'heroui-native'; Please enter a valid email address ``` ### Custom Content Pass custom React components as children instead of strings. ```tsx Invalid input ``` ### Custom Animations Override default entering and exiting animations using the `animation` prop. ```tsx import { SlideInDown, SlideOutUp } from 'react-native-reanimated'; Field validation failed ; ``` Disable animations entirely: ```tsx Field validation failed ``` ### Custom Styling Apply custom styles to the container and text elements. ```tsx Password must be at least 8 characters ``` ### Custom Text Props Pass additional props to the Text component when children is a string. ```tsx This is a very long error message that might need to be truncated ``` ## Example ```tsx import { Description, FieldError, Label, TextField } from 'heroui-native'; import { useState } from 'react'; import { View } from 'react-native'; export default function FieldErrorExample() { const [email, setEmail] = useState(''); const [isInvalid, setIsInvalid] = useState(false); const isValidEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); const handleBlur = () => { setIsInvalid(email !== '' && !isValidEmail); }; return ( We'll use this to contact you Please enter a valid email address ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/field-error.tsx). ## API Reference ### FieldError | prop | type | default | description | | ---------------------- | --------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `children` | `React.ReactNode` | `undefined` | The content of the error field. String children are wrapped with Text | | `isInvalid` | `boolean` | `undefined` | Controls the visibility of the error field (overrides form-item-state context). When used inside TextField, automatically consumes form state | | `animation` | `FieldErrorRootAnimation` | - | Animation configuration | | `className` | `string` | `undefined` | Additional CSS classes for the container | | `classNames` | `ElementSlots` | `undefined` | Additional CSS classes for different parts of the component | | `styles` | `{ container?: ViewStyle; text?: TextStyle }` | `undefined` | Styles for different parts of the field error | | `textProps` | `TextProps` | `undefined` | Additional props to pass to the Text component when children is a string | | `...AnimatedViewProps` | `AnimatedProps` | - | All Reanimated Animated.View props are supported | **classNames prop:** `ElementSlots` provides type-safe CSS classes for different parts of the field error component. Available slots: `container`, `text`. #### `styles` | prop | type | description | | ----------- | ----------- | --------------------------- | | `container` | `ViewStyle` | Styles for the container | | `text` | `TextStyle` | Styles for the text content | #### FieldErrorRootAnimation Animation configuration for field error root component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ---------------- | ---------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `entering.value` | `EntryOrExitLayoutType` | `FadeIn`
`.duration(150)`
`.easing(Easing.out(Easing.ease))` | Custom entering animation for field error | | `exiting.value` | `EntryOrExitLayoutType` | `FadeOut`
`.duration(100)`
`.easing(Easing.out(Easing.ease))` | Custom exiting animation for field error |
# InputOTP **Category**: native **URL**: https://v3.heroui.com/docs/native/components/input-otp **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/input-otp.mdx > Input component for entering one-time passwords (OTP) with individual character slots, animations, and validation support. ## Import ```tsx import { InputOTP } from 'heroui-native'; ``` ## Anatomy ```tsx ``` * **InputOTP**: Main container that manages OTP input state, handles text changes, and provides context to child components. Manages focus, validation, and character input. * **InputOTP.Group**: Container for grouping multiple slots together. Use this to visually group related slots (e.g., groups of 3 digits). * **InputOTP.Slot**: Individual slot that displays a single character or placeholder. Each slot must have a unique index matching its position in the OTP sequence. When no children are provided, automatically renders SlotPlaceholder, SlotValue, and SlotCaret. * **InputOTP.SlotPlaceholder**: Text component that displays the placeholder character for a slot when it's empty. Used by default in Slot if no children provided. * **InputOTP.SlotValue**: Text component that displays the actual character value for a slot with animations. Used by default in Slot if no children provided. * **InputOTP.SlotCaret**: Animated caret indicator that shows the current input position. Place this inside a Slot to show where the user is currently typing. * **InputOTP.Separator**: Visual separator between groups of slots. Use this to visually separate different groups of OTP digits. ## Usage ### Basic Usage Create a 6-digit OTP input with grouped slots and separator. ```tsx console.log(code)}> ``` ### Four Digits Create a simple 4-digit PIN input. ```tsx console.log(code)}> ``` ### With Placeholder Provide custom placeholder characters for each slot position. ```tsx console.log(code)} > {({ slots }) => ( <> {slots.map((slot) => ( ))} )} ``` ### Controlled Value Control the OTP value programmatically. ```tsx const [value, setValue] = useState(''); ; ``` ### With Validation Display validation errors when the OTP is invalid. ```tsx ``` ### With Pattern Restrict input to specific character patterns using regex. Three predefined patterns are available: `REGEXP_ONLY_DIGITS` (matches digits 0-9), `REGEXP_ONLY_CHARS` (matches alphabetic characters a-z, A-Z), and `REGEXP_ONLY_DIGITS_AND_CHARS` (matches both digits and alphabetic characters). ```tsx import { InputOTP, REGEXP_ONLY_CHARS } from 'heroui-native'; console.log(code)} > ; ``` ### Custom Layout Use render props in Group to create custom slot layouts. ```tsx {({ slots, isFocused, isInvalid }) => ( <> {slots.map((slot) => ( ))} )} ``` ## Example ```tsx import { InputOTP, Label, Description, type InputOTPRef } from 'heroui-native'; import { View } from 'react-native'; import { useRef } from 'react'; export default function InputOTPExample() { const ref = useRef(null); const onComplete = (code: string) => { console.log('OTP completed:', code); setTimeout(() => { ref.current?.clear(); }, 1000); }; return ( We've sent a code to a****@gmail.com ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/input-otp.tsx). ## API Reference ### InputOTP | prop | type | default | description | | -------------------------- | ----------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- | | `maxLength` | `number` | - | Maximum length of the OTP (required) | | `value` | `string` | - | Controlled value for the OTP input | | `defaultValue` | `string` | - | Default value for uncontrolled usage | | `onChange` | `(value: string) => void` | - | Callback when value changes | | `onComplete` | `(value: string) => void` | - | Handler called when all slots are filled | | `isDisabled` | `boolean` | `false` | Whether the input is disabled | | `isInvalid` | `boolean` | `false` | Whether the input is in an invalid state | | `pattern` | `string` | - | Regex pattern for allowed characters (e.g., REGEXP\_ONLY\_DIGITS, REGEXP\_ONLY\_CHARS) | | `inputMode` | `TextInputProps['inputMode']` | `'numeric'` | Input mode for the input | | `placeholder` | `string` | - | Placeholder text for the input. Each character corresponds to a slot position | | `placeholderTextColor` | `string` | - | Placeholder text color for all slots | | `placeholderTextClassName` | `string` | - | Placeholder text class name for all slots | | `pasteTransformer` | `(text: string) => string` | - | Transform pasted text (e.g., remove hyphens). Defaults to removing non-matching characters | | `onFocus` | `(e: FocusEvent) => void` | - | Handler for focus events | | `onBlur` | `(e: BlurEvent) => void` | - | Handler for blur events | | `textInputProps` | `Omit` | - | Additional props to pass to the underlying TextInput component | | `children` | `React.ReactNode` | - | Children elements to be rendered inside the InputOTP | | `className` | `string` | - | Additional CSS classes to apply | | `style` | `PressableProps['style']` | - | Style to pass to the container Pressable component | | `isBottomSheetAware` | `boolean` | `true` | Whether the InputOTP automatically handles keyboard state when rendered inside a BottomSheet. Set to `false` to disable | | `animation` | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | ### InputOTP.Group | prop | type | default | description | | -------------- | --------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ | | `children` | `React.ReactNode \| ((props: InputOTPGroupRenderProps) => React.ReactNode)` | - | Children elements to be rendered inside the group, or a render function that receives slot data and other context values | | `className` | `string` | - | Additional CSS classes to apply | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### InputOTPGroupRenderProps | prop | type | description | | ------------ | ------------ | ---------------------------------------- | | `slots` | `SlotData[]` | Array of slot data for each position | | `maxLength` | `number` | Maximum length of the OTP | | `value` | `string` | Current OTP value | | `isFocused` | `boolean` | Whether the input is currently focused | | `isDisabled` | `boolean` | Whether the input is disabled | | `isInvalid` | `boolean` | Whether the input is in an invalid state | ### InputOTP.Slot | prop | type | default | description | | -------------- | ----------------- | ------- | ------------------------------------------------------------------------------------------- | | `index` | `number` | - | Zero-based index of the slot (required). Must be between 0 and maxLength - 1 | | `children` | `React.ReactNode` | - | Custom slot content. If not provided, defaults to SlotPlaceholder, SlotValue, and SlotCaret | | `className` | `string` | - | Additional CSS classes to apply | | `style` | `ViewStyle` | - | Additional styles to apply | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### InputOTP.SlotPlaceholder | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------------------------- | | `children` | `string` | - | Text content to display (optional, defaults to slot.placeholderChar) | | `className` | `string` | - | Additional CSS classes to apply | | `style` | `TextStyle` | - | Additional styles to apply | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ### InputOTP.SlotValue | prop | type | default | description | | -------------- | ---------------------------- | ------- | --------------------------------------------------------- | | `children` | `string` | - | Text content to display (optional, defaults to slot.char) | | `className` | `string` | - | Additional CSS classes to apply | | `animation` | `InputOTPSlotValueAnimation` | - | Animation configuration for SlotValue | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | #### InputOTPSlotValueAnimation Animation configuration for InputOTP.SlotValue component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------ | ----------------------- | ---------------------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `wrapper.entering` | `EntryOrExitLayoutType` | `FadeIn.duration(250)` | Entering animation for wrapper | | `wrapper.exiting` | `EntryOrExitLayoutType` | `FadeOut.duration(100)` | Exiting animation for wrapper | | `text.entering` | `EntryOrExitLayoutType` | `FlipInXDown.duration(250).easing(...)` | Entering animation for text | | `text.exiting` | `EntryOrExitLayoutType` | `FlipOutXDown.duration(250).easing(...)` | Exiting animation for text | ### InputOTP.SlotCaret | prop | type | default | description | | ----------------------- | ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `className` | `string` | - | Additional CSS classes to apply | | `style` | `ViewStyle` | - | Additional styles to apply | | `animation` | `InputOTPSlotCaretAnimation` | - | Animation configuration for SlotCaret | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active. When `false`, the animated style is removed and you can implement custom logic | | `pointerEvents` | `'none' \| 'auto' \| ...` | `'none'` | Pointer events configuration | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### InputOTPSlotCaretAnimation Animation configuration for InputOTP.SlotCaret component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------ | ----------------------- | ---------- | ----------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `opacity.value` | `[number, number]` | `[0, 1]` | Opacity values \[min, max] | | `opacity.duration` | `number` | `500` | Animation duration in milliseconds | | `height.value` | `[number, number]` | `[16, 18]` | Height values \[min, max] in pixels | | `height.duration` | `number` | `500` | Animation duration in milliseconds | ### InputOTP.Separator | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------- | | `className` | `string` | - | Additional CSS classes to apply | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ## Hooks ### useInputOTP Hook to access the InputOTP root context. Must be used within an `InputOTP` component. ```tsx const { value, maxLength, isFocused, isDisabled, isInvalid, slots } = useInputOTP(); ``` ### useInputOTPSlot Hook to access the InputOTP.Slot context. Must be used within an `InputOTP.Slot` component. ```tsx const { slot, isActive, isCaretVisible } = useInputOTPSlot(); ``` # Input **Category**: native **URL**: https://v3.heroui.com/docs/native/components/input **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/input.mdx > A text input component with styled border and background for collecting user input. ## Import ```tsx import { Input } from 'heroui-native'; ``` ## Usage ### Basic Usage Input can be used standalone or within a TextField component. ```tsx import { Input } from 'heroui-native'; ; ``` ### Within TextField Input works seamlessly with TextField for complete form structure. ```tsx import { Input, Label, TextField } from 'heroui-native'; ; ``` ### With Validation Display error state when the input is invalid. ```tsx import { FieldError, Input, Label, TextField } from 'heroui-native'; Please enter a valid email ; ``` ### With Local Invalid State Override Override the context's invalid state for the input. ```tsx import { FieldError, Input, Label, TextField } from 'heroui-native'; Email format is incorrect ; ``` ### Disabled State Disable the input to prevent interaction. ```tsx import { Input, Label, TextField } from 'heroui-native'; ; ``` ### With Variant Use different variants to style the input based on context. ```tsx import { Input, Label, TextField } from 'heroui-native'; ``` ### Custom Styling Customize the input appearance using className. ```tsx import { Input, Label, TextField } from 'heroui-native'; ; ``` ## Example ```tsx import { Ionicons } from '@expo/vector-icons'; import { Description, Input, Label, TextField } from 'heroui-native'; import { useState } from 'react'; import { Pressable, View } from 'react-native'; import { withUniwind } from 'uniwind'; const StyledIonicons = withUniwind(Ionicons); export const TextInputContent = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isPasswordVisible, setIsPasswordVisible] = useState(false); return ( We'll never share your email with anyone else. setIsPasswordVisible(!isPasswordVisible)} > Password must be at least 6 characters ); }; ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/input.tsx). ## API Reference ### Input | prop | type | default | description | | ------------------------- | -------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------- | | isInvalid | `boolean` | `undefined` | Whether the input is in an invalid state (overrides context) | | variant | `'primary' \| 'secondary'` | `'primary'` | Variant style for the input | | className | `string` | - | Custom class name for the input | | selectionColorClassName | `string` | `"accent-accent"` | Custom className for the selection color | | placeholderColorClassName | `string` | `"field-placeholder"` | Custom className for the placeholder text color | | isBottomSheetAware | `boolean` | `true` | Whether the input automatically handles keyboard state when rendered inside a BottomSheet. Set to `false` to disable | | animation | `AnimationRoot` | `undefined` | Animation configuration for the input | | ...TextInputProps | `TextInputProps` | - | All standard React Native TextInput props are supported | > **Note**: When used within a TextField component, Input automatically consumes form state (isDisabled, isInvalid) from TextField via the form-item-state context. # Label **Category**: native **URL**: https://v3.heroui.com/docs/native/components/label **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/label.mdx > Text component for labeling form fields and other UI elements with support for required indicators and validation states. ## Import ```tsx import { Label } from 'heroui-native'; ``` ## Anatomy ```tsx ``` * **Label**: Root container that manages label state and provides context to child components. When string children are provided, automatically renders as Label.Text. Supports disabled, required, and invalid states. * **Label.Text**: Text content of the label. Displays the label text and automatically shows an asterisk when the label is required. Changes color when invalid or disabled. ## Usage ### Basic Usage Display a label with text content. String children are automatically rendered as Label.Text. ```tsx ``` ### With Form Fields Use Label with form fields to provide accessible labels. ```tsx ``` ### Required Fields Show an asterisk indicator for required fields using the `isRequired` prop. ```tsx ``` ### Invalid State Display labels in an invalid state to indicate validation errors. ```tsx import { FieldError, Label, TextField } from 'heroui-native'; Passwords do not match ``` ### Disabled State Disable labels to indicate non-interactive fields. ```tsx ``` ### Custom Layout Use compound components for custom label layouts. ```tsx ``` ### Custom Styling Apply custom styles using className, classNames, or styles props. ```tsx ``` ## Example ```tsx import { FieldError, Label, TextField } from 'heroui-native'; import { View } from 'react-native'; export default function LabelExample() { return ( Passwords do not match ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/label.tsx). ## API Reference ### Label | prop | type | default | description | | ------------------- | ---------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Label content. When string is provided, automatically renders as Label.Text. Otherwise renders children as-is | | `isRequired` | `boolean` | `false` | Whether the label is required. Shows asterisk indicator when true | | `isInvalid` | `boolean` | `false` | Whether the label is in an invalid state. Changes text color to danger | | `isDisabled` | `boolean` | `false` | Whether the label is disabled. Applies disabled styling and prevents interaction | | `className` | `string` | - | Additional CSS classes to apply | | `animation` | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | `...PressableProps` | `PressableProps` | - | All standard React Native Pressable props are supported | ### Label.Text | prop | type | default | description | | -------------- | ---------------------------------------- | ------- | ---------------------------------------------------------------------------------- | | `children` | `React.ReactNode` | - | Label text content | | `className` | `string` | - | Additional CSS classes to apply to the text element | | `classNames` | `ElementSlots` | - | Additional CSS classes for different parts of the label | | `styles` | `Partial>` | - | Styles for different parts of the label | | `nativeID` | `string` | - | Native ID for accessibility. Used to link label to form fields via aria-labelledby | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | #### `ElementSlots` | prop | type | description | | ---------- | -------- | ------------------------------ | | `text` | `string` | CSS classes for the label text | | `asterisk` | `string` | CSS classes for the asterisk | #### `styles` | prop | type | description | | ---------- | ----------- | ------------------------- | | `text` | `TextStyle` | Styles for the label text | | `asterisk` | `TextStyle` | Styles for the asterisk | # RadioGroup **Category**: native **URL**: https://v3.heroui.com/docs/native/components/radio-group **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/radio-group.mdx > A set of radio buttons where only one option can be selected at a time. ## Import ```tsx import { RadioGroup } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ``` * **RadioGroup**: Container that manages the selection state of radio items. Supports both horizontal and vertical orientations. * **RadioGroup.Item**: Individual radio option within a RadioGroup. Must be used inside RadioGroup. Handles selection state and renders a default `` indicator when text children are provided. Supports render function children to access state (`isSelected`, `isInvalid`, `isDisabled`). * **Label**: Optional clickable text label for the radio option. Linked to the radio for accessibility. Use the [Label](./label) component directly. * **Description**: Optional secondary text below the label. Provides additional context about the radio option. Use the [Description](./description) component directly. * **Radio**: The [Radio](./radio) component used inside `RadioGroup.Item` to render the radio indicator. Automatically detects the `RadioGroupItem` context and derives `isSelected`, `isDisabled`, `isInvalid`, and `variant` from it. * **Radio.Indicator**: Optional container for the radio circle. Renders default thumb if no children provided. Manages the visual selection state. See [Radio](./radio) for full API. * **Radio.IndicatorThumb**: Optional inner circle that appears when selected. Animates scale based on selection. Can be replaced with custom content. See [Radio](./radio) for full API. * **FieldError**: Error message displayed when radio group is invalid. Shown with animation below the radio group content. Use the [FieldError](./field-error) component directly. ## Usage ### Basic Usage RadioGroup with simple string children automatically renders title and indicator. ```tsx Option 1 Option 2 Option 3 ``` ### With Descriptions Add descriptive text below each radio option for additional context. ```tsx import { RadioGroup, Radio, Label, Description } from 'heroui-native'; import { View } from 'react-native'; Delivered in 5-7 business days Delivered in 2-3 business days ; ``` ### Custom Indicator Replace the default indicator thumb with custom content using `Radio` sub-components. ```tsx import { RadioGroup, Radio, Label } from 'heroui-native'; {({ isSelected }) => ( <> {isSelected && ( )} )} ; ``` ### With Render Function Use a render function on RadioGroup.Item to access state and customize the entire content. ```tsx import { RadioGroup, Radio, Label } from 'heroui-native'; {({ isSelected, isInvalid, isDisabled }) => ( <> {isSelected && } )} ; ``` ### With Error Message Display validation errors below the radio group. ```tsx import { RadioGroup, FieldError } from 'heroui-native'; function RadioGroupWithError() { const [value, setValue] = React.useState(undefined); return ( I agree to the terms I do not agree Please select an option to continue ); } ``` ## Example ```tsx import { Description, Label, Radio, RadioGroup, Separator, Surface, } from 'heroui-native'; import React from 'react'; import { View } from 'react-native'; export default function RadioGroupExample() { const [selection, setSelection] = React.useState('desc1'); return ( Delivered in 5-7 business days Delivered in 2-3 business days Delivered next business day ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/radio-group.tsx). ## API Reference ### RadioGroup | prop | type | default | description | | --------------- | ---------------------------- | ----------- | ----------------------------------------------------------------------------------------- | | `children` | `React.ReactNode` | `undefined` | Radio group content | | `value` | `string \| undefined` | `undefined` | The currently selected value of the radio group | | `onValueChange` | `(val: string) => void` | `undefined` | Callback fired when the selected value changes | | `isDisabled` | `boolean` | `false` | Whether the entire radio group is disabled | | `isInvalid` | `boolean` | `false` | Whether the radio group is invalid | | `variant` | `'primary' \| 'secondary'` | `undefined` | Variant style for the radio group (inherited by items if not set on item) | | `animation` | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | `className` | `string` | `undefined` | Custom class name | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### RadioGroup.Item | prop | type | default | description | | ------------------- | ---------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------- | | `children` | `React.ReactNode \| ((props: RadioGroupItemRenderProps) => React.ReactNode)` | `undefined` | Radio item content or render function to customize the radio item | | `value` | `string` | `undefined` | The value associated with this radio item | | `isDisabled` | `boolean` | `false` | Whether this specific radio item is disabled | | `isInvalid` | `boolean` | `false` | Whether the radio item is invalid | | `variant` | `'primary' \| 'secondary'` | `'primary'` | Variant style for the radio item | | `hitSlop` | `number` | `6` | Hit slop for the pressable area | | `className` | `string` | `undefined` | Custom class name | | `...PressableProps` | `PressableProps` | - | All standard React Native Pressable props are supported (except disabled) | #### RadioGroupItemRenderProps | prop | type | description | | ------------ | --------- | ---------------------------------- | | `isSelected` | `boolean` | Whether the radio item is selected | | `isInvalid` | `boolean` | Whether the radio item is invalid | | `isDisabled` | `boolean` | Whether the radio item is disabled | ### Radio (inside RadioGroup.Item) The [Radio](./radio) component is used inside `RadioGroup.Item` to render the radio indicator. When placed inside a `RadioGroup.Item`, the Radio component automatically detects the `RadioGroupItem` context and derives `isSelected`, `isDisabled`, `isInvalid`, and `variant` from it — no manual prop passing is needed. Use `` for the default indicator, or compose with `Radio.Indicator` and `Radio.IndicatorThumb` for custom styling. **Note:** For complete Radio prop documentation (including `Radio.Indicator` and `Radio.IndicatorThumb`), see the [Radio component documentation](./radio). **Note:** For labels, descriptions, and error messages, use the base components directly: * Use [Label](./label) component for labels * Use [Description](./description) component for descriptions * Use [FieldError](./field-error) component for error messages ## Hooks ### useRadioGroup **Returns:** | Property | Type | Description | | --------------- | -------------------------- | ---------------------------------------------- | | `value` | `string \| undefined` | Currently selected value | | `isDisabled` | `boolean` | Whether the radio group is disabled | | `isInvalid` | `boolean` | Whether the radio group is in an invalid state | | `variant` | `'primary' \| 'secondary'` | Variant style for the radio group | | `onValueChange` | `(value: string) => void` | Function to change the selected value | ### useRadioGroupItem **Returns:** | Property | Type | Description | | ------------------ | ---------------------------------------------- | ----------------------------------------------------------------------- | | `isSelected` | `boolean` | Whether the radio item is selected | | `isDisabled` | `boolean \| undefined` | Whether the radio item is disabled | | `isInvalid` | `boolean \| undefined` | Whether the radio item is invalid | | `variant` | `'primary' \| 'secondary' \| undefined` | Variant style for the radio item | | `onSelectedChange` | `((isSelected: boolean) => void) \| undefined` | Callback to change the selection state (selects this item in the group) | # Select **Category**: native **URL**: https://v3.heroui.com/docs/native/components/select **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/select.mdx > Displays a list of options for the user to pick from — triggered by a button. ## Import ```tsx import { Select } from 'heroui-native'; ``` ## Anatomy ```tsx ``` * **Select**: Main container that manages open/close state, value selection and provides context to child components. * **Select.Trigger**: Clickable element that toggles the select visibility. Wraps any child element with press handlers. Supports `variant` prop (`'default'` or `'unstyled'`). * **Select.Value**: Displays the selected value or placeholder text. Automatically updates when selection changes. Styling changes based on selection state. * **Select.TriggerIndicator**: Optional visual indicator showing open/close state. Renders an animated chevron icon by default that rotates when the select opens/closes. * **Select.Portal**: Renders select content in a portal layer above other content. Ensures proper stacking and positioning. * **Select.Overlay**: Optional background overlay. Can be transparent or semi-transparent to capture outside clicks. * **Select.Content**: Container for select content with three presentation modes: popover (floating with positioning), bottom sheet modal, or dialog modal. * **Select.Close**: Close button for the select. Can accept custom children or uses default close icon. * **Select.ListLabel**: Label for the list of items with pre-styled typography. * **Select.Item**: Selectable option item. Handles selection state and press events. * **Select.ItemLabel**: Displays the label text for an item. * **Select.ItemDescription**: Optional description text for items with muted styling. * **Select.ItemIndicator**: Optional indicator shown for selected items. Renders a check icon by default. ## Usage ### Basic Usage The Select component uses compound parts to create dropdown selection interfaces. ```tsx ``` ### With Value Display Display the selected value in the trigger using the Value component. ```tsx ``` ### Popover Presentation Use popover presentation for floating content with automatic positioning. ```tsx ``` ### Width Control Control the width of the select content using the `width` prop. This only works with popover presentation. ```tsx { /* Fixed width in pixels */ } ; { /* Match trigger width */ } ; { /* Full width (100%) */ } ; { /* Auto-size to content (default) */ } ; ``` ### Bottom Sheet Presentation Use bottom sheet for mobile-optimized selection experience. ```tsx ``` ### Dialog Presentation Use dialog presentation for centered modal-style selection. ```tsx ``` ### Custom Item Content Customize item appearance with custom content and indicators. ```tsx ``` ### With Render Function Use a render function on `Select.Item` to access state and customize content based on selection. ```tsx ``` ### With Item Description Add descriptions to items for additional context. ```tsx ``` ### With Trigger Indicator Add a visual indicator to show the open/close state of the select. The indicator rotates when the select opens/closes. ```tsx ``` ### Custom Trigger with Unstyled Variant Use the `unstyled` variant when composing a custom trigger with other components like Button. ```tsx ``` ### Controlled Mode Control the select state programmatically. ```tsx const [value, setValue] = useState(); const [isOpen, setIsOpen] = useState(false); ; ``` ## Example ```tsx import { Select, Separator } from 'heroui-native'; import React, { useState } from 'react'; type SelectOption = { value: string; label: string; }; const US_STATES: SelectOption[] = [ { value: 'CA', label: 'California' }, { value: 'NY', label: 'New York' }, { value: 'TX', label: 'Texas' }, { value: 'FL', label: 'Florida' }, ]; export default function SelectExample() { const [value, setValue] = useState(); return ( ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/select.tsx). ## API Reference ### Select | prop | type | default | description | | --------------- | ----------------------------------------- | ----------- | ---------------------------------------------------------------------- | | `children` | `ReactNode` | - | The content of the select | | `value` | `SelectOption` | - | The selected value (controlled mode) | | `onValueChange` | `(value: SelectOption) => void` | - | Callback when the value changes | | `defaultValue` | `SelectOption` | - | The default selected value (uncontrolled mode) | | `isOpen` | `boolean` | - | Whether the select is open (controlled mode) | | `isDefaultOpen` | `boolean` | - | Whether the select is open when initially rendered (uncontrolled mode) | | `onOpenChange` | `(isOpen: boolean) => void` | - | Callback when the select open state changes | | `isDisabled` | `boolean` | `false` | Whether the select is disabled | | `presentation` | `'popover' \| 'bottom-sheet' \| 'dialog'` | `'popover'` | Presentation mode for the select content | | `animation` | `SelectRootAnimation` | - | Animation configuration | | `asChild` | `boolean` | `false` | Whether to render as a child element | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### SelectRootAnimation Animation configuration for Select component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ---------------- | ------------------------------------------------ | ------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `entering.value` | `SpringAnimationConfig \| TimingAnimationConfig` | - | Animation configuration for when select opens | | `exiting.value` | `SpringAnimationConfig \| TimingAnimationConfig` | - | Animation configuration for when select closes | #### SpringAnimationConfig | prop | type | default | description | | -------- | ------------------ | ------- | ----------------------------------------- | | `type` | `'spring'` | - | Animation type (must be `'spring'`) | | `config` | `WithSpringConfig` | - | Reanimated spring animation configuration | #### TimingAnimationConfig | prop | type | default | description | | -------- | ------------------ | ------- | ----------------------------------------- | | `type` | `'timing'` | - | Animation type (must be `'timing'`) | | `config` | `WithTimingConfig` | - | Reanimated timing animation configuration | ### Select.Trigger | prop | type | default | description | | ------------------- | ------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | | `variant` | `'default' \| 'unstyled'` | `'default'` | The variant of the trigger. `'default'` applies pre-styled container styles, `'unstyled'` removes default styling | | `children` | `ReactNode` | - | The trigger element content | | `className` | `string` | - | Additional CSS classes for the trigger | | `asChild` | `boolean` | `true` | Whether to render as a child element | | `isDisabled` | `boolean` | - | Whether the trigger is disabled | | `...PressableProps` | `PressableProps` | - | All standard React Native Pressable props are supported | ### Select.Value | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------- | | `placeholder` | `string` | - | Placeholder text when no value is selected | | `className` | `string` | - | Additional CSS classes for the value | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | **Note:** The value component automatically applies different text colors based on selection state: * When a value is selected: `text-foreground` * When no value is selected (placeholder): `text-field-placeholder` ### Select.TriggerIndicator | prop | type | default | description | | ----------------------- | --------------------------------- | ------- | ------------------------------------------------------------ | | `children` | `ReactNode` | - | Custom indicator content. Defaults to animated chevron icon | | `className` | `string` | - | Additional CSS classes for the trigger indicator | | `style` | `ViewStyle` | - | Custom styles for the trigger indicator | | `iconProps` | `SelectTriggerIndicatorIconProps` | - | Chevron icon configuration | | `animation` | `SelectTriggerIndicatorAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | **Note:** The following style properties are occupied by animations and cannot be set via className: * `transform` (specifically `rotate`) - Animated for open/close rotation transitions To customize this property, use the `animation` prop. To completely disable animated styles and use your own via className or style prop, set `isAnimatedStyleActive={false}`. #### SelectTriggerIndicatorIconProps | prop | type | default | description | | ------- | -------- | ------- | ------------------------------------------------------ | | `size` | `number` | `16` | Size of the icon | | `color` | `string` | - | Color of the icon (defaults to foreground theme color) | #### SelectTriggerIndicatorAnimation Animation configuration for Select.TriggerIndicator component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations (rotation from 0° to -180°) * `object`: Custom animation configuration | prop | type | default | description | | ----------------------- | ----------------------- | -------------------------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `rotation.value` | `[number, number]` | `[0, -180]` | Rotation values \[closed, open] in degrees | | `rotation.springConfig` | `WithSpringConfig` | `{ damping: 140, stiffness: 1000, mass: 4 }` | Spring animation configuration for rotation | ### Select.Portal | prop | type | default | description | | -------------------------- | ----------- | ------- | ----------------------------------------------------------------------------------------------------------------------------- | | `children` | `ReactNode` | - | The portal content (required) | | `disableFullWindowOverlay` | `boolean` | `false` | When true on iOS, uses View instead of FullWindowOverlay. Enables element inspector; overlay won't appear above native modals | | `className` | `string` | - | Additional CSS classes for the portal container | | `hostName` | `string` | - | Optional name of the host element for the portal | | `forceMount` | `boolean` | - | Whether to force mount the component in the DOM | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### Select.Overlay | prop | type | default | description | | ----------------------- | ------------------------ | ------- | ------------------------------------------------------------ | | `className` | `string` | - | Additional CSS classes for the overlay | | `animation` | `SelectOverlayAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `closeOnPress` | `boolean` | `true` | Whether to close the select when overlay is pressed | | `forceMount` | `boolean` | - | Whether to force mount the component in the DOM | | `asChild` | `boolean` | `false` | Whether to render as a child element | | `...Animated.ViewProps` | `Animated.ViewProps` | - | All Reanimated Animated.View props are supported | #### SelectOverlayAnimation Animation configuration for Select.Overlay component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations (progress-based opacity for bottom-sheet/dialog, Keyframe animations for popover) * `object`: Custom animation configuration | prop | type | default | description | | --------------- | -------------------------- | ----------- | ---------------------------------------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `opacity.value` | `[number, number, number]` | `[0, 1, 0]` | Opacity values \[idle, open, close] (for bottom-sheet/dialog presentation) | | `entering` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for entering transition (for popover presentation) | | `exiting` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for exiting transition (for popover presentation) | ### Select.Content (Popover Presentation) | prop | type | default | description | | ----------------------- | ------------------------------------------------ | --------------- | ------------------------------------------------------ | | `children` | `ReactNode` | - | The select content | | `width` | `number \| 'trigger' \| 'content-fit' \| 'full'` | `'content-fit'` | Width sizing strategy for the content | | `presentation` | `'popover'` | `'popover'` | Presentation mode for the select | | `placement` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` | Placement of the content relative to trigger | | `align` | `'start' \| 'center' \| 'end'` | `'center'` | Alignment along the placement axis | | `avoidCollisions` | `boolean` | `true` | Whether to flip placement when close to viewport edges | | `offset` | `number` | `8` | Distance from trigger element in pixels | | `alignOffset` | `number` | `0` | Offset along the alignment axis in pixels | | `className` | `string` | - | Additional CSS classes for the content container | | `animation` | `SelectContentPopoverAnimation` | - | Animation configuration | | `forceMount` | `boolean` | - | Whether to force mount the component in the DOM | | `insets` | `Insets` | - | Screen edge insets to respect when positioning | | `asChild` | `boolean` | `false` | Whether to render as a child element | | `...Animated.ViewProps` | `Animated.ViewProps` | - | All Reanimated Animated.View props are supported | #### SelectContentPopoverAnimation Animation configuration for Select.Content component (popover presentation). Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default Keyframe animations (translateY/translateX, scale, opacity based on placement) * `object`: Custom animation configuration with `entering` and/or `exiting` Keyframe animations | prop | type | default | description | | ---------- | ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `entering` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for entering transition (default: Keyframe with translateY/translateX, scale, opacity based on placement, 200ms) | | `exiting` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for exiting transition (default: Keyframe mirroring entering animation, 150ms) | ### Select.Content (Bottom Sheet Presentation) | prop | type | default | description | | --------------------------- | ------------------ | ------- | ------------------------------------------------ | | `children` | `ReactNode` | - | The bottom sheet content | | `presentation` | `'bottom-sheet'` | - | Presentation mode for the select | | `contentContainerClassName` | `string` | - | Additional CSS classes for the content container | | `...BottomSheetProps` | `BottomSheetProps` | - | All @gorhom/bottom-sheet props are supported | ### Select.Content (Dialog Presentation) | prop | type | default | description | | -------------- | -------------------------------------------------------- | ------- | --------------------------------------------------- | | `children` | `ReactNode` | - | The dialog content | | `presentation` | `'dialog'` | - | Presentation mode for the select | | `classNames` | `{ wrapper?: string; content?: string }` | - | Additional CSS classes for wrapper and content | | `styles` | `Partial>` | - | Styles for different parts of the dialog content | | `animation` | `SelectContentAnimation` | - | Animation configuration | | `isSwipeable` | `boolean` | `true` | Whether the dialog content can be swiped to dismiss | | `forceMount` | `boolean` | - | Whether to force mount the component in the DOM | | `asChild` | `boolean` | `false` | Whether to render as a child element | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### `styles` | prop | type | description | | --------- | ----------- | -------------------------------- | | `wrapper` | `ViewStyle` | Styles for the wrapper container | | `content` | `ViewStyle` | Styles for the dialog content | #### SelectContentAnimation Animation configuration for Select.Content component (dialog presentation). Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default Keyframe animations (scale and opacity transitions) * `object`: Custom animation configuration with `entering` and/or `exiting` Keyframe animations | prop | type | default | description | | ---------- | ----------------------- | ------- | -------------------------------------------------------------------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `entering` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for entering transition (default: Keyframe with scale and opacity, 200ms) | | `exiting` | `EntryOrExitLayoutType` | - | Custom Keyframe animation for exiting transition (default: Keyframe mirroring entering animation, 150ms) | ### Select.Close Select.Close extends [CloseButton](./close-button) and automatically handles select dismissal when pressed. ### Select.ListLabel | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------- | | `children` | `ReactNode` | - | The label text content | | `className` | `string` | - | Additional CSS classes for the list label | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ### Select.Item | prop | type | default | description | | ------------------- | ------------------------------------------------------------ | ------- | -------------------------------------------------------------------------- | | `children` | `ReactNode \| ((props: SelectItemRenderProps) => ReactNode)` | - | Custom item content. Defaults to label and indicator, or a render function | | `value` | `any` | - | The value associated with this item (required) | | `label` | `string` | - | The label text for this item (required) | | `isDisabled` | `boolean` | `false` | Whether this item is disabled | | `className` | `string` | - | Additional CSS classes for the item | | `...PressableProps` | `PressableProps` | - | All standard React Native Pressable props are supported | #### SelectItemRenderProps When using a render function for `children`, the following props are provided: | property | type | description | | ------------ | --------- | --------------------------------------- | | `isSelected` | `boolean` | Whether this item is currently selected | | `value` | `string` | The value of the item | | `isDisabled` | `boolean` | Whether the item is disabled | ### Select.ItemLabel | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------- | | `className` | `string` | - | Additional CSS classes for the item label | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ### Select.ItemDescription | prop | type | default | description | | -------------- | ----------- | ------- | -------------------------------------------------- | | `children` | `ReactNode` | - | The description text content | | `className` | `string` | - | Additional CSS classes for the item description | | `...TextProps` | `TextProps` | - | All standard React Native Text props are supported | ### Select.ItemIndicator | prop | type | default | description | | -------------- | ------------------------------ | ------- | -------------------------------------------------- | | `children` | `ReactNode` | - | Custom indicator content. Defaults to check icon | | `className` | `string` | - | Additional CSS classes for the item indicator | | `iconProps` | `SelectItemIndicatorIconProps` | - | Check icon configuration | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### SelectItemIndicatorIconProps | prop | type | default | description | | ------- | -------- | ---------------- | ----------------- | | `size` | `number` | `16` | Size of the icon | | `color` | `string` | `--colors-muted` | Color of the icon | ## Hooks ### useSelect Hook to access the Select root context. Returns the select state and control functions. ```tsx import { useSelect } from 'heroui-native'; const { isOpen, onOpenChange, isDefaultOpen, isDisabled, presentation, triggerPosition, setTriggerPosition, contentLayout, setContentLayout, nativeID, value, onValueChange, } = useSelect(); ``` #### Return Value | property | type | description | | -------------------- | -------------------------------------------- | --------------------------------------------------------- | | `isOpen` | `boolean` | Whether the select is currently open | | `onOpenChange` | `(open: boolean) => void` | Callback to change the open state | | `isDefaultOpen` | `boolean \| undefined` | Whether the select is open by default (uncontrolled mode) | | `isDisabled` | `boolean \| undefined` | Whether the select is disabled | | `presentation` | `'popover' \| 'bottom-sheet' \| 'dialog'` | Presentation mode for the select content | | `triggerPosition` | `LayoutPosition \| null` | Position of the trigger element relative to viewport | | `setTriggerPosition` | `(position: LayoutPosition \| null) => void` | Updates the trigger element's position | | `contentLayout` | `LayoutRectangle \| null` | Layout measurements of the select content | | `setContentLayout` | `(layout: LayoutRectangle \| null) => void` | Updates the content layout measurements | | `nativeID` | `string` | Unique identifier for the select instance | | `value` | `SelectOption` | Currently selected option | | `onValueChange` | `(option: SelectOption) => void` | Callback fired when the selected value changes | **Note:** This hook must be used within a `Select` component. It will throw an error if called outside of the select context. ### useSelectAnimation Hook to access the Select animation state values within custom components or compound components. ```tsx import { useSelectAnimation } from 'heroui-native'; const { selectState, progress, isDragging, isGestureReleaseAnimationRunning } = useSelectAnimation(); ``` #### Return Value | property | type | description | | ---------------------------------- | ---------------------- | ---------------------------------------------------------- | | `progress` | `SharedValue` | Progress value for animations (0=idle, 1=open, 2=close) | | `isDragging` | `SharedValue` | Whether the select content is currently being dragged | | `isGestureReleaseAnimationRunning` | `SharedValue` | Whether the gesture release animation is currently running | **Note:** This hook must be used within a `Select` component. It will throw an error if called outside of the select animation context. #### SelectOption | property | type | description | | -------- | -------- | ---------------------------- | | `value` | `string` | The value of the option | | `label` | `string` | The label text of the option | ### useSelectItem Hook to access the Select Item context. Returns the item's value and label. ```tsx import { useSelectItem } from 'heroui-native'; const { itemValue, label } = useSelectItem(); ``` #### Return Value | property | type | description | | ----------- | -------- | ---------------------------------- | | `itemValue` | `string` | The value of the current item | | `label` | `string` | The label text of the current item | ## Special Notes ### Element Inspector (iOS) Select uses FullWindowOverlay on iOS. To enable the React Native element inspector during development, set `disableFullWindowOverlay={true}` on `Select.Portal`. Tradeoff: the select dropdown will not appear above native modals when disabled. # Switch **Category**: native **URL**: https://v3.heroui.com/docs/native/components/switch **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/switch.mdx > A toggle control that allows users to switch between on and off states. ## Import ```tsx import { Switch } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ... ``` * **Switch**: Main container that handles toggle state and user interaction. Renders default thumb if no children provided. Animates scale (on press) and background color based on selection state. Acts as a pressable area for toggling. * **Switch.Thumb**: Optional sliding thumb element that moves between positions. Uses spring animation for smooth transitions. Can contain custom content like icons or be customized with different styles and animations. * **Switch.StartContent**: Optional content displayed on the left side of the switch. Typically used for icons or text that appear when switch is off. Positioned absolutely within the switch container. * **Switch.EndContent**: Optional content displayed on the right side of the switch. Typically used for icons or text that appear when switch is on. Positioned absolutely within the switch container. ## Usage ### Basic Usage The Switch component renders with default thumb if no children provided. ```tsx ``` ### With Custom Thumb Replace the default thumb with custom content using the Thumb component. ```tsx ... ``` ### With Start and End Content Add icons or text that appear on each side of the switch. ```tsx ... ... ``` ### With Render Function Use render functions for dynamic content based on switch state. ```tsx {({ isSelected, isDisabled }) => ( <> {({ isSelected }) => (isSelected ? : )} )} ``` ### With Custom Animations Customize animations for the switch root and thumb components. ```tsx ``` ### Disable Animations Disable animations entirely or only for specific components. ```tsx { /* Disable all animations including children */ } ; { /* Disable only root animations, thumb can still animate */ } ; ``` ## Example ```tsx import { Switch } from 'heroui-native'; import { Ionicons } from '@expo/vector-icons'; import React from 'react'; import { View } from 'react-native'; import Animated, { ZoomIn } from 'react-native-reanimated'; export default function SwitchExample() { const [darkMode, setDarkMode] = React.useState(false); return ( {darkMode && ( )} {!darkMode && ( )} ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/rc/example/src/app/\(home\)/components/switch.tsx). ## API Reference ### Switch | prop | type | default | description | | --------------------------- | -------------------------------------------------------------------- | ----------- | ------------------------------------------------------------ | | `children` | `React.ReactNode \| ((props: SwitchRenderProps) => React.ReactNode)` | `undefined` | Content to render inside the switch, or a render function | | `isSelected` | `boolean` | `undefined` | Whether the switch is currently selected | | `isDisabled` | `boolean` | `false` | Whether the switch is disabled and cannot be interacted with | | `className` | `string` | `undefined` | Custom class name for the switch | | `animation` | `SwitchRootAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `onSelectedChange` | `(isSelected: boolean) => void` | - | Callback fired when the switch selection state changes | | `...AnimatedPressableProps` | `AnimatedProps` | - | All React Native Reanimated Pressable props are supported | #### SwitchRenderProps | prop | type | description | | ------------ | --------- | ------------------------------ | | `isSelected` | `boolean` | Whether the switch is selected | | `isDisabled` | `boolean` | Whether the switch is disabled | #### SwitchRootAnimation Animation configuration for Switch component. Can be: * `false` or `"disabled"`: Disable only root animations * `"disable-all"`: Disable all animations including children * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------------------ | ---------------------------------------- | -------------------------------------------------------------- | ----------------------------------------------- | | `state` | `'disabled' \| 'disable-all' \| boolean` | - | Disable animations while customizing properties | | `scale.value` | `[number, number]` | `[1, 0.96]` | Scale values \[unpressed, pressed] | | `scale.timingConfig` | `WithTimingConfig` | `{ duration: 150 }` | Animation timing configuration | | `backgroundColor.value` | `[string, string]` | Uses theme colors | Background color values \[unselected, selected] | | `backgroundColor.timingConfig` | `WithTimingConfig` | `{ duration: 175, easing: Easing.bezier(0.25, 0.1, 0.25, 1) }` | Animation timing configuration | ### Switch.Thumb | prop | type | default | description | | ----------------------- | -------------------------------------------------------------------- | ----------- | ------------------------------------------------------------ | | `children` | `React.ReactNode \| ((props: SwitchRenderProps) => React.ReactNode)` | `undefined` | Content to render inside the thumb, or a render function | | `className` | `string` | `undefined` | Custom class name for the thumb element | | `animation` | `SwitchThumbAnimation` | - | Animation configuration | | `isAnimatedStyleActive` | `boolean` | `true` | Whether animated styles (react-native-reanimated) are active | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | #### SwitchThumbAnimation Animation configuration for Switch.Thumb component. Can be: * `false` or `"disabled"`: Disable all animations * `true` or `undefined`: Use default animations * `object`: Custom animation configuration | prop | type | default | description | | ------------------------------ | ----------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- | | `state` | `'disabled' \| boolean` | - | Disable animations while customizing properties | | `left.value` | `number` | `2` | Offset value from the edges (left when unselected, right when selected) | | `left.springConfig` | `WithSpringConfig` | `{ damping: 120, stiffness: 1600, mass: 2 }` | Spring animation configuration for thumb position | | `backgroundColor.value` | `[string, string]` | `['white', theme accent-foreground color]` | Background color values \[unselected, selected] | | `backgroundColor.timingConfig` | `WithTimingConfig` | `{ duration: 175, easing: Easing.bezier(0.25, 0.1, 0.25, 1) }` | Animation timing configuration | ### Switch.StartContent | prop | type | default | description | | -------------- | ----------------- | ----------- | -------------------------------------------------- | | `children` | `React.ReactNode` | `undefined` | Content to render inside the switch content | | `className` | `string` | `undefined` | Custom class name for the content element | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ### Switch.EndContent | prop | type | default | description | | -------------- | ----------------- | ----------- | -------------------------------------------------- | | `children` | `React.ReactNode` | `undefined` | Content to render inside the switch content | | `className` | `string` | `undefined` | Custom class name for the content element | | `...ViewProps` | `ViewProps` | - | All standard React Native View props are supported | ## Hooks ### useSwitch A hook that provides access to the Switch context. This is useful when building custom switch components or when you need to access switch state in child components. **Returns:** | Property | Type | Description | | ------------ | --------- | ------------------------------ | | `isSelected` | `boolean` | Whether the switch is selected | | `isDisabled` | `boolean` | Whether the switch is disabled | **Example:** ```tsx import { useSwitch } from 'heroui-native'; function CustomSwitchContent() { const { isSelected, isDisabled } = useSwitch(); return ( Status: {isSelected ? 'On' : 'Off'} {isDisabled && Disabled} ); } // Usage ; ``` ## Special Notes ### Border Styling If you need to apply a border to the switch root, use the `outline` style properties instead of `border`. This ensures the border doesn't affect the internal layout calculations for the thumb position: ```tsx ``` Using `outline` keeps the border visual without impacting the switch's internal width calculations, ensuring the thumb animates correctly. ### Integration with ControlField The Switch component integrates seamlessly with ControlField for press state sharing: ```tsx import { Description, ControlField, Label } from 'heroui-native'; Receive push notifications ``` When wrapped in ControlField, the Switch will automatically respond to press events on the entire ControlField container, creating a larger touch target and better user experience. # TextArea **Category**: native **URL**: https://v3.heroui.com/docs/native/components/text-area **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/text-area.mdx > A multiline text input component with styled border and background for collecting longer user input. ## Import ```tsx import { TextArea } from 'heroui-native'; ``` ## Usage ### Basic Usage TextArea can be used standalone or within a TextField component. ```tsx import { TextArea } from 'heroui-native';