Components
Layout
PhoenixPaper.Box, Container, Stack, Grid / GridItem, and Divider: Tailwind-native layout primitives in the spirit of MUI's Layout category. Every page on this site, including this one, is built out of them.
Box
A bare div/span/pre that exists purely to hold a class: no visual style of its own, and the only component with no paperize attr at all, since there's no skin to strip.
Preview
tag="pre", whitespace preserved.
Options
- tag
- div | span | pre (default: div)
<.pp_box class="rounded-lg bg-pp-surface-variant p-4">A div (default).</.pp_box>
<.pp_box tag="span" class="rounded bg-pp-surface-variant px-2 py-1">A span.</.pp_box>
<.pp_box tag="pre" class="rounded-lg bg-pp-surface-variant p-4">A pre, whitespace preserved.</.pp_box>
Container
A centered, width-constrained content wrapper. This very page's content sits inside one (max_width=lg); here it is again, nested, at two other widths.
max_width comparison
Options
- max_width
- sm | md | lg | xl | 2xl | full (default: lg)
- paperize
- boolean (default: true)
<.pp_container max_width="sm">
Narrower content.
</.pp_container>
<.pp_container :for={width <- ~w(sm md lg xl 2xl full)} max_width={width} class="mb-2">
{width}
</.pp_container>
Stack
A one-dimensional flex layout: row or column, with consistent spacing between children. No divider slot to auto-interleave (a stateless component only gets one opaque inner_block); add a Divider yourself where you want one. The bordered canvas around every demo on this site is a pp_stack.
direction: row
direction: column
Options
- direction
- row | column (default: column)
- spacing
- a Spacing token, :none | :xs | :sm | :md | :lg | :xl | :2xl (default: :md)
- wrap
- boolean (default: false)
<.pp_stack direction="row" spacing={:sm}>
<.pp_button>Save</.pp_button>
<.pp_button variant="outlined">Cancel</.pp_button>
</.pp_stack>
<.pp_stack direction="column" spacing={:sm}>
<.pp_button>Save</.pp_button>
<.pp_button variant="outlined">Cancel</.pp_button>
</.pp_stack>
Grid & GridItem
A 12-column CSS grid container, paired with GridItem for each column-spanning child. GridItem's md attribute overrides its span at the md: breakpoint and up, the only responsive breakpoint supported, since every value has to be a literal Tailwind class.
Even thirds
Stack on mobile, three columns on desktop (span=12 md=4)
Options
- pp_grid spacing
- a Spacing token (default: :md)
- pp_grid_item span
- 1-12 (default: 12)
- pp_grid_item md
- 1-12, overrides span at md: and up (default: nil, no override)
<.pp_grid>
<.pp_grid_item span={12} md={4}>Sidebar</.pp_grid_item>
<.pp_grid_item span={12} md={8}>Content</.pp_grid_item>
</.pp_grid>
Divider
A thin separator line, most often used between sections of a List.
Variants
Below
Options
- inset
- boolean, indent past a leading icon/avatar column instead of spanning full width (default: false)
<.pp_divider />
<.pp_divider inset />