package toffee

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Style.Track_sizing_functionSource

CSS Grid track sizing functions.

A track sizing function specifies the minimum and maximum sizes of a grid track (row or column). Grid tracks automatically size between their minimum and maximum based on content size, available space, and the sizing constraints applied to the grid.

See MDN: grid-template-columns

Sourcetype t = {
  1. min : Compact_length.t;
    (*

    Minimum track sizing function.

    *)
  2. max : Compact_length.t;
    (*

    Maximum track sizing function.

    *)
}

A track sizing function combining minimum and maximum sizing constraints.

Construction

Sourceval make : min:Compact_length.t -> max:Compact_length.t -> t

make ~min ~max creates a track sizing function with explicit min and max constraints.

Sourceval auto : t

auto creates a track sized automatically according to grid algorithm rules. Equivalent to minmax(auto, auto).

Sourceval min_content : t

min_content creates a track sized to the smallest size that fits content with all soft line-wrapping opportunities taken. Equivalent to minmax(min-content, min-content).

Sourceval max_content : t

max_content creates a track sized to the smallest size that fits content with no soft line-wrapping opportunities taken. Equivalent to minmax(max-content, max-content).

Sourceval zero : t

zero creates a zero-sized track.

Sourceval fr : float -> t

fr value creates a flexible track that takes a fraction of available space. The track receives value parts out of the sum of all fr values in the grid dimension. Equivalent to minmax(auto, <value>fr).

See CSS Grid fr unit specification.

Sourceval length : float -> t

length value creates a fixed-size track with the specified length. Equivalent to minmax(<value>px, <value>px).

Sourceval percent : float -> t

percent value creates a track sized as a percentage of the grid container.

The value is a fraction in the range 0.0, 1.0, where 0.5 represents 50%. See Compact_length for percentage conventions.

Sourceval from_length_percentage : Compact_length.t -> t

from_length_percentage lp creates a track from a length or percentage value, applying it to both min and max sizing functions.

Sourceval fit_content : Compact_length.t -> t

fit_content lp creates a track sized by the fit-content formula: max(min-content, min(max-content, lp)).

The track takes the size of lp clamped between min-content and max-content sizes. Equivalent to minmax(auto, fit-content(<lp>)).

Sourceval minmax : min:Compact_length.t -> max:Compact_length.t -> t

minmax ~min ~max creates a track sizing function with separate min and max constraints. Alias for make.

Accessors

min t returns the minimum sizing function.

max t returns the maximum sizing function.

Sourceval min_sizing_function : t -> Compact_length.t

min_sizing_function t returns the minimum sizing function. Alias for min.

Sourceval max_sizing_function : t -> Compact_length.t

max_sizing_function t returns the maximum sizing function. Alias for max.

Predicates

Sourceval has_fixed_component : t -> bool

has_fixed_component t returns true if at least one component (min or max) is a fixed length or percentage value.

Comparison and Display

Sourceval equal : t -> t -> bool

equal a b returns true if a and b represent the same track sizing function.

Sourceval compare : t -> t -> int

compare a b compares a and b lexicographically, first by min then by max.

Sourceval to_string : t -> string

to_string t converts t to a string representation. Returns a compact form when min equals max, otherwise returns minmax(min, max) form.

Sourceval pp : Format.formatter -> t -> unit

pp fmt t formats t for pretty-printing.

Minimum Sizing Function Helpers

Sourcemodule Min : sig ... end

Operations on the minimum sizing function component.

Maximum Sizing Function Helpers

Sourcemodule Max : sig ... end

Operations on the maximum sizing function component.