Skip to content

components/ShowMore

import { … } from 'zidane-ui'ui/src/components/ShowMore.tsx

Components#

ShowMoreButtonComponent#

The Show more button under a capped list, on the rows' left edge. Every capped list in the kit uses it, with useShowMore.

TypeScript
function ShowMoreButton(props: ShowMoreButtonProps): Element | null
Parameters
NameTypeDescription
propsShowMoreButtonProps

Component props.

Element | null
ShowMoreButton props
NameTypeDescription
className?string

Extra classes on the root. Default: on a list's rows' edge.

expanded?boolean

The list was expanded: with ShowMoreButtonProps.onFewer, the button reads Show fewer.

hiddennumber

How many items are hidden. Nothing renders at 0, unless the list is expanded and can show fewer.

onFewer?() => void

Caps the list again. Without it, an expanded list shows no button.

onMore() => void

Shows them.

style?CSSProperties

Inline styles on the root element.

ui/src/components/ShowMore.tsx:62

Functions#

useShowMoreFunction#

Caps a list at cap items until Show more is pressed.

TypeScript
function useShowMore<T>(list: readonly T[], cap?: number): ShowMore<T>
Type parameters
NameDescription
T
Parameters
NameTypeDefaultDescription
listreadonly T[]

The whole list.

cap?numberSHOW_MORE_CAP

How many show at first. Default: SHOW_MORE_CAP.

ui/src/components/ShowMore.tsx:32

Constants#

SHOW_MORE_CAPConstant#

How many rows a list shows before Show more, unless it says otherwise.

TypeScript
const SHOW_MORE_CAP = 8

ui/src/components/ShowMore.tsx:10

Interfaces#

ShowMoreInterface#

What useShowMore returns.

TypeScript
interface ShowMore<T>
ShowMore type parameters
NameDescription
T
ShowMore properties
NameTypeDescription
expandedboolean

Whether Show more was pressed.

fewer() => void

Caps the list again.

hiddennumber

How many are hidden.

more() => void

Shows them all.

shownreadonly T[]

The items shown.

ui/src/components/ShowMore.tsx:13

ShowMoreButtonPropsInterface#

Props for ShowMoreButton.

TypeScript
interface ShowMoreButtonProps
ShowMoreButtonProps properties
NameTypeDescription
className?string

Extra classes on the root. Default: on a list's rows' edge.

expanded?boolean

The list was expanded: with ShowMoreButtonProps.onFewer, the button reads Show fewer.

hiddennumber

How many items are hidden. Nothing renders at 0, unless the list is expanded and can show fewer.

onFewer?() => void

Caps the list again. Without it, an expanded list shows no button.

onMore() => void

Shows them.

style?CSSProperties

Inline styles on the root element.

ui/src/components/ShowMore.tsx:41