Most components in Balance accept the
as prop, which allows you to
change the root element that the component renders.
<Box as="span" /> would render the Box component as a
instead of its default (in this case,
Important: Changing the root element can affect the styles and accessibility of a component. Consider how the component will be used when specifying the
Balance components do not provide surrounding white space. Instead, spacing between elements is owned entirely by layout primitives. This approach ensures that the system is as composable as possible while keeping white space predictable.
The layout primitives below can be nested within each other to create a wide variety of layouts. Getting a firm grasp of these layout primitives is an essential part of working effectively with Balance.
Balance provides a standard spacing scale that is used by the layout primitives.
Box is the most low-level layout primitive provided by Balance. Its job is to render an individual element on the screen.
In terms of page layout, Box most notably provides a set of padding options which can be used to create container elements with internal spacing.
These options accept a value from the spacing scale. For example, if you wanted to create a container element with small spacing on all sides:
These also support the ‘responsive props’ format which allows you to specify a set of values for different screen sizes.
For example, if you wanted small spacing on mobile but medium spacing from tablet upwards:
The most common white space on screen is between elements stacked vertically. For this use case, Balance provides a Stack component that accepts a ‘gap’ prop.
To visually break up content, you can insert dividers between all stack elements by setting the dividers prop on Stack:
Multiple Stack components can be nested to create more complex white space rules. For example, if you wanted to group blocks of text:
Stack also supports alignment. For example, if you wanted to centre align all content within a Stack:
If you’d like to render a set of components in a row with equal spacing around them, wrapping onto multiple lines when necessary, Balance provides a Inline component:
If you need to lay out content horizontally, Balance provides the Columns component:
All columns are of equal width by default, but you can use the template prop to define proportional widths.
For example, if you wanted to render a main content area and a sidebar:
The usage of colour in the system is designed to have a strong correlation with the tone of voice being used. The system makes available a spectrum of tones which are leveraged across the entire component suite.
Super important. You need to see this. Used for:
- High risk interaction
- High urgency interaction
- Error message
- Overdue/rejected status
You should be aware something is happening or mid-way through a process. There could be a risk or an item that needs to be acted on. Used for:
- Low risk interaction
- Low urgency interaction
- Warning message
- Attention/caution status
Celebrate the successful outcome of an event or action. Used for:
- Successful interaction
- Completed interaction
- Positive message
- New/created/resolved status
Guidance & advice. Functional, calm and non urgent. Used for:
- Helpful interaction
- Informative message
- Updated/in-progress status