Design Principles
A mantle part gets the behavior and the styles right. These rules decide how you arrange the parts. They come from ngrok's designers. Each rule has a reason, a do and a don't, and the part that does the work when one exists. Some rules also have a golden example.
Start from a pattern before you compose by hand. Search the docs, or call the MCP find tool, with what you build, such as "form sections" or "form actions". A form or settings page uses Strata, the buttons that end a form follow Cancel and Submit Actions, and an app shell uses AppLayout.
Balance
Space spreads evenly across a layout. A layout looks off when one element takes most of the space and its neighbors shrink to their minimum.
Share the spare width across columns
A table looks even when no one column takes the row.
- Do let the columns whose values change in length, such as a name, a URL, and an upstream, share the spare width.
- Do fit a column whose values are short and the same shape, such as a status, a date, or a duration, to its content.
- Don't give one column
w-fullor a large fixed width. That column takes the row, and the other columns shrink and wrap. - Don't leave only one column unfit when its values are short. All the spare width goes to it, and a gap opens after its values.
- Part:
DataTable. Setmeta: { width: "fit" }on a column, and passcolumnto itsDataTable.Headerand to eachDataTable.Cell.
Golden example: the name, the URL, and the upstream share the spare width. The status and the date fit their content.
Don't: the name column has w-full, so it takes the row. The URL, upstream, status, and date wrap in what is left.
Give siblings of equal weight equal space
Items of equal importance get equal size.
- Do put siblings of equal weight in equal tracks, such as three summary cards in one grid.
- Don't mix
flex-1and a fixed width on siblings of equal weight. One sibling grows. The other looks like an afterthought. - Part:
Cardin a CSS grid.
Inset a nested item by the same distance on every side
An item that sits closer to one edge than to the others looks like it slipped.
- Do give a badge, a button, or a control inside a container the same space on each side.
- Don't pad only the top and bottom, or let an item hang over the container's edge.
- Part:
Card.Card.Bodypads all four sides the same. AWellhas no padding of its own, so give it one value for every side, such asp-4.
Proximity
Items that sit close together read as one group. Use space to show the structure.
Use less space inside a group than between groups
The reader sees the groups before they read a word.
- Do use the spacing that the parts build in. It grows at each level: a label and its control in
Field.Item(gap-1.5), fields inField.Group(gap-4), and sections inStrata(py-8and a divider). When you compose by hand, grow the space at each level, such asgap-2inside a group andgap-8between groups. - Don't put the same space between all children, such as
space-y-4on a whole form. Then each item is as far from the next group as from its own, and the groups disappear. - Part:
FieldandStrata.
Put an action next to what it acts on
An action far from its target makes the reader search for what it changes.
- Do put row actions in the row, a card's actions in its footer, and a form's buttons where Cancel and Submit Actions puts them.
- Don't put an Edit button at the top of the page for one card further down, or an action for one row in a toolbar above the table.
- Part:
DataTable.ActionCell,Card.Footer, and Cancel and Submit Actions.
Put a title closer to the content it names
A title halfway between two blocks belongs to neither.
- Do use a part that pairs a title with its content, such as
Strata.Headerwith itsStrata.Body. - Don't put a hand-made heading with the same margin above and below it.
- Part:
Strata.
Common region
Items inside one boundary read as one group, even when they are far apart.
Use one container for each group, picked by role
The container tells the reader what kind of group it is.
- Do put content that must read as one unit in one container:
- a
Cardfor a primary group, with an optional title and actions; - a
Wellfor secondary content inset in the page, such as a note, a code sample, or a read-only summary; - a
Strata.Sectionfor a titled section of a settings page or a long form; - a
Field.Setwith aField.Legendfor controls that answer one question.
- a
- Don't draw a box with a hand-made
border rounded-md p-4where one of these parts fits. - Part:
Card,Well,Strata.Section, andField.Set.
Don't nest a region in a region of the same kind
Two borders around one group add noise and no meaning.
- Do split one card into parts with sibling
Card.Bodyparts. Each body after the first has a divider above it. Inside one body, split with space or aSeparator, and use aHorizontalSeparatorGroupfor a divider with a label. - Don't put a
Cardin aCard. - Part:
Card.BodyandSeparator.
Don't put each item in its own box
When each field or each fact has its own container, nothing groups, and the page reads as noise.
- Do put the related items in one container, and separate them with space or rows.
- Don't wrap each fact or each field in its own
Card. - Part:
DescriptionListinside oneCard, as in the golden example of Use one container for each group.
Hierarchy
The most important thing on a screen gets the most visual weight, and nothing else competes with it.
Give each view one primary action
Two filled buttons ask the reader to choose before they know what the page is for.
- Do make the main action a filled
Buttonwithintent="neutral", and make every other action outlined or ghost. - Don't put two filled buttons side by side, or use
intent="accent"for an ordinary action. - Part:
Button.
Keep red for one moment of danger
Red draws the eye, so it loses its meaning when it shows up everywhere.
- Do use red where the user commits to a destructive action: a menu item that deletes, or the action of an
AlertDialogwithintent="danger". - Don't make a delete icon red in a row of icon buttons. A group of icon buttons stays uniform, and the confirmation step carries the danger.
- Part:
AlertDialog.IconButtontakes onlyintent="neutral".
Cut what doesn't earn its place
Each extra icon, badge, shadow, or line of text makes the rest harder to scan.
- Do remove a decorative icon in a title, a badge that repeats a heading, and subtext that repeats the title.
- Don't stack shadows, glows, and colors for emphasis. When every card has an effect, none of them stands out.
- Part: none. Start from the plain part, and add only what the reader needs.
Consistency
The same job looks and works the same on every page.
Use each part as it ships
A part that looks a little different from the rest of the product reads as a bug.
- Do render the mantle part, such as
Badge,Sheet, orDataTablesub-rows, with its own props and parts. - Don't rebuild a part by hand, or restyle it with
classNameto change its shape, color, or font. When the part can't do what the design needs, report the gap. - Part: every part. Call
getbefore you write its props.
Feedback
Tell the user what happened, and where, without moving the page under them.
Show an error next to what failed
A toast disappears, and it doesn't say which field to fix.
- Do show a field's error under the field with
Field.Errors. Show an error for the whole form in anAlertat the top of the form. - Don't report a failed save or a blocked action in a
Toast. - Part:
FieldandAlert.
Disable a control and say why
A control that is gone makes the user wonder where it went.
- Do show the control as disabled, and put the reason in visible text beside it, such as a
Field.Description. - Don't hide the control, or put the only explanation in a tooltip.
- Part:
Field.
Keep items where the user put them
When a list reorders after an action, the user loses their place.
- Do keep the order the user saw until they leave and come back, and keep a check, a toggle, or a tab in the same position and size in every state.
- Don't move an item to the end of the list as soon as the user selects it, or let tabs push the content sideways.
- Part: none. Sort the data you pass to the part before it renders.
This page grows as ngrok's designers write down more of what they check. It has no typography rules yet.