Laying out views
Arrange views in columns, rows and layers, set spacing, padding and sizes, push things apart, scroll, and build grids.
In PadCode you lay out a screen by putting views inside containers. A Column stacks views top to bottom, a Row lines them up side by side, and Layers puts them on top of each other. Containers go inside containers, so a whole screen is a tree of them, which you can see in Layers.
On the Free plan, Column, Row, Layers, Spacer, Divider and Scroll Area are there; the other containers on this page are part of Pro. See Plans and billing.
#How a screen starts
Every new app, and every screen you add, starts with the same two containers:
- Screen, a Scroll Area, so a long screen scrolls instead of running off the bottom.
- Page, a Column inside it, with 24 points of padding, Width set to Fill, and its views lined up on the left.
When nothing is selected, tapping a Library tile adds the component to the end of the Page. You'll see both in Layers.
#Columns and rows
| Component | What it does |
|---|---|
| Column | Stacks items top to bottom. |
| Row | Lines items up side by side. |
| Long Column | A column for long scrolling content. Items are only built as they scroll into view. |
| Long Row | A row for long sideways-scrolling content. Items are only built as they scroll into view. |
Use a Long Column or Long Row for long lists, like one row per item of a big list. Put it in a Scroll Area so it scrolls: sideways for a Long Row.
When you drag a view onto the canvas, a line shows where it will land. Inside a Row the line appears to the left or right of a view; everywhere else, above or below.
#Spacing and alignment
A Column, a Row and their Long versions have two settings of their own, at the top of the Inspector's Style tab:
| Setting | What it does |
|---|---|
| Spacing | Space between the views inside, in points. Auto lets iOS choose. |
| Alignment | How the views inside line up with each other. In a Column: Left, Center or Right (Default is the center). Its two List Row Separator choices only matter inside a List. In a Row: Top, Center, Bottom, or along the first or last line of text (First Text Baseline, Last Text Baseline). |
A Column's alignment lines its views up with each other, so you see it when they have different widths. To line everything up on the left edge of the screen, set the Column's Alignment to Left and its Width to Fill, like the Page.
#Layers: views on top of each other
Layers places items on top of each other, each one drawn over the ones before it in the list. Use it for a badge on a photo, text over a picture, or a progress ring with a number in the middle.
- A new Layers fills the width, is at least 240 points tall, and places items from its top-left corner. Its Alignment picks where items sit: top left, center, bottom right and so on.
- Inside Layers, you can place views anywhere. Drop a component where you want it, or select a view inside Layers and drag it. PadCode keeps the position as the view's Offset (in Size & spacing), so you can fine-tune it by typing numbers.
- To bring a view to the front without reordering, give it a Layer Order modifier: higher numbers come to the front.
#Padding
Padding is empty space around a view, inside its background. Set it in the Inspector's Style tab, under Size & spacing:
- Padding puts the same space on every side, like 16.
- Sides sets each side on its own: T (top), L (left), B (bottom), R (right). When the sides differ, Padding shows Mixed.
Padding goes inside the view's background, so a card with a background color and 16 points of padding has room around its text. Use a container's padding to keep everything inside it away from its edges, and the container's Spacing to keep the views inside apart.
See Size & spacing.
#Width and height
Every view has Width and Height in Size & spacing:
| Choice | What it does |
|---|---|
| Auto | Fits the content: a Text is as wide as its words. Where most views start. |
| Fill | Takes all the room it can. A Fill button in a Column stretches across the Column. |
| Fixed | An exact size in points. Picking it starts at 120; type a different number in the box beside it. |
Once Width or Height isn't Auto, an Align setting appears: where the content sits when the view is bigger than it, like Top Left or Center.
Two Fill views side by side in a Row share the room between them. To nudge a view without moving anything around it, use Offset: X moves it right, Y moves it down, and negative numbers go left and up.
#Pushing views apart
| Component | What it does |
|---|---|
| Spacer | Empty space that stretches to push items apart. |
| Divider | A thin line between items. |
A Spacer takes up the free room in its Row or Column. In a Row, a Spacer between a title and a button pushes the button to the far edge. In a screen that scrolls, a Column is only as tall as what's in it, so a Spacer inside has no extra room to fill; Spacers are most useful in Rows.
#Scrolling
A Scroll Area lets its content scroll when it's too big for the screen. Its Direction setting picks the way it scrolls: down (Default, the same as Vertical) or across (Horizontal).
Every new screen is already a Scroll Area, so a page scrolls down on its own. For a strip that scrolls sideways, like a row of cards, add a Scroll Area inside the page, set its Direction to Horizontal, and put a Row (or Long Row) in it.
A List and a Form scroll by themselves.
#Grids
| Component | What it does |
|---|---|
| Grid | Rows and columns that line up, like a spreadsheet. |
| Grid Row | One row inside a Grid. |
| Gallery Grid | Tiles that fill columns and scroll down, like a photo gallery. |
| Sideways Grid | Tiles that fill rows and scroll sideways. |
- Grid is for tables: put a Grid Row in it for each row, and views in each Grid Row for its cells. The cells line up in columns across rows. Horizontal Spacing and Vertical Spacing set the gaps. To make one cell span several columns, give it a Column Span modifier.
- Gallery Grid flows its views into columns, left to right, then down. Its Columns setting is a counter, from 1 to 8 columns of equal width (2 to start). Sideways Grid does the same in rows, with a Rows counter.
#Grouping and choosing
| Component | What it does |
|---|---|
| Group | Groups items so they share settings, without changing the layout. |
| Box | A rounded box that sets related items apart, with an optional title. |
| Form | A settings-style page of grouped fields and switches. |
| Section | A titled group of rows inside a List or a Form. |
| Best Fit | Shows the first of its options that fits in the space available. |
| Adaptive Pair | Shows a main and a secondary view side by side or stacked, depending on the space. |
| Glass Group | Lets Liquid Glass items near each other blend and morph together. |
Best Fit is handy for screens that must work on both an iPhone and an iPad: put a Row and a Column with the same views inside it, and it shows the Row where it fits, the Column where it doesn't. Its Direction setting picks which way it checks for room.
#Wrap, unwrap and group
You don't have to plan containers first. Select a view, open ⋯ in the Inspector (or the layer's menu in Layers), and use:
- Wrap in: puts the view in a new Column, Row, Layers, Scroll Area, Box or Group.
- Unwrap: replaces a container with what's inside it.
- Move Up and Move Down: moves the view one place within its container.
To put several views in one container, Shift-click them, then choose Group into… in the Inspector. It's offered when they sit side by side in the same container.
| Shortcut | What it does |
|---|---|
| ⌘G | Wrap in Column (several selected views: group them into a Column) |
| ⌥⌘G | Wrap in Row (several selected views: group them into a Row) |
| ⇧⌘G | Unwrap |
| ⌥⌘[ | Move Up |
| ⌥⌘] | Move Down |