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


Blocks under one another: a stack node.
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


Blocks beside one another, going on to a new line when they do not fit (wrap): a stack node with direction: "horizontal".
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


Blocks in columns: a grid node.
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


A surface around blocks: a box node, plain, the app's card, or a quiet inset.
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


Blocks under a heading: a section node.
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.
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 line between blocks: a divider node.
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


Blocks a tap opens and closes: a collapsible node. With onChange, it is open exactly when open says.
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


One of several groups of blocks, under a switcher: a tabs node, its tabs its Tab children.
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.
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