DesignOverviewDesign SystemMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingAgentsCortexMemoryActiveProvenanceActiveContextActiveServicesInsightsGet in touchSource on GitHub
Theming
Size and densityA control has no size. It takes its height from the region it is in.<helix-flexdata-density="lg"><helix-buttonemphasis="solid"tone="primary">See what is shipping</helix-button></helix-flex>Buttons, inputs, selects, and checkboxes have no size prop.What size is used forSize does three jobs:
Emphasis shows which control matters most. The emphasis axis sets it. A
filled primary button marks the important action much more clearly than eight
more pixels of height.
Fit depends on the region. A toolbar is tight and a hero is spacious. The region sets the fit for every control in it.
Optical role applies only to things that are not controls. An avatar at 24 in
a list and at 96 on a profile are two different pictures. That is why
Avatar, Loader, and Orb keep a size.
The stepsDensityControl heightTight rowControl textsm32px26px12pxmd40px32px13pxlg48px38px14pxA tight row is --helix-size-control-tight, the height of a row in a Menu, a
Select, or a Combobox. A Table and a List row take the control height. The
control text in the table is for a mouse or a trackpad. On a touch screen it is
a step larger, as On a touch screen describes.Can two controls differ in height?Ask whether two controls placed together can ever differ in height:
Save and Cancel
An icon button beside a text button
An input and its submit button
The two halves of a split button
In every case the answer is no.A size on each control describes the region, one element at a time, and
that is how a row ends up with one control at the wrong height. When you set the
density once on the region, you cannot write a row of mismatched heights.Three regions take a size by the same test:
Toolbar sets the density of every control in it. Unset, its controls are
sm, since a toolbar is dense.
Button Group sets the density of every button in it. Unset, its buttons
take the density of the region around the group.
Dialog sets its own width. Two dialogs never sit together. One is on screen
at a time, in the top layer, so the dialog is itself the region.
This also helps when you or a model generate code. There is no size to get wrong
on each element, and you make one choice for each region.Set the density of a regionPut data-density on any container, with a value of sm, md, or lg. md
is the default, so you never write it.<helix-toolbarlabel="Build"><!-- Nothing here needs a size. The toolbar is already dense. --><helix-button>Run</helix-button><helix-selectaria-label="Target"><!-- … --></helix-select></helix-toolbar>Containers that are dense by design set their own density. The app header, the
toolbar, and the announcement all do, so a control inside one of them is already
the right height.Density works through these custom properties:
--helix-size-control
--helix-size-checkbox
--helix-size-icon
--helix-size-switch
--helix-size-tag
It also sets the control text, the field text, and their insets.Because of this, density adds no API to any component, and it passes through
every shadow boundary.The -sm, -md, and -lg tokens are the scale, and they never change. The
unsuffixed tokens hold the current step, and data-density changes them.A step either side-tight and -loose are a step either side of the current one: 0.8 and 1.2
times the unsuffixed token, rounded to a whole pixel. An icon rounds to an even
pixel, so its steps land between 0.75 and 0.83 times the icon and between 1.17
and 1.25 times it. They move with the region's density. Three sizes have the
pair:
--helix-size-control-tight and --helix-size-control-loose
--helix-size-icon-tight and --helix-size-icon-loose
--helix-size-checkbox-tight and --helix-size-checkbox-loose
DensityControlTightLooseIconTightLoosesm32px26px38px16px12px20pxmd40px32px48px20px16px24pxlg48px38px58px24px20px28pxUse a -tight or -loose step for something that is meant to differ from its
neighbors, such as a row in a floating panel or a caret inside a trigger. Use
-sm, -md, or -lg for a size that does not follow density.Three sizes do not follow a region's density. Like every size, they still scale
with --helix-seed-density:
--helix-size-button is 200px, a standard width for a button. Set it as a
button's --button-inline-size.
--helix-size-badge is 16px, the size of a Badge's mark. A badge is pinned
to something else, such as an avatar, so it does not take a control's size.
--helix-size-control-xs is 26px, the step under --helix-size-control-sm,
for a strip denser than a toolbar. Find and the Editor's link bar set
it as their own control height. It is not a density step.
On a touch screenWhere the primary pointer is coarse, such as on a phone, these sizes change:
--helix-size-target is 44px. Under a mouse it is 24px. A control's press
reaches that size through a transparent box around it, so nothing drawn moves.
Control text is a step larger, up to 14px: 13px at sm, and 14px at md and
lg. A Button at md goes from 13px to 14px.
A field's text is at least 16px, so a field at md goes from 14px to 16px.
iOS Safari zooms the page into a field whose text is smaller. See
Typography.
A row in a Menu, a Select, or a Combobox is at least --helix-size-target
tall, 44px at every density. Rows sit against each other, so the row itself
grows to the target.
A List row and a Tree row are 48px apart at every density, the pitch a List
has at lg. Tree rows keep the List's pitch.
An Accordion's summary row is at least 44px tall, so it is 44px at sm and
md and keeps its 48px at lg.
A Table row does not grow to the target. It keeps its density's height, and
only its text takes the larger touch size.
A link in a Navigation bar is 44px tall.
A control keeps the height of its density step.Exceptionsdata-link-size still exists. A text link has no control height. Its size comes
from typography, and it follows the text around it.A component can still set its own step on the scale. --helix-size-switch is
one step above --helix-size-checkbox at every density, because a switch is a
track with a thumb inside it and a checkbox is a box with a mark in it. The
component sets this once, and it applies to every instance. You do not set a
height on each instance.Narrowest supported widthHelix supports a column down to 280px. Every family's examples fit at that width
with no sideways scroll. Below it, a control may overflow or a figure may wrap.A Stat figure that does not fit its column steps down the type scale twice,
from 3xl to 2xl to xl. If it still does not fit, it breaks after a group
separator, such as the comma in "1,284,567". Give each Stat a column of about
6rem or wider, so its digits stay on one line.