Skip to content

Instantly share code, notes, and snippets.

@jkarttunen
Last active June 22, 2022 17:39
Show Gist options
  • Save jkarttunen/15360637e8043351490603a5e653b0b1 to your computer and use it in GitHub Desktop.
Save jkarttunen/15360637e8043351490603a5e653b0b1 to your computer and use it in GitHub Desktop.
Figma autolayout as css
.autolayout {
display: flex;
flex-direction: row;
flex-shrink: 0;
justify-content: flex-start;
align-items: flex-start;
}
/* Horizontal */
.autolayout.top-left {
justify-content: flex-start;
align-items: flex-start;
}
.autolayout.top-center {
justify-content: center;
align-items: flex-start;
}
.autolayout.top-right {
justify-content: flex-end;
align-items: flex-start;
}
.autolayout.center-left {
justify-content: flex-start;
align-items: center;
}
.autolayout.center-center {
justify-content: center;
align-items: center;
}
.autolayout.center-right {
justify-content: flex-end;
align-items: center;
}
.autolayout.bottom-left {
justify-content: flex-start;
align-items: flex-end;
}
.autolayout.bottom-center {
justify-content: center;
align-items: flex-end;
}
.autolayout.bottom-right {
justify-content: flex-end;
align-items: flex-end;
}
.autolayout.space-between {
justify-content: space-between;
}
.autolayout > .fill-container {
align-self: stretch;
}
/* Vertical */
.autolayout.vertical {
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}
.autolayout.vertical.top-stretch {
justify-content: flex-start;
align-items: stretch;
}
.autolayout.vertical.top-left {
justify-content: flex-start;
align-items: flex-start;
}
.autolayout.vertical.top-center {
justify-content: flex-start;
align-items: center;
}
.autolayout.vertical.top-right {
justify-content: flex-start;
align-items: flex-end;
}
.autolayout.vertical.center-left {
justify-content: center;
align-items: flex-start;
}
.autolayout.vertical.center-center {
justify-content: center;
align-items: center;
}
.autolayout.vertical.center-right {
justify-content: center;
align-items: flex-end;
}
.autolayout.vertical.bottom-left {
justify-content: flex-end;
align-items: flex-start;
}
.autolayout.vertical.bottom-center {
justify-content: flex-end;
align-items: center;
}
.autolayout.vertical.bottom-right {
justify-content: flex-end;
align-items: flex-end;
}
.autolayout.vertical.space-between {
justify-content: space-between;
}
@jkarttunen
Copy link
Author

WIP, comments or bug reports appreciated.

.autolayout.vertical.top-stretch is an experiment for including constraints and resizing better

@jkarttunen
Copy link
Author

Needs to be updated to new version of autolayout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment