Defines the size of a track (a row or a column) in a Grid.

Use the companion functions (e.g., Fixed, Flex) to create instances.

Summary

Public companion functions

GridTrackSize
Fixed(size: Dp)

A track with a fixed Dp size.

Cmn
GridTrackSize
Flex(weight: @FloatRange(from = 0.0) Fr)

A flexible track that takes a share of the remaining space after Fixed and Percentage tracks are allocated.

Cmn
GridTrackSize
Percentage(value: @FloatRange(from = 0.0) Float)

A track sized as a percentage of the total available size of the grid container.

Cmn

Public companion properties

GridTrackSize

A track that behaves automatically, typically similar to MinContent or Flex depending on context.

Cmn
GridTrackSize

A track that sizes itself to fit the maximum intrinsic size of its contents.

Cmn
GridTrackSize

A track that sizes itself to fit the minimum intrinsic size of its contents.

Cmn

Public functions

open String
Cmn

Public companion functions

Fixed

fun Fixed(size: Dp): GridTrackSize

A track with a fixed Dp size.

Parameters
size: Dp

The size of the track.

Flex

fun Flex(weight: @FloatRange(from = 0.0) Fr): GridTrackSize

A flexible track that takes a share of the remaining space after Fixed and Percentage tracks are allocated.

Parameters
weight: @FloatRange(from = 0.0) Fr

The flexible weight. Space is distributed proportional to this weight divided by the total flex weight. Must be non-negative.

Throws
kotlin.IllegalArgumentException

if weight is negative.

Percentage

fun Percentage(value: @FloatRange(from = 0.0) Float): GridTrackSize

A track sized as a percentage of the total available size of the grid container. Note: In this implementation, percentages are calculated based on the remaining available space after gaps. This differs from the W3C CSS Grid spec, where percentages are based on the container size regardless of gaps. This behavior prevents unexpected overflows when mixing gaps and percentages (e.g., 50% + 50% + gap will fit perfectly here, but would overflow in CSS).

Parameters
value: @FloatRange(from = 0.0) Float

The percentage of the container size.

Throws
kotlin.IllegalArgumentException

if value is negative.

Public companion properties

Auto

val AutoGridTrackSize

A track that behaves automatically, typically similar to MinContent or Flex depending on context.

MaxContent

val MaxContentGridTrackSize

A track that sizes itself to fit the maximum intrinsic size of its contents.

MinContent

val MinContentGridTrackSize

A track that sizes itself to fit the minimum intrinsic size of its contents.

Public functions

toString

open fun toString(): String