Skip to Content
Documentation

Layout

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

Components that arrange others: stacks, grids, surfaces, sections, and what folds or switches. None of them draws anything of its own but room, a surface or a rule.

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.

Stack

Stacks with each step of gap and padding, from none to xlarge, and their alignmentsStacks with each step of gap and padding, from none to xlarge, and their alignments

Blocks under one another: a stack node.

Example: Stack
import { Stack, Text } from 'songstress/ui'

const header = (
  <Stack gap="xsmall">
    <Text style="heading">Played lately</Text>
    <Text tone="muted">12 songs this week</Text>
  </Stack>
)

In the reference: Stack.

Prop

Type

HStack

A horizontal stack: a text that takes the room left, beside a buttonA horizontal stack: a text that takes the room left, beside a button

Blocks beside one another, going on to a new line when they do not fit (wrap): a stack node with direction: "horizontal".

Example: HStack
import { Badge, Glyph, HStack, Spacer, Text } from 'songstress/ui'

const row = (
  <HStack gap="small" align="center">
    <Glyph name="headphones" />
    <Text>Listening now</Text>
    <Spacer />
    <Badge tone="accent">Live</Badge>
  </HStack>
)

In the reference: HStack.

Prop

Type

Grid

A grid of blocks in columns, and one that fits as many as there is room forA grid of blocks in columns, and one that fits as many as there is room for

Blocks in columns: a grid node.

Example: Grid
import { Box, Grid, Text } from 'songstress/ui'

const totals = (
  <Grid columns={2} gap="small">
    <Box variant="card"><Text style="label">Plays</Text><Text style="title">42</Text></Box>
    <Box variant="card"><Text style="label">Hours</Text><Text style="title">3</Text></Box>
  </Grid>
)

In the reference: Grid.

Prop

Type

Box

Three boxes: plain, the app’s card, and a quiet insetThree boxes: plain, the app’s card, and a quiet inset

A surface around blocks: a box node, plain, the app's card, or a quiet inset.

Example: Box
import { Box, Text } from 'songstress/ui'

const week = (
  <Box variant="card" padding="medium" gap="xsmall">
    <Text style="label">This week</Text>
    <Text style="title">42 plays</Text>
  </Box>
)

In the reference: Box.

Prop

Type

Section

A section with its title over the blocks it holdsA section with its title over the blocks it holds

Blocks under a heading: a section node.

Example: Section
import { Section, Text } from 'songstress/ui'

const today = (
  <Section title="Today" footer="Counted on this device.">
    <Text>3 songs started</Text>
  </Section>
)

In the reference: Section.

Prop

Type

Spacer

A spacer draws nothing: it is room, of a step or, with grow, all that is left in a horizontal stack.

Room between blocks: a spacer node.

Example: Spacer
import { HStack, Spacer, Text } from 'songstress/ui'

// In an HStack, a Spacer takes the room left: the count goes to the far end.
const line = (
  <HStack>
    <Text>So What</Text>
    <Spacer />
    <Text tone="muted">12 plays</Text>
  </HStack>
)

In the reference: Spacer.

Prop

Type

Divider

A divider across its parentA divider across its parent

A line between blocks: a divider node.

Example: Divider
import { Divider, Stack, Text } from 'songstress/ui'

const parts = (
  <Stack gap="small">
    <Text>This week</Text>
    <Divider />
    <Text>Last week</Text>
  </Stack>
)

In the reference: Divider.

Prop

Type

Collapsible

A collapsible titled More, open on what it holdsA collapsible titled More, open on what it holds

Blocks a tap opens and closes: a collapsible node. With onChange, it is open exactly when open says.

Example: Collapsible
import { Collapsible, Text, useState } from 'songstress/ui'

function Credits() {
  const [open, setOpen] = useState(false)
  return (
    <Collapsible title="Credits" open={open} onChange={setOpen}>
      <Text>Recorded in one take.</Text>
    </Collapsible>
  )
}

In the reference: Collapsible.

Prop

Type

Tabs

Tabs: a switcher over the group of blocks it showsTabs: a switcher over the group of blocks it shows

One of several groups of blocks, under a switcher: a tabs node, its tabs its Tab children.

Example: Tabs
import { Tab, Tabs, Text, useState } from 'songstress/ui'

function Totals() {
  const [tab, setTab] = useState('week')
  return (
    <Tabs value={tab} onSelect={setTab}>
      <Tab id="week" title="This week"><Text>42 plays</Text></Tab>
      <Tab id="year" title="This year"><Text>1,204 plays</Text></Tab>
    </Tabs>
  )
}

In the reference: Tabs.

Prop

Type

Tab

One tab of a Tabs: its id, its title on the switcher, and its blocks.

Example: Tab
import { Tab, Tabs, Text } from 'songstress/ui'

const totals = (
  <Tabs>
    <Tab id="week" title="This week" icon="calendar"><Text>42 plays</Text></Tab>
    <Tab id="year" title="This year"><Text>1,204 plays</Text></Tab>
  </Tabs>
)

In the reference: Tab.

Prop

Type

On this page