Viz Artist User Guide

Version 5.0 | Published December 20, 2022 ©

Flexbox in Detail

This chapter explains all settings of the Flexbox plugin in detail.


The flexbox plugin takes advantage of the Box Transformation and allows to build graphics for adaptive storytelling. It is based on the flex implementation of CSS and web development. Therefore you can find a lot of documentation, tips and tricks online.

Layout in Flexbox uses two axes, the main axis and the cross axis. The alignment of any child items along those two axes depends on the available height and width.

images/download/attachments/95389458/image2022-5-12_14-22-3.png

The Main Axis is defined by the direction property. If the direction is set to row, the Main Axis is horizontal. If set to column, the Main Axis is vertical.

Justification defines how items are aligned along the Main axis. Alignment defines how items are aligned along the Cross axis.

Flex Wrap

By default children are scaled down to fit into a box. By changing the wrapping mode, children are automatically aligned based on the setting. The following examples use boxes A-E are 300px in width and a minimum width of 150px, but they can grow and shrink.

No Wrap

If no wrapping is used, the boxes are scaled down until they reach their minimum width (140 pixels).

Parent 100%

images/download/attachments/95389458/image2022-5-11_13-19-50.png

Parent 50%

images/download/attachments/95389458/image2022-5-11_13-20-50.png

Parent 20%

images/download/attachments/95389458/image2022-5-11_13-21-25.png

Wrap and Wrap Reverse

If wrapping is turned on, the boxes are scaled down until they reach their minimum size and are then wrapped to fill the space.

Wrapping enabled
Parent 50%

images/download/attachments/95389458/image2022-5-11_13-26-59.png

Wrapping Reverse enabled
Parent 50%

images/download/attachments/95389458/image2022-5-11_13-28-50.png

Flex Direction

Layouts can be based on Rows or Columns for all child boxes. This means that all children are placed within a row or within a column. The Flex Direction defines the main axis and defines the direction of all children placed underneath the flexbox container.

Column

images/download/attachments/95389458/image2022-5-11_13-33-0.png

Column Reverse

images/download/attachments/95389458/image2022-5-11_13-33-24.png

Row

images/download/attachments/95389458/image2022-5-11_13-32-16.png

Row Reverse

images/download/attachments/95389458/image2022-5-11_13-33-56.png

Direction

The direction property defines the main axis. Your children can be aligned starting from the left or from the right side. By default it inherits the setting of the parent flex container.

In Column mode this is being flipped and the main axis is going top to down or reverse.

Left to Right

images/download/attachments/95389458/image2022-5-11_13-51-24.png

Right to Left

images/download/attachments/95389458/image2022-5-11_13-50-18.png

Flex Basis

The basis value defines the default size of a container along the main axis before any growing or shrink is performed. It can be either auto or a given value. This value is like setting the width if flex direction row is used or height or column layout is in use.

Growing and Shrinking

Defines if and how strong a container can grow or shrink to fit into a parent container. The minimum and maximum width/height values are taken into account. If growing is enabled for all child containers, the remaining space is distributed equally to all children.

The value is used as a proportional factor. For example if one container has a shrink value of 2, it shrinks twice as much as all other containers (see below).

Parent container on 100 %
No wrapping
Container C has growing = 0 and Shrinking = 0, size is set to 400 px

images/download/attachments/95389458/image2022-5-11_14-59-32.png

Parent container on 60 %
No wrapping
Container C has growing = 0 and Shrinking = 0, size is set to 400 px

images/download/attachments/95389458/image2022-5-11_15-0-45.png

Scaling of container C stays, whereas all other containers shrink to fit into
parent dimensions.

Parent container on 60 %
No wrapping
Container C has growing = 0 and Shrinking = 2.0, size is set to 400 px

images/download/attachments/95389458/image2022-5-11_15-6-11.png

Container C is scaled down twice as all other containers (shrink = 2.0)

Aspect Ratio

Defines how a flexbox is being scaled. If it is on auto, the width and height taken as it is. If a value is used, it defines the ratio between width and height. For example: An aspect of 2.0 means the width is twice the value of the height.

Aspect ratio = 1

images/download/attachments/95389458/image2022-5-11_15-24-6.png

Width and height are the same.

Aspect Ratio = 0.5

images/download/attachments/95389458/image2022-5-11_15-26-42.png

Aspect Radio = 2

images/download/attachments/95389458/image2022-5-11_15-28-15.png
The height is double the width.

Auto

images/download/attachments/95389458/image2022-5-11_15-29-0.png

Width, Height and Limits

The sizes for width, height, minimum width and height as well as the maximum width and height can be set to be either auto, in percentage values or in pixel sizes.

  • Auto: The size for the box is being calculated automatically based on grow and shrink values, the content as well as the aspect ratio.

  • Pixels: Defines the width/height in pixels.

    Note: This dimension can be influenced by other properties.

  • Percentage: Same as pixels, but based on percentage values.

images/download/attachments/95389458/image2022-5-11_15-45-17.png

The minimum and maximum values size set the upper and lower size constraints of a container. These properties have higher priority than all other properties and are always respected.

Margins, Padding and Borders

Each container can have some offsets by adding either a margin, padding or border.

  • Margin: Adds an offset to the outside of the element. It offsets itself and all children from the calculated position. It adds to the total size for the element. it can be set to auto, pixels or percentage values. Negative numbers are allowed too.

  • Padding: Affects the size of the container it is applied to. It does not add to the total size of an element if it has an explicit size set. It can be set in pixels or percentage, but can not be negative.

  • Border: Does more or less the same as padding. It can only be set in pixels. The main purpose of having an additional border is to keep compatibility with the original flexbox implementation.

images/download/attachments/95389458/image2022-5-11_16-5-12.png

Positioning

Tracking

To bind one container to another, Flexbox supports tracking. You can specify a reference container and your container follows this position. All other properties are disabled, but offsets can still be applied.

images/download/attachments/95389458/image2022-7-15_10-11-45.png

Adding an offset to a container shifts the whole container and its content based on the calculated position by the given values. This offset can be either relative or absolute.

Relative offset

images/download/attachments/95389458/image2022-5-11_16-33-53.png

Takes the calculated position and adds the given offset.
Offsets can be set as auto (calculated automatically when using certain content alignments) or as value in pixels or percentage.

Absolute offset

images/download/attachments/95389458/image2022-5-11_16-38-39.png
Takes out the container from the calculation and sets the position to the given values.
It can be set as pixels or percentage (auto is available, but is ignored).
When using absolute positioning, all other properties that influence the position are no longer effective.

Justify Content

This setting describes how child containers align along the Main Axis. This can be used to automatically center items for example. The samples below show five child containers with a width of 10% and a height of 100%. The following settings are available:

Flex Start

images/download/attachments/95389458/image2022-5-12_10-31-20.png
Aligns child containers to the start of the main axis.

Center

images/download/attachments/95389458/image2022-5-12_10-31-28.png
Aligns child containers to the center of the main axis.

Flex End

images/download/attachments/95389458/image2022-5-12_10-31-36.png

Aligns child containers to the end of the main axis.

Space Between

images/download/attachments/95389458/image2022-5-12_10-31-50.png

Distributes the remaining space between all child containers.

Space Around

images/download/attachments/95389458/image2022-5-12_10-31-59.png

Distributes the remaining space between all child containers, including start and end as one element

Space Evenly

images/download/attachments/95389458/image2022-5-12_10-32-8.png

Distributes the remaining space between all child containers,
space between all elements including start and end are exactly the same.

Align Items

This setting describes how child containers align along the cross axis. It sets the default alignment for all child containers, however it can be overwritten by a children using the Align-Self property. The samples below show five child container with a width of 10% and a height of 25%, 30%, 35%, 40% and 45%, Justify content is set to space around. The following settings are available:

Auto

Uses the align item of the parent container.

Flex Start

images/download/attachments/95389458/image2022-5-12_11-25-36.png
Aligns child containers to the start of the cross axis.

Center

images/download/attachments/95389458/image2022-5-12_11-25-45.png

Aligns child containers to the center of the cross axis.

Flex End

images/download/attachments/95389458/image2022-5-12_11-25-54.png

Aligns child containers to the end of the cross axis.

Stretch

images/download/attachments/95389458/image2022-5-12_11-26-1.png

The items are streched to fill the cross axis. Therefore the cross axis setting (in our case the height) must be set to be auto to allow the parent to overwrite the value

Baseline

images/download/attachments/95389458/image2022-5-12_11-28-18.png

Aligns all containers in a way such that their baselines align. The highest one starts on the top.

Space between


Space around


Align Self

Align self is used to overwrite the Align Items property given by the parent container to is own. In the example below, the parent container is set to be Align Items: Start, but container E has an Align-Self set to be Flex-End. This takes it out of the computed position of the top (parent is set to Flex Start) and overwrite it with its own property Flex-End:

images/download/attachments/95389458/image2022-5-12_11-36-27.png

Align Content

Defines how containers are aligned, if the wrap mode forces elements to be distributed in more than on row or column. It has no effect if no wrapping happens.

The following settings are available:

Auto

Uses the align item of the parent container.

Flex Start

images/download/attachments/95389458/image2022-5-12_14-5-46.png
Aligns wrapping child containers to the start of the cross axis.

Center

images/download/attachments/95389458/image2022-5-12_14-5-54.png

Aligns wrapping child containers to the center of the cross axis.

Flex End

images/download/attachments/95389458/image2022-5-12_14-6-5.png

Aligns child containers to the end of the cross axis.

Stretch

images/download/attachments/95389458/image2022-5-12_14-8-34.png

Stretches the space between the elements to reach the parent containers cross axis.

Baseline

images/download/attachments/95389458/image2022-5-12_14-6-19.png

Aligns all containers in a way such that their baselines align.

Space between

images/download/attachments/95389458/image2022-5-12_14-5-4.png

Distributes the remaining space between all lines to match the parent containers cross axis.

Space around


images/download/attachments/95389458/image2022-5-12_14-4-46.png

Like space between, but also distributes space including top and bottom.