Customize rendered elements with render functions
mainReact Photo Album allows full UI customization by providing custom render functions via the render prop. Each function receives the default element's props as the first argument (typically including style and className). Some functions also receive a second argument representing the photo rendering context.
Photo Rendering Context
When the second argument is provided, it contains:
photo: ThePhotoobject.index: The index of the photo in the originalphotosarray.width: Rendered photo width in pixels.height: Rendered photo height in pixels.
Available Render Functions
container: Customizes the main albumdiv. Must forward therefattribute to the underlying element.track: Customizes row/column containers.wrapper: Customizes the image wrapper (used when photos are not clickable).link: Customizes the link element (used when a photo has anhref).button: Customizes the button element (used when anonClickcallback is provided).image: Customizes the<img>element.extras: Renders custom markup immediately after each image (useful for absolute positioned icons).photo: A complete override that replaceswrapper,link,button,image, andextras. It only receivesonClickin the first argument.
// Example: Customizing the container (must forward ref)
<RowsPhotoAlbum
photos={photos}
render={{
container: ({ ref, ...rest }) => <div ref={ref} {...rest} />,
}}
/>
// Example: Adding custom icons via extras
<RowsPhotoAlbum
photos={photos}
render={{
extras: (_, { photo, index }) => (
<FavoriteIcon photo={photo} index={index} />
),
}}
/>
// Example: Complete photo override
<RowsPhotoAlbum
photos={photos}
render={{
photo: ({ onClick }, { photo, width, height }) => (
<CustomPhoto
photo={photo}
width={width}
height={height}
onClick={onClick}
/>
),
}}
/>