This document aims to provide guidance for consumers on how best to compose Balance components, affording flexibility within the constraints of the system.
In React, composition is a natural pattern of the component model. It's how we build components from other components, of varying complexity and specificity through props. Depending on how adaptable these components are, they can be used in building many other components.
Designs like this are rarely built top-to-bottom in a single pass. Instead, they typically start very simple, with further details and refinements added in layers.
To give you a sense of what this looks like, the following tutorial will guide you through the design process that you might go through when using Playroom.
At any stage you can click the “Open in Playroom” button under the examples to view the design.
You’ll notice that there is no space between components by default. This is actually a good thing: we now get to decide exactly how spaced out we want the content to be. To achieve this, we’ll use a Stack component which applies space evenly between its child elements.
Grouping the content into sections can help provide structure to the information, and in turn, make it easier to digest. Let’s divide the information into four descrete sections — the header, metadata, body and footer. For this, we’ll start nesting new Stack components within our existing Stack.
Not all the information presented has the same priority. To improve readability, we can adjust the tone and/or the size of the information. In this case, pushing some details back to “muted” and/or adjusting their size can help focus the user’s attention.
Icons can be used to serve as visual cues to complement data and introduce some more visual interest. Let’s add icons to our list of metadata.
Let’s add a visual cue to indicate that this pay summary is in progress. To do this, we’ll add a Badge component above the content.
Sometimes adding new features can necessitate changing the layout. First, we’ll use a Flex component to break our header into sections.
To make this easier to follow, we'll use placeholders for the first part.
With the header layout adjusted, let’s reinstate our pay summary content.
Now that we have all our elements in place we can polish until we are happy. Adjusting white space between elements, or even responsively, to achieve the desired goal.
In this case, we might loosen up the metadata section by increasing the gap to “small”.
Now that you are familiar with the code we have just written, this is a good chance to head over to Playroom and continue refining this design.
You may want to consider: