Introduction
Components
- Accordion
- Action Sheet
- Alert
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Charts
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import React from 'react';
const sampleImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryDemo() {
return (
<Gallery
items={sampleImages}
columns={2}
spacing={8}
borderRadius={12}
enableFullscreen={true}
enableZoom={true}
/>
);
}
Installation
pnpm dlx bna-ui add gallery
Usage
import { Gallery } from '@/components/ui/gallery';
const galleryItems = [
{
id: '1',
uri: 'https://picsum.photos/400/400?random=1',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
},
{
id: '2',
uri: 'https://picsum.photos/400/400?random=2',
title: 'City Skyline',
description: 'Urban architecture at its finest',
},
// ... more items
];
<Gallery items={galleryItems} />;
Examples
Default
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import React from 'react';
const sampleImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryDemo() {
return (
<Gallery
items={sampleImages}
columns={2}
spacing={8}
borderRadius={12}
enableFullscreen={true}
enableZoom={true}
/>
);
}
Custom Grid
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import { ScrollView } from '@/components/ui/scroll-view';
import { Text } from '@/components/ui/text';
import { View } from '@/components/ui/view';
import React from 'react';
const gridImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryGrid() {
return (
<ScrollView
style={{ flex: 1 }}
contentContainerStyle={{
gap: 16,
paddingBottom: 32,
}}
showsVerticalScrollIndicator={false}
>
<View style={{ flex: 1 }}>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
4 Columns, No Spacing
</Text>
<Gallery
items={gridImages}
columns={4}
spacing={0}
borderRadius={0}
aspectRatio={1}
/>
</View>
<View style={{ flex: 1 }}>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
3 Columns with Spacing
</Text>
<Gallery
items={gridImages.slice(0, 6)}
columns={3}
spacing={12}
borderRadius={8}
aspectRatio={1.2}
/>
</View>
<View style={{ flex: 1 }}>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
2 Columns, Large Spacing
</Text>
<Gallery
items={gridImages.slice(0, 4)}
columns={2}
spacing={20}
borderRadius={16}
aspectRatio={0.8}
/>
</View>
</ScrollView>
);
}
With Titles and Descriptions
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import React from 'react';
const infoImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryInfo() {
return (
<Gallery
items={infoImages}
columns={2}
spacing={16}
borderRadius={12}
aspectRatio={1}
showTitles={true}
showDescriptions={true}
showPages={true}
enableFullscreen={true}
enableZoom={true}
/>
);
}
Different Layouts
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import { ScrollView } from '@/components/ui/scroll-view';
import { Text } from '@/components/ui/text';
import { View } from '@/components/ui/view';
import React from 'react';
const layoutImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryLayouts() {
return (
<ScrollView
style={{ flex: 1 }}
contentContainerStyle={{
gap: 16,
paddingBottom: 32,
}}
showsVerticalScrollIndicator={false}
>
<View>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
Single Column (Feed Style)
</Text>
<Gallery
items={layoutImages.slice(0, 3)}
columns={1}
spacing={16}
borderRadius={12}
aspectRatio={1.2}
showTitles={true}
/>
</View>
<View>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
Square Grid
</Text>
<Gallery
items={layoutImages}
columns={3}
spacing={4}
borderRadius={8}
aspectRatio={1}
/>
</View>
<View>
<Text variant='subtitle' style={{ marginBottom: 12 }}>
Wide Thumbnails
</Text>
<Gallery
items={layoutImages.slice(0, 4)}
columns={2}
spacing={8}
borderRadius={16}
aspectRatio={1.5}
/>
</View>
</ScrollView>
);
}
With Controls
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import React from 'react';
import { Alert } from 'react-native';
const controlImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryControls() {
const handleDownload = (item: GalleryItem) => {
Alert.alert('Download', `Downloading: ${item.title || 'Image'}`, [
{ text: 'OK' },
]);
};
const handleShare = (item: GalleryItem) => {
Alert.alert('Share', `Sharing: ${item.title || 'Image'}`, [{ text: 'OK' }]);
};
return (
<Gallery
items={controlImages}
columns={2}
spacing={12}
borderRadius={12}
aspectRatio={1}
showTitles={true}
showDescriptions={true}
showPages={true}
enableFullscreen={true}
enableZoom={true}
enableDownload={true}
enableShare={true}
onDownload={handleDownload}
onShare={handleShare}
/>
);
}
With Overlays
import { Gallery, GalleryItem } from '@/components/ui/gallery';
import { Text } from '@/components/ui/text';
import { View } from '@/components/ui/view';
import React from 'react';
const sampleImages: GalleryItem[] = [
{
id: '1',
uri: 'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'City Skyline',
description: 'Modern architecture at sunset',
thumbnail:
'https://images.unsplash.com/photo-1637858868799-7f26a0640eb6?q=80&w=2960&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '2',
uri: 'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Winter Wonderland',
description: 'Snow-covered peaks and pristine wilderness',
thumbnail:
'https://images.unsplash.com/photo-1644190022446-04b99df7259a?q=80&w=2012&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '3',
uri: 'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Ocean Waves',
description: 'Peaceful ocean scene with rolling waves',
thumbnail:
'https://images.unsplash.com/photo-1717732596477-04f8c5d53387?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '4',
uri: 'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Forest Path',
description: 'A winding path through ancient trees',
thumbnail:
'https://images.unsplash.com/photo-1575737698350-52e966f924d4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '5',
uri: 'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Desert Dunes',
description: 'Golden sand dunes stretching to the horizon',
thumbnail:
'https://images.unsplash.com/photo-1667830867718-da7f5a45d20d?q=80&w=1064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
{
id: '6',
uri: 'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
title: 'Beautiful Landscape',
description: 'A stunning view of mountains and valleys',
thumbnail:
'https://images.unsplash.com/photo-1593085512500-5d55148d6f0d?q=80&w=2334&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
},
];
export function GalleryOverlay() {
return (
<Gallery
items={sampleImages}
columns={2}
aspectRatio={1}
renderCustomOverlay={(item) => (
<View
style={{
position: 'absolute',
top: 8,
right: 8,
backgroundColor: 'rgba(0,0,0,0.7)',
borderRadius: 12,
paddingHorizontal: 8,
paddingVertical: 4,
}}
>
<Text
variant='caption'
style={{
color: 'white',
fontSize: 12,
fontWeight: 'bold',
}}
>
{item.title}
</Text>
</View>
)}
/>
);
}
API Reference
Gallery
The main gallery component that displays images in a grid layout with fullscreen viewing capabilities.
Prop | Type | Default | Description |
---|---|---|---|
items | GalleryItem[] | - | Array of gallery items to display. |
columns | number | 4 | Number of columns in the grid layout. |
spacing | number | 0 | Spacing between grid items in pixels. |
borderRadius | number | 0 | Border radius for gallery items. |
aspectRatio | number | 1 | Aspect ratio for gallery items (width/height). |
showPages | boolean | false | Show page indicator in fullscreen mode. |
showTitles | boolean | false | Show image titles in grid view. |
showDescriptions | boolean | false | Show image descriptions in grid view. |
enableFullscreen | boolean | true | Enable fullscreen viewing mode. |
enableZoom | boolean | true | Enable zoom functionality in fullscreen mode. |
enableDownload | boolean | false | Show download button in fullscreen mode. |
enableShare | boolean | false | Show share button in fullscreen mode. |
onItemPress | (item: GalleryItem, index: number) => void | - | Custom handler for item press events. |
onDownload | (item: GalleryItem) => void | - | Handler for download button press. |
onShare | (item: GalleryItem) => void | - | Handler for share button press. |
renderCustomOverlay | (item: GalleryItem, index: number) => React.ReactNode | - | Custom overlay renderer for grid items. |
GalleryItem
Interface for gallery items.
Property | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the gallery item. |
uri | string | Yes | Image URI for the full-size image. |
title | string | No | Optional title for the image. |
description | string | No | Optional description for the image. |
thumbnail | string | No | Optional thumbnail URI (falls back to uri ). |
Features
Gesture Support
- Pinch to zoom: Zoom in and out on images in fullscreen mode
- Double tap to zoom: Quick zoom to 2.5x scale or reset to original size
- Pan when zoomed: Drag zoomed images to view different areas
- Swipe navigation: Horizontal swipe to navigate between images
Fullscreen Mode
- Immersive fullscreen viewing experience
- Thumbnail navigation bar at the bottom
- Top controls for sharing, downloading, and closing
- Page indicators showing current position
Responsive Design
- Automatically adjusts to screen size
- Configurable grid columns and spacing
- Maintains aspect ratios across different devices
- Smooth animations and transitions
Performance Optimizations
- Lazy loading of off-screen images
- Efficient gesture handling with React Native Reanimated
- Optimized FlatList rendering for large galleries
- Thumbnail support for faster grid loading
Accessibility
The Gallery component includes accessibility features:
- Proper keyboard navigation support
- Screen reader compatibility
- High contrast support for UI elements
- Semantic structure for assistive technologies
- Touch target sizes meet accessibility guidelines
Troubleshooting
Common Issues
Gestures not working:
- Ensure
react-native-gesture-handler
is properly installed and configured - Make sure the component is wrapped in
GestureHandlerRootView
Images not loading:
- Verify image URIs are accessible
- Check network connectivity
- Ensure proper CORS configuration for web images
Performance issues with large galleries:
- Consider implementing pagination
- Use thumbnail images for grid view
- Optimize image sizes and formats
Zoom not working properly:
- Verify
react-native-reanimated
is correctly set up - Check that
enableZoom
prop is set totrue
- Ensure proper gesture handler configuration