Density
Density lets people see more information in data-heavy views by making components more compact.
Density lets people see more information in data-heavy views by making
components more compact. A component's density is a number from 0 (the
default) to -3 (the densest). Each step down makes the component smaller.
Values are rounded and clamped to that range.
Use the density attribute.
<label>
Default
<md-gb-checkbox></md-gb-checkbox>
</label>
<label>
Dense
<md-gb-checkbox density="-3"></md-gb-checkbox>
</label>Which components support it
Link to “Which components support it”density is available on these components:
md-gb-button-groupmd-gb-checkboxmd-gb-chipmd-gb-icon-buttonmd-gb-listmd-gb-menumd-gb-radiomd-gb-segmented-buttonmd-gb-switchmd-gb-tabsmd-gb-text-fieldmd-gb-time-picker
Each step shrinks the component's visual size, not its touch target. A checkbox, for example, loses 4px from its layout box (48px at density 0) and its state layer (40px at density 0) per step. Its touch target stays 48px.
Touch targets stay 48dp
Link to “Touch targets stay 48dp”Every component keeps a touch target of at least 48 by 48 CSS pixels, even at the densest setting. The visual element can be smaller, but the area that responds to a tap cannot. Do not override this with your own sizing.
Rules of thumb
Link to “Rules of thumb”- Density is a choice, not a default. Leave components at
0unless the view is data-heavy, and let people opt into a denser layout where you offer a control for it. - Do not change density automatically. It should not switch when the window resizes or the device rotates, unless the person changed it.
- Consider the device. A person may want a dense desktop layout but not a dense phone layout.
- Layout density comes first. Spacing changes can add information without shrinking components. Use component density when you also need the controls themselves to be smaller.
- Keep the controls accessible. If you offer a density setting, the setting itself must be easy to find and use.