Thru inspection of all configuration permutations of Auto Layout (all, that I care about at least) I believe I have the basis to form a complete algorithm. I also hope others find this helpful too, as much as I do. (it is a lot to get thru, I know. But, only because this is exactly how complex Auto Layout actually is! )
@Figma_Support , can you, or you get someone in development, to have a look at this?
- Correct me if I got anything wrong.
- And/or supplement if I missed any of the permutations.
- Add any CSS name:value mappings I may have missed that are involved with Flexbox definitions from Auto Layout.
Much Thanx!
Here we go…
When FIGMA Auto Layout layoutMode === “HORIZONTAL” ::
FIGMA auto layout grid selection:
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: MIN | primaryAxisAlignItems: CENTER | primaryAxisAlignItems: MAX |
| counterAxisAlignItems: MIN | counterAxisAlignItems: MIN | counterAxisAlignItems: MIN |
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: MIN | primaryAxisAlignItems: CENTER | primaryAxisAlignItems: MAX |
| counterAxisAlignItems: CENTER | counterAxisAlignItems: CENTER | counterAxisAlignItems: CENTER |
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: MIN | primaryAxisAlignItems: CENTER | primaryAxisAlignItems: MAX |
| counterAxisAlignItems: MAX | counterAxisAlignItems: MAX | counterAxisAlignItems: MAX |
|_______________________________|_______________________________|_______________________________|
Above Maps to CSS Below:
In All Cases when Auto Layout layoutMode === "HORIZONTAL" ::
display: flex;
flex-direction: row;
|_______________________________|___________________________|_____________________________|
| align-items: flex-start; | align-items: flex-start; | align-items: flex-start; |
| justify-content: flex-start; | justify-content: center; | justify-content: flex-end; |
|_______________________________|___________________________|_____________________________|
| align-items: center; | align-items: center; | align-items: center; |
| justify-content: flex-start; | justify-content: center; | justify-content: flex-end; |
|_______________________________|___________________________|_____________________________|
| align-items: flex-end; | align-items: flex-end; | align-items: flex-end; |
| justify-content: flex-start; | justify-content: center; | justify-content: flex-end; |
|_______________________________|___________________________|_____________________________|
When FIGMA Auto Layout layoutMode === “VERTICAL” ::
FIGMA auto layout grid selection:
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: MIN | primaryAxisAlignItems: MIN | primaryAxisAlignItems: MIN |
| counterAxisAlignItems: MIN | counterAxisAlignItems: CENTER | counterAxisAlignItems: MAX |
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: CENTER | primaryAxisAlignItems: CENTER | primaryAxisAlignItems: CENTER |
| counterAxisAlignItems: MIN | counterAxisAlignItems: CENTER | counterAxisAlignItems: MAX |
|_______________________________|_______________________________|_______________________________|
| primaryAxisAlignItems: MAX | primaryAxisAlignItems: MAX | primaryAxisAlignItems: MAX |
| counterAxisAlignItems: MIN | counterAxisAlignItems: CENTER | counterAxisAlignItems: MAX |
|_______________________________|_______________________________|_______________________________|
Above Maps to CSS Below:
In All Cases when Auto Layout layoutMode === "VERTICAL" ::
display: flex;
flex-direction: column;
|_______________________________|______________________________|_______________________________|
| align-items: flex-start; | align-items: center; | align-items: flex-end; |
| justify-content: flex-start; | justify-content: flex-start; | justify-content: flex-start; |
|_______________________________|______________________________|_______________________________|
| align-items: flex-start; | align-items: center; | align-items: flex-end; |
| justify-content: center; | justify-content: center; | justify-content: center; |
|_______________________________|______________________________|_______________________________|
| align-items: flex-start; | align-items: center; | align-items: flex-end; |
| justify-content: flex-end; | justify-content: flex-end; | justify-content: flex-end; |
|_______________________________|______________________________|_______________________________|
OVERRIDES to the above when using Advanced Layout:
1) IF: Spacing Mode === 'Space Between'
So that JSON primaryAxisAlignItems === SPACE_BETWEEN
THEN:
justify-content: space-between
ELSE, DEFAULT:
Figma Spacing Mode === 'PACKED' and
CSS justify-content value is defined by the tables above
FIGMA auto layout grid selection when layoutMode === “HORIZONTAL”::
|______________________________________|
| primaryAxisAlignItems: SPACE_BETWEEN |
| counterAxisAlignItems: MIN |
|______________________________________|
| primaryAxisAlignItems: SPACE_BETWEEN |
| counterAxisAlignItems: CENTER |
|______________________________________|
| primaryAxisAlignItems: SPACE_BETWEEN |
| counterAxisAlignItems: MAX |
|______________________________________|
Above maps to the following CSS ::
|__________________________________|
| align-items: flex-start; |
| justify-content: space-between; |
|__________________________________|
| align-items: center; |
| justify-content: space-between; |
|__________________________________|
| align-items: flex-end; |
| justify-content: space-between; |
|__________________________________|
FIGMA auto layout grid selection when layoutMode === “VERTICAL” ::
|______________________________________|______________________________________|______________________________________|
| primaryAxisAlignItems: SPACE_BETWEEN | primaryAxisAlignItems: SPACE_BETWEEN | primaryAxisAlignItems: SPACE_BETWEEN |
| counterAxisAlignItems: MIN | counterAxisAlignItems: CENTER | counterAxisAlignItems: MAX |
|______________________________________|______________________________________|______________________________________|
Above maps to the following CSS ::
|________________________________|____________________________|______________________________|
| align-items: baseline; | align-items: baseline; | align-items: baseline; |
| justify-content: flex-start; | justify-content: center; | justify-content: flex-end; |
|________________________________|____________________________|______________________________|
2) IF: Auto Layout layoutMode === "HORIZONTAL" AND Text baseline alignment is CHECKED
THEN:
FIGMA auto layout grid selection ::
|_________________________________|_________________________________|_________________________________|
| primaryAxisAlignItems: MIN | primaryAxisAlignItems: CENTER | primaryAxisAlignItems: MAX |
| counterAxisAlignItems: BASELINE | counterAxisAlignItems: BASELINE | counterAxisAlignItems: BASELINE |
|_________________________________|_________________________________|_________________________________|
Above maps to the following CSS ::
|__________________________________|__________________________________|__________________________________|
| align-items: flex-start; | align-items: center; | align-items: flex-end; |
| justify-content: space-between; | justify-content: space-between; | justify-content: space-between; |
|__________________________________|__________________________________|__________________________________|
3) IF: Advanced Auto Layout Mode Both
Spacing Mode === Space Between and
Text Baseline Alignment is CHECKED
THEN:
FIGMA auto layout grid selection when layoutMode === “HORIZONTAL” (mandatory for Baseline Alignment) ::
|______________________________________|
| primaryAxisAlignItems: SPACE_BETWEEN |
| counterAxisAlignItems: BASELINE |
|______________________________________|
Above maps to the following CSS ::
|__________________________________|
| align-items: baseline; |
| justify-content: space-between; |
|__________________________________|
(no other combinations are possible)