An image gallery that displays up to four images by default. Also supports
reordering and deletion of images and blurred image previews for images loaded
from tsimg.cloud
.
You should have the chayns-components
package installed. If that is not the
case already, run
yarn add chayns-components
or
npm i chayns-components
After the chayns-components
package is installed, you can import the component
and use it with React:
import React from 'react'
import { Gallery } from 'chayns-components';
// ...
<Gallery {...} />
The Gallery
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
images | custom |
||
onClick | function |
||
onDelete | function |
||
deleteMode | boolean |
false |
|
height | number | string |
||
width | number | string |
||
className | string |
||
style | { [key: string]: string | number } |
{} |
|
stopPropagation | boolean |
false |
|
dragMode | boolean |
false |
|
onDragEnd | function |
||
preventParams | boolean |
false |
|
smallTiles | boolean |
false |
images?: custom
An array of strings or File objects that will be the image sources.
onClick?: function
A function that is called when an Image is clicked.
onDelete?: function
A function that is called when an image is deleted in deletion mode.
deleteMode?: boolean
Wether the deletion mode is active.
height?: number | string
The height of the gallery as a number of pixels or CSS string.
width?: number | string
The width of the gallery as a number of pixels or CSS string.
className?: string
A classname string that will be applied to the root container.
style?: { [key: string]: string | number }
A React style object that is applied to the root container.
stopPropagation?: boolean
Wether to stop propagation of click events to parent elements.
dragMode?: boolean
Wether drag mode is active.
onDragEnd?: function
Called after the user finished reordering the array. Receives the new array as its first parameter.
preventParams?: boolean
This will be forwarded to the Image
-component. It prevents parameters of the
loaded image. E.g. supply { width: true }
to prevent the width
-parameter on
the loaded image.
smallTiles?: boolean
This option changes the layout to the layout known from delete- and drag-mode without activating this modes.