FlexBasis

Class

Common
@ExperimentalFlexBoxApi
value class FlexBasis
@PublishedApi
internal constructor(@PublishedApi internal val packedValue: Long)

Defines the initial main size of a flex item before free space distribution.

  • Auto: Uses the item's explicitly set size, or falls back to its natural content size.
  • Dp: Uses a fixed exact size in androidx.compose.ui.unit.Dp.
  • Percent: Uses a fraction of the container's main axis size.

Companion Object

Properties

Common
val Auto = FlexBasis(TypeAuto shl TypeShift)

Use the item's maximum intrinsic size as the basis.

If the item has an explicitly set size modifier along the main axis (for example, Modifier.width in a FlexDirection.Row), that exact size will be used as the basis. Otherwise, it falls back to measuring the item's preferred natural content size without constraints.

This is the default value.

Methods

Common
fun Dp(value: Dp): FlexBasis

Use a fixed size in androidx.compose.ui.unit.Dp as the basis.

Parameters

valueThe basis size in Dp.
Common
fun Percent(@FloatRange(0.0, 1.0) value: Float): FlexBasis

Use a fraction of the container's main axis size as the basis.

Parameters

valueA value between 0.0 and 1.0 representing the percentage.