# components/ShowMore (zidane-ui)

Import: `import { … } from 'zidane-ui'`. Source: [ui/src/components/ShowMore.tsx](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx).

## Components

### `ShowMoreButton`

Component.

The Show more button under a capped list, on the rows' left edge. Every capped list in the kit uses it, with
[`useShowMore`](https://zidane.si/docs/reference/ui-components-show-more.md#useShowMore).

```ts
function ShowMoreButton(props: ShowMoreButtonProps): Element | null
```

**Parameters**

- `props` (`ShowMoreButtonProps`): Component props.

**Returns** `Element | null`

**Props**

- `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.
- `hidden` (`number`): 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.

Source: [ui/src/components/ShowMore.tsx:62](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx#L62)

## Functions

### `useShowMore`

Function.

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

```ts
function useShowMore<T>(list: readonly T[], cap?: number): ShowMore<T>
```

**Type parameters**

- `T`

**Parameters**

- `list` (`readonly T[]`): The whole list.
- `cap?` (`number`, default `SHOW_MORE_CAP`): How many show at first. Default: [`SHOW_MORE_CAP`](https://zidane.si/docs/reference/ui-components-show-more.md#SHOW_MORE_CAP).

**Returns** `ShowMore<T>`

Source: [ui/src/components/ShowMore.tsx:32](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx#L32)

## Constants

### `SHOW_MORE_CAP`

Constant.

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

```ts
const SHOW_MORE_CAP = 8
```

Source: [ui/src/components/ShowMore.tsx:10](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx#L10)

## Interfaces

### `ShowMore`

Interface.

What [`useShowMore`](https://zidane.si/docs/reference/ui-components-show-more.md#useShowMore) returns.

```ts
interface ShowMore<T>
```

**Type parameters**

- `T`

**Properties**

- `expanded` (`boolean`): Whether Show more was pressed.
- `fewer` (`() => void`): Caps the list again.
- `hidden` (`number`): How many are hidden.
- `more` (`() => void`): Shows them all.
- `shown` (`readonly T[]`): The items shown.

Source: [ui/src/components/ShowMore.tsx:13](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx#L13)

### `ShowMoreButtonProps`

Interface.

Props for [`ShowMoreButton`](https://zidane.si/docs/reference/ui-components-show-more.md#ShowMoreButton).

```ts
interface ShowMoreButtonProps
```

**Properties**

- `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.
- `hidden` (`number`): 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.

Source: [ui/src/components/ShowMore.tsx:41](https://github.com/Tahul/zidane/blob/main/ui/src/components/ShowMore.tsx#L41)
