FlexContainer

ic.FlexContainer is a single-axis layout container built on CSS flexbox. It arranges its children in a row or column and controls their spacing, alignment, and wrapping behavior. Use it whenever you need to lay out components horizontally or vertically without reaching for a full grid.

Direction

Direction sets the main axis. row lays children out left-to-right, column stacks them top-to-bottom. The -reverse variants flip the order without changing the DOM structure, which is useful when you want a visual reorder without changing the logical tab sequence.

Controls
1
2
3
4

Alignment

JustifyContent distributes children along the main axis. AlignItems positions them on the cross axis. The combination of these two properties gives you full control over where children land within the container. The space-between, space-around, and space-evenly options for justify are particularly useful for distributing items across a toolbar or navigation bar.

Controls
A
B
C
D

Wrap

Wrap controls whether children flow onto new lines when they overflow the main axis. The default nowrap keeps everything on one line (children may shrink or overflow). Set it to wrap to let items break to the next row or column. wrap-reverse wraps in the opposite cross-axis direction.

Controls
1
2
3
4
5
6
7
8

Gap and padding

Gap sets the spacing between children. Padding adds internal space around the entire content area. Both accept a pixel number or a CSS string like "8px 16px" for asymmetric values.

Controls
1
2
3
4

Custom styling

FlexContainer has minimal CSS of its own, just display: flex on .ic-flex. Styling targets the container itself rather than internal parts. This example turns it into a centered card with a gradient background and soft shadow.

1
2
3
4
f = ic.FlexContainer();
f.Direction = "row";
f.JustifyContent = "center";
f.AlignItems = "center";
f.Gap = 16;
f.Padding = 24;

% Gradient background with rounded corners
f.css.style(".ic-flex", ...
    "background", "linear-gradient(135deg, #e0e7ff, #fce7f3, #fef3c7)", ...
    "border_radius", "12px", ...
    "box_shadow", "0 2px 8px rgba(0,0,0,0.08)");
Compatibility note. Figures run in different browsers depending on Matlabs version and operating system. CSS features like linear-gradient, backdrop-filter, or newer color functions may not work everywhere. For reference, MATLAB R2024b uses Chromium 104. Always test your custom styles in the MATLAB version you are targeting, and use canIuse to check compatibility of specific CSS features if you know the browser version MATLAB is using. Use the Developer Tools component to inspect the DOM structure of each component and find the right selectors for styling.