Skip to main content

MediaPickerButton

Image/media picker button with preview and aspect ratio support.

Basic Usage​

import { MediaPickerButton } from '@multinaire/expo-ui';

<MediaPickerButton
placeholder="Select image"
value={imageSource}
onPress={() => pickImage()}
/>

Props​

PropTypeDefaultDescription
placeholderstring—Placeholder text shown when the field is empty
valueImageSourcePropType—Currently selected image source
titlestring—Field label displayed above the input
requiredbooleanfalseMark the field as required. Displays a visual indicator
placeholderIconIconName—Fallback icon shown when no media is selected
aspectRatio'1:1' | '16:9' | '9:16''1:1'Aspect ratio of the media preview
extraReactElement—Extra element rendered at the trailing end of the label row (e.g. a "Forgot password?" link)
errorTextstring—Error message displayed below the input
clearTextstring—Label for the clear action button
flexnumber—Flex grow value
marginSpacingProps—Outer margin
isLoadingbooleanfalseShow a loading state while the media is uploading or processing
testIDstring—Test identifier for UI automation
onPress() => void—Press handler that opens the media picker
onClear() => void—Callback invoked when the user removes the selected media

Examples​

Profile Photo Picker​

<MediaPickerButton
title="Profile Photo"
placeholder="Add photo"
placeholderIcon="Camera"
value={profileImage}
aspectRatio="1:1"
onPress={pickProfilePhoto}
onClear={() => setProfileImage(null)}
clearText="Remove"
/>

Cover Image Picker​

<MediaPickerButton
title="Cover Image"
placeholder="Add cover image"
value={coverImage}
aspectRatio="16:9"
onPress={pickCoverImage}
/>

Story Image Picker​

<MediaPickerButton
placeholder="Add story"
value={storyImage}
aspectRatio="9:16"
onPress={pickStoryImage}
/>

With Loading State​

<MediaPickerButton
title="Upload Image"
placeholder="Select image"
value={image}
isLoading={isUploading}
onPress={pickAndUploadImage}
/>

With Validation​

<MediaPickerButton
title="ID Document"
required
placeholder="Upload ID"
value={idDocument}
errorText={!idDocument ? 'ID document is required' : undefined}
onPress={pickIdDocument}
/>