# The library

> The components of songstress/ui for the library, each as Songstress draws it, with its props and an example.

Page: https://songstress.app/docs/develop/components/library/

Songstress’s own things, named by library id and drawn exactly as the app draws them everywhere else, with their own menus, covers and Play. Client code learns ids from the player, a panel’s context or a command of your server entry.

Each picture is the SDK’s own test tree for the component, drawn by the web app; every app draws the same tree with its own controls, the phones natively. Each example is the one in the SDK’s doc comment, which its tests compile, and the props are read from its types.

## SongItem [#songitem]

<Shot name="gallery/song-item" alt="A song from the library, as a row with its cover, artist and menu" />

A song of the library, drawn as Songstress draws it: a `song` node.

```tsx
import { List, SongItem } from 'songstress/ui'

const songIds = ['s1', 's2']
const recent = <List title="Played lately">{songIds.map((id) => <SongItem key={id} id={id} />)}</List>
```

The props of a `SongItem`, an `AlbumItem`, an `ArtistItem` or a
`PlaylistItem`: something of the library, by its id.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Its library id. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

## AlbumItem [#albumitem]

<Shot name="gallery/album-item" alt="An album from the library, as Songstress draws it" />

An album of the library: an `album` node.

```tsx
import { AlbumItem, Shelf } from 'songstress/ui'

const albumIds = ['al-1', 'al-2']
const albums = <Shelf title="Albums">{albumIds.map((id) => <AlbumItem key={id} id={id} />)}</Shelf>
```

The props of a `SongItem`, an `AlbumItem`, an `ArtistItem` or a
`PlaylistItem`: something of the library, by its id.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Its library id. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

## ArtistItem [#artistitem]

<Shot name="gallery/artist-item" alt="An artist from the library, as Songstress draws it" />

An artist of the library: an `artist` node.

```tsx
import { ArtistItem, Shelf } from 'songstress/ui'

const artists = (
  <Shelf title="Artists">
    <ArtistItem id="ar-1" />
    <ArtistItem id="ar-2" />
  </Shelf>
)
```

The props of a `SongItem`, an `AlbumItem`, an `ArtistItem` or a
`PlaylistItem`: something of the library, by its id.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Its library id. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

## PlaylistItem [#playlistitem]

<Shot name="gallery/playlist-item" alt="A playlist from the library, as Songstress draws it" />

A playlist of the library: a `playlist` node, a card of a `Shelf` (a
`List` takes rows and songs alone).

```tsx
import { PlaylistItem, Shelf } from 'songstress/ui'

const playlists = (
  <Shelf title="Your playlists">
    <PlaylistItem id="pl-1" />
  </Shelf>
)
```

The props of a `SongItem`, an `AlbumItem`, an `ArtistItem` or a
`PlaylistItem`: something of the library, by its id.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Its library id. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

## PlayButton [#playbutton]

<Shot name="gallery/play-button" alt="The app’s own Play, for an album, and Play both for two songs" />

The app's own Play button, for songs, an album, an artist or a playlist:
a `play-button` node.

```tsx
import { PlayButton } from 'songstress/ui'

const play = <PlayButton what={{ albumId: 'al-1' }} title="Play the album" />
```

A `PlayButton`'s props.

| Field | Type | Description |
|---|---|---|
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `what` | `Playable` | What it plays. |
| `title?` | `string \| undefined` | Its label. Left out, "Play". |
