Skip to content

feat(css): add new css utility classes for display and flex utils #30567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/components/back-button/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h3>Custom</h3>

<ion-toolbar color="dark">
<ion-buttons slot="start">
<ion-back-button class="ion-hide"></ion-back-button>
<ion-back-button class="ion-display-none"></ion-back-button>
</ion-buttons>
<ion-title>Hidden</ion-title>
</ion-toolbar>
Expand Down
1 change: 1 addition & 0 deletions core/src/components/progress-bar/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const renderProgress = (value: number, buffer: number) => {
* When finalBuffer === 1, we use display: none
* instead of removing the element to avoid flickering.
*/
// TODO(FW-6697): change `ion-hide` class to `ion-display-none` or another class
<div
class={{ 'buffer-circles-container': true, 'ion-hide': finalBuffer === 1 }}
style={{ transform: `translateX(${finalBuffer * 100}%)` }}
Expand Down
35 changes: 33 additions & 2 deletions core/src/css/display.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
@import "../themes/ionic.mixins";

// Display
// --------------------------------------------------
// Modifies display of a particular element based on the given classes
// ------------------------------------------------------------------
// Provides utility classes to control the CSS display property
// of elements. Includes responsive variants for toggling between
// block, inline, flex, grid, and other display values at different
// breakpoints.

// TODO(FW-6697): remove ion-hide-* classes in favor of the new
// ion-display-* classes
.ion-hide {
display: none !important;
}
Expand All @@ -29,3 +34,29 @@
}
}
}

$display-values: (
none,
inline,
inline-block,
block,
flex,
inline-flex,
grid,
inline-grid,
table,
table-cell,
table-row
);

@each $display in $display-values {
@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);

@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
.ion-display#{$infix}-#{$display} {
display: #{$display} !important;
}
}
}
}
288 changes: 200 additions & 88 deletions core/src/css/flex-utils.scss
Original file line number Diff line number Diff line change
@@ -1,99 +1,211 @@
// Flex Utilities
// --------------------------------------------------
// Creates flex classes to align flex containers
// and items

// Align Self
// --------------------------------------------------

.ion-align-self-start {
align-self: flex-start !important;
}

.ion-align-self-end {
align-self: flex-end !important;
}

.ion-align-self-center {
align-self: center !important;
}
@import "../themes/ionic.globals";
@import "../themes/ionic.mixins";

.ion-align-self-stretch {
align-self: stretch !important;
}

.ion-align-self-baseline {
align-self: baseline !important;
}

.ion-align-self-auto {
align-self: auto !important;
}


// Flex Wrap
// --------------------------------------------------

.ion-wrap {
flex-wrap: wrap !important;
}

.ion-nowrap {
flex-wrap: nowrap !important;
}

.ion-wrap-reverse {
flex-wrap: wrap-reverse !important;
}


// Justify Content
// --------------------------------------------------

.ion-justify-content-start {
justify-content: flex-start !important;
}

.ion-justify-content-center {
justify-content: center !important;
}

.ion-justify-content-end {
justify-content: flex-end !important;
}

.ion-justify-content-around {
justify-content: space-around !important;
}

.ion-justify-content-between {
justify-content: space-between !important;
}

.ion-justify-content-evenly {
justify-content: space-evenly !important;
// Flex Utilities
// ------------------------------------------------------------------
// Provides utility classes to control flexbox layout, alignment,
// and sizing of elements. Includes responsive variants for managing
// flex direction, alignment, justification, wrapping, growth,
// shrinking, and ordering at different breakpoints.

// Align Content
// ------------------------------------------------------------------

$align-content-values: (
start: flex-start,
end: flex-end,
center: center,
between: space-between,
around: space-around,
stretch: stretch
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $key, $value in $align-content-values {
.ion-align-content#{$infix}-#{$key} {
align-content: #{$value} !important;
}
}
}
}


// Align Items
// --------------------------------------------------

.ion-align-items-start {
align-items: flex-start !important;
// ------------------------------------------------------------------

$align-items-values: (
start,
end,
center,
stretch,
baseline
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $value in $align-items-values {
.ion-align-items#{$infix}-#{$value} {
align-items: #{$value} !important;
}
}
}
}

.ion-align-items-center {
align-items: center !important;
}

.ion-align-items-end {
align-items: flex-end !important;
// Align Self
// ------------------------------------------------------------------

$align-self-values: (
start,
end,
center,
stretch,
baseline,
auto
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $value in $align-self-values {
.ion-align-self#{$infix}-#{$value} {
align-self: #{$value} !important;
}
}
}
}

.ion-align-items-stretch {
align-items: stretch !important;
// Justify Content
// ------------------------------------------------------------------

$justify-content-values: (
start: flex-start,
end: flex-end,
center: center,
between: space-between,
around: space-around,
evenly: space-evenly
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $key, $value in $justify-content-values {
.ion-justify-content#{$infix}-#{$key} {
justify-content: #{$value} !important;
}
}
}
}

// Flex Direction
// ------------------------------------------------------------------

$flex-direction-values: (
row,
row-reverse,
column,
column-reverse
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $value in $flex-direction-values {
.ion-flex#{$infix}-#{$value} {
flex-direction: #{$value} !important;
}
}
}
}

.ion-align-items-baseline {
align-items: baseline !important;
// Flex Wrap
// ------------------------------------------------------------------

$flex-wrap-values: (
wrap,
nowrap,
wrap-reverse
);

@each $value in $flex-wrap-values {
// TODO(FW-6697): remove ion-wrap, ion-nowrap, ion-wrap-reverse
// in favor of the new ion-flex-wrap, ion-flex-nowrap, and
// ion-flex-wrap-reverse classes
.ion-#{$value} {
flex-wrap: #{$value} !important;
}
}

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $value in $flex-wrap-values {
.ion-flex#{$infix}-#{$value} {
flex-wrap: #{$value} !important;
}
}
}
}

// Flex Fill
// ------------------------------------------------------------------

$flex-fill-values: (
1,
auto,
initial,
none
);

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
@each $value in $flex-fill-values {
.ion-flex#{$infix}-#{$value} {
flex: #{$value} !important;
}
}
}
}

// Flex Grow and Shrink
// ------------------------------------------------------------------

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
.ion-flex#{$infix}-grow-0 {
flex-grow: 0 !important;
}

.ion-flex#{$infix}-grow-1 {
flex-grow: 1 !important;
}

.ion-flex#{$infix}-shrink-0 {
flex-shrink: 0 !important;
}

.ion-flex#{$infix}-shrink-1 {
flex-shrink: 1 !important;
}
}
}

// Flex Order
// ------------------------------------------------------------------

@each $breakpoint in map-keys($screen-breakpoints) {
$infix: breakpoint-infix($breakpoint, $screen-breakpoints);
@include media-breakpoint-up($breakpoint, $screen-breakpoints) {
.ion-order#{$infix}-first { order: -1 !important; }

@for $i from 0 through 12 {
.ion-order#{$infix}-#{$i} { order: #{$i} !important; }
}

.ion-order#{$infix}-last { order: 13 !important; }
}
}
Loading
Loading