The items in a list to display related data in a structured format. Should be
used inside of a List
component.
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 { ListItem } from 'chayns-components';
// ...
<ListItem {...} />
The ListItem
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
title | ReactNode | Array<ReactNode> |
✓ | |
subtitle | ReactNode | Array<ReactNode> |
||
image | string |
||
images | Array<string> |
||
openImageOnClick | boolean |
false |
|
icon | string | object |
||
className | string |
||
onClick | function |
||
right | ReactNode | Array<ReactNode> |
||
style | { head: { [key: string]: string | number }, body: { [key: string]: string | number } } |
||
headerProps | object |
||
circle | boolean |
false |
|
hoverItem | ReactNode |
||
onLongPress | function |
||
onMouseDown | function |
||
onMouseMove | function |
||
onMouseUp | function |
||
onTouchStart | function |
||
onTouchMove | function |
||
onTouchEnd | function |
||
onTouchCancel | function |
||
longPressTimeout | number |
450 |
|
noContentClass | boolean |
||
onOpen | function |
||
imageBorderColor | string |
'rgba(var(--chayns-color-rgb--009), .08)' |
|
headMultiline | boolean |
false |
title: ReactNode | Array<ReactNode>;
A string or ReactNode
that will be rendered as the title of the list item.
subtitle?: ReactNode | Array<ReactNode>
A string or ReactNode
that will be rendered as the subtitle of the list item.
image?: string
The URL to an image that will be shown on the left of the list item.
images?: Array<string>
An array of URLs for creating a puzzle of images on the left hand of the image item.
openImageOnClick?: boolean
Whether the image/images should be opened at full size when clicked only works if either image or images is defined
icon?: string | object
An icon to show on the left side of the list item.
className?: string
A classname string that will be applied ot the outer-most <div>
-element of the
list item.
onClick?: function
An onClick
-listener for the list item header.
right?: ReactNode | Array<ReactNode>
A ReactNode
that should be displayed on the right side of the list item.
style?: { head: { [key: string]: string | number }, body: { [key: string]: string | number } }
A React style object that will be applied to the outer-most <div>
-element of
the list item. style.body
and style.head
will be applied to the body and
head parts of the list item accordingly.
headerProps?: object
Any additional props that will be applied to the head of the list item.
circle?: boolean
Wether the image should be in a circular shape rather than a rectangle.
hoverItem?: ReactNode
A ReactNode that is shown on the right side of the list item on hover.
onLongPress?: function
This function will be called when the user long-presses on the list item header.
onMouseDown?: function
A callback for the mousedown
-event on the list item header.
onMouseMove?: function
A callback for the mousemove
-event on the list item header.
onMouseUp?: function
A callback for the mouseup
-event on the list item header.
onTouchStart?: function
A callback for the touchstart
-event on the list item header.
onTouchMove?: function
A callback for the touchmove
-event on the list item header.
onTouchEnd?: function
A callback for the touchend
-event on the list item header.
onTouchCancel?: function
A callback for the touchcancel
-event on the list item header.
longPressTimeout?: number
Control the time after which a press is considered a long press.
noContentClass?: boolean
Whether the default classname for the children container should be removed, which removes the padding around the list item content.
onOpen?: function
This function will be called when the list item is opening.
imageBorderColor?: string
A CSS color that will be applied to the border of the image.
headMultiline?: boolean
Whether the head of the list item should be multiline or ellipsis in expanded state