package toffee

  1. Overview
  2. Docs
CSS layout engine for OCaml (Flexbox, Grid, Block)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/toffee.style/Style/index.html

Module StyleSource

Style types for CSS layout.

This module provides CSS style properties for layout computation, including dimensions, positioning, flexbox, and grid layout.

Sourcetype calc_resolver = int -> float -> float

Type for calc resolver function.

Length types

Sourcemodule Compact_length : sig ... end

Compact representation of CSS length values.

Sourcemodule Length_percentage : sig ... end

CSS length-percentage values.

Sourcemodule Length_percentage_auto : sig ... end

CSS length-percentage-auto values.

Sourcemodule Dimension : sig ... end

CSS dimension values supporting length, percentage, auto, and calc().

Layout control types

Sourcemodule Display : sig ... end

CSS display property controlling box generation and child layout algorithm.

Sourcemodule Position : sig ... end

CSS position property controlling normal flow participation.

Sourcemodule Overflow : sig ... end

CSS overflow property.

Sourcemodule Box_sizing : sig ... end

CSS box-sizing property.

Sourcemodule Box_generation_mode : sig ... end

CSS box generation mode.

Sourcemodule Text_align : sig ... end

CSS text-align property for block layout.

Flexbox types

Sourcemodule Flex_direction : sig ... end

CSS flex-direction property for flexbox layout.

Sourcemodule Flex_wrap : sig ... end

Controls whether flex items wrap onto multiple lines.

Alignment types

Sourcemodule Align_items : sig ... end

Controls how child nodes are aligned.

Sourcemodule Justify_items : sig ... end

Controls how child nodes are aligned.

Sourcemodule Align_self : sig ... end

Controls alignment of an individual child node.

Sourcemodule Justify_self : sig ... end

Controls alignment of an individual child node.

Sourcemodule Align_content : sig ... end

Sets the distribution of space between and around content items.

Sourcemodule Justify_content : sig ... end

Sets the distribution of space between and around content items.

Grid types

Sourcemodule Grid_auto_flow : sig ... end

CSS grid-auto-flow property.

Sourcemodule Grid_placement : sig ... end

CSS Grid item placement specification.

Sourcemodule Grid_repetition : sig ... end

Grid track repetition specification.

Sourcemodule Grid_template_area : sig ... end

CSS grid template areas.

Sourcemodule Grid_template_component : sig ... end

Grid template component definitions.

Sourcemodule Repetition_count : sig ... end

CSS Grid track repetition counts.

Sourcemodule Track_sizing_function : sig ... end

CSS Grid track sizing functions.

Sourcemodule Grid : sig ... end

Grid coordinate systems and track utilities with submodules.

Type aliases

Sourcetype length_percentage = Length_percentage.t
Sourcetype length_percentage_auto = Length_percentage_auto.t
Sourcetype dimension = Dimension.t

Alias for Dimension.t.

Sourcetype display = Display.t

Alias for Display.t.

Sourcetype position = Position.t

Alias for Position.t.

Sourcetype overflow = Overflow.t

Alias for Overflow.t.

Sourcetype box_sizing = Box_sizing.t

Alias for Box_sizing.t.

Sourcetype box_generation_mode = Box_generation_mode.t
Sourcetype text_align = Text_align.t

Alias for Text_align.t.

Sourcetype flex_direction = Flex_direction.t

Alias for Flex_direction.t.

Sourcetype flex_wrap = Flex_wrap.t

Alias for Flex_wrap.t.

Sourcetype align_items = Align_items.t

Alias for Align_items.t.

Sourcetype align_content = Align_content.t

Alias for Align_content.t.

Sourcetype justify_items = Justify_items.t

Alias for Justify_items.t.

Sourcetype align_self = Align_self.t

Alias for Align_self.t.

Sourcetype justify_self = Justify_self.t

Alias for Justify_self.t.

Sourcetype justify_content = Justify_content.t
Sourcetype grid_auto_flow = Grid_auto_flow.t

Alias for Grid_auto_flow.t.

Sourcetype grid_placement = Grid_placement.t

Alias for Grid_placement.t.

Sourcetype track_sizing_function = Track_sizing_function.t
Sourcetype repetition_count = Repetition_count.t
Sourcetype grid_repetition = Grid_repetition.t
Sourcetype grid_template_component = Grid_template_component.t
Sourcetype grid_template_area = Grid_template_area.t

Convenience constructors

Sourcemodule Rect_dim : sig ... end
Sourcemodule Size_dim : sig ... end

Main Style type

Sourcetype t

The main style struct representing CSS style properties.

Sourceval default : t

Default style values.

Constructor

Sourceval make : ?display:display -> ?box_sizing:box_sizing -> ?position:position -> ?overflow:overflow Geometry.point -> ?scrollbar_width:float -> ?text_align:text_align -> ?inset:length_percentage_auto Geometry.rect -> ?size:dimension Geometry.size -> ?min_size:dimension Geometry.size -> ?max_size:dimension Geometry.size -> ?aspect_ratio:float -> ?margin:length_percentage_auto Geometry.rect -> ?padding:length_percentage Geometry.rect -> ?border:length_percentage Geometry.rect -> ?gap:length_percentage Geometry.size -> ?align_items:align_items -> ?align_self:align_self -> ?align_content:align_content -> ?justify_items:justify_items -> ?justify_self:justify_self -> ?justify_content:justify_content -> ?flex_direction:flex_direction -> ?flex_wrap:flex_wrap -> ?flex_grow:float -> ?flex_shrink:float -> ?flex_basis:dimension -> ?grid_template_rows:grid_template_component list -> ?grid_template_columns:grid_template_component list -> ?grid_auto_rows:track_sizing_function list -> ?grid_auto_columns:track_sizing_function list -> ?grid_auto_flow:grid_auto_flow -> ?grid_template_areas:grid_template_area list -> ?grid_template_column_names:string list list -> ?grid_template_row_names:string list list -> ?grid_row:grid_placement Geometry.line -> ?grid_column:grid_placement Geometry.line -> unit -> t

make ... creates a style with optional parameters, defaulting to default for unspecified fields.

Accessors

Property accessors return the current value of style properties. See the corresponding module for property semantics.

Sourceval display : t -> display

display t returns the display mode. See Display.

Sourceval item_is_table : t -> bool

item_is_table t returns true if the item is a table element.

Sourceval box_generation_mode : t -> box_generation_mode

box_generation_mode t returns the box generation mode. See Box_generation_mode.

Sourceval set_box_generation_mode : box_generation_mode -> t -> t

set_box_generation_mode mode t returns a style with updated box generation mode.

Sourceval is_compressible_replaced : t -> bool

is_compressible_replaced t returns true if the item is a compressible replaced element.

Sourceval text_align : t -> text_align

text_align t returns the text alignment. See Text_align.

Sourceval item_is_replaced : t -> bool

item_is_replaced t returns true if the item is a replaced element.

Sourceval box_sizing : t -> box_sizing

box_sizing t returns the box sizing mode. See Box_sizing.

Sourceval overflow : t -> overflow Geometry.point

overflow t returns the overflow behavior for both axes. See Overflow.

Sourceval scrollbar_width : t -> float

scrollbar_width t returns the scrollbar width in pixels.

Sourceval position : t -> position

position t returns the positioning mode. See Position.

inset t returns the inset values (top, right, bottom, left).

size t returns the explicit size (width, height). See Dimension.

Sourceval min_size : t -> dimension Geometry.size

min_size t returns the minimum size constraints.

Sourceval max_size : t -> dimension Geometry.size

max_size t returns the maximum size constraints.

Sourceval aspect_ratio : t -> float option

aspect_ratio t returns the aspect ratio constraint, if any.

margin t returns the margin values. See Length_percentage_auto.

padding t returns the padding values. See Length_percentage.

border t returns the border widths.

gap t returns the gap between items (row_gap, column_gap).

Sourceval align_items : t -> align_items option

align_items t returns the cross-axis alignment for children. See Align_items.

Sourceval align_self : t -> align_self option

align_self t returns the self cross-axis alignment override. See Align_self.

Sourceval align_content : t -> align_content option

align_content t returns the content alignment in the cross axis. See Align_content.

Sourceval justify_items : t -> justify_items option

justify_items t returns the inline-axis alignment for children (Grid only). See Justify_items.

Sourceval justify_self : t -> justify_self option

justify_self t returns the self inline-axis alignment override. See Justify_self.

Sourceval justify_content : t -> justify_content option

justify_content t returns the content alignment in the main/inline axis. See Justify_content.

Sourceval flex_direction : t -> flex_direction

flex_direction t returns the flex container direction. See Flex_direction.

Sourceval flex_wrap : t -> flex_wrap

flex_wrap t returns the flex wrap behavior. See Flex_wrap.

Sourceval flex_grow : t -> float

flex_grow t returns the flex grow factor.

Sourceval flex_shrink : t -> float

flex_shrink t returns the flex shrink factor.

Sourceval flex_basis : t -> dimension

flex_basis t returns the initial main size before growing/shrinking.

Sourceval grid_template_rows : t -> grid_template_component list

grid_template_rows t returns the explicit row track definitions. See Grid_template_component.

Sourceval grid_template_columns : t -> grid_template_component list

grid_template_columns t returns the explicit column track definitions.

Sourceval grid_auto_rows : t -> track_sizing_function list

grid_auto_rows t returns the implicit row track sizing. See Track_sizing_function.

Sourceval grid_auto_columns : t -> track_sizing_function list

grid_auto_columns t returns the implicit column track sizing.

Sourceval grid_auto_flow : t -> grid_auto_flow

grid_auto_flow t returns the auto-placement algorithm. See Grid_auto_flow.

Sourceval grid_template_areas : t -> grid_template_area list

grid_template_areas t returns the named grid areas. See Grid_template_area.

Sourceval grid_template_column_names : t -> string list list

grid_template_column_names t returns the named column lines.

Sourceval grid_template_row_names : t -> string list list

grid_template_row_names t returns the named row lines.

grid_row t returns the row placement (start, end). See Grid_placement.

Sourceval grid_column : t -> grid_placement Geometry.line

grid_column t returns the column placement (start, end).

Functional updates

Setters return a new style with the specified property updated. All other properties remain unchanged.

Sourceval set_display : display -> t -> t

set_display v t returns a style with updated display mode.

Sourceval set_position : position -> t -> t

set_position v t returns a style with updated positioning mode.

Sourceval set_overflow : overflow Geometry.point -> t -> t

set_overflow v t returns a style with updated overflow behavior.

Sourceval set_scrollbar_width : float -> t -> t

set_scrollbar_width v t returns a style with updated scrollbar width.

Sourceval set_text_align : text_align -> t -> t

set_text_align v t returns a style with updated text alignment.

set_inset v t returns a style with updated inset values.

Sourceval set_size : dimension Geometry.size -> t -> t

set_size v t returns a style with updated explicit size.

Sourceval set_width : dimension -> t -> t

set_width v t returns a style with size.width updated to v.

Sourceval set_height : dimension -> t -> t

set_height v t returns a style with size.height updated to v.

Sourceval set_min_size : dimension Geometry.size -> t -> t

set_min_size v t returns a style with updated minimum size.

Sourceval set_min_width : dimension -> t -> t

set_min_width v t returns a style with min_size.width updated to v.

Sourceval set_min_height : dimension -> t -> t

set_min_height v t returns a style with min_size.height updated to v.

Sourceval set_max_size : dimension Geometry.size -> t -> t

set_max_size v t returns a style with updated maximum size.

Sourceval set_max_width : dimension -> t -> t

set_max_width v t returns a style with max_size.width updated to v.

Sourceval set_max_height : dimension -> t -> t

set_max_height v t returns a style with max_size.height updated to v.

Sourceval set_aspect_ratio : float option -> t -> t

set_aspect_ratio v t returns a style with updated aspect ratio.

set_margin v t returns a style with updated margin values.

Sourceval set_margin_left : length_percentage_auto -> t -> t

set_margin_left v t returns a style with margin.left updated to v.

Sourceval set_margin_right : length_percentage_auto -> t -> t

set_margin_right v t returns a style with margin.right updated to v.

Sourceval set_margin_top : length_percentage_auto -> t -> t

set_margin_top v t returns a style with margin.top updated to v.

Sourceval set_margin_bottom : length_percentage_auto -> t -> t

set_margin_bottom v t returns a style with margin.bottom updated to v.

Sourceval set_margin_x : length_percentage_auto -> t -> t

set_margin_x v t returns a style with both margin.left and margin.right updated to v.

Sourceval set_margin_y : length_percentage_auto -> t -> t

set_margin_y v t returns a style with both margin.top and margin.bottom updated to v.

Sourceval set_padding : length_percentage Geometry.rect -> t -> t

set_padding v t returns a style with updated padding values.

Sourceval set_padding_left : length_percentage -> t -> t

set_padding_left v t returns a style with padding.left updated to v.

Sourceval set_padding_right : length_percentage -> t -> t

set_padding_right v t returns a style with padding.right updated to v.

Sourceval set_padding_top : length_percentage -> t -> t

set_padding_top v t returns a style with padding.top updated to v.

Sourceval set_padding_bottom : length_percentage -> t -> t

set_padding_bottom v t returns a style with padding.bottom updated to v.

Sourceval set_padding_x : length_percentage -> t -> t

set_padding_x v t returns a style with both padding.left and padding.right updated to v.

Sourceval set_padding_y : length_percentage -> t -> t

set_padding_y v t returns a style with both padding.top and padding.bottom updated to v.

Sourceval set_border : length_percentage Geometry.rect -> t -> t

set_border v t returns a style with updated border widths.

set_gap v t returns a style with updated gap between items.

Sourceval set_align_items : align_items option -> t -> t

set_align_items v t returns a style with updated child alignment.

Sourceval set_align_self : align_self option -> t -> t

set_align_self v t returns a style with updated self alignment.

Sourceval set_align_content : align_content option -> t -> t

set_align_content v t returns a style with updated content alignment.

Sourceval set_justify_items : justify_items option -> t -> t

set_justify_items v t returns a style with updated justify items.

Sourceval set_justify_self : justify_self option -> t -> t

set_justify_self v t returns a style with updated justify self.

Sourceval set_justify_content : justify_content option -> t -> t

set_justify_content v t returns a style with updated justify content.

Sourceval set_flex_direction : flex_direction -> t -> t

set_flex_direction v t returns a style with updated flex direction.

Sourceval set_flex_wrap : flex_wrap -> t -> t

set_flex_wrap v t returns a style with updated flex wrap.

Sourceval set_flex_grow : float -> t -> t

set_flex_grow v t returns a style with updated flex grow factor.

Sourceval set_flex_shrink : float -> t -> t

set_flex_shrink v t returns a style with updated flex shrink factor.

Sourceval set_flex_basis : dimension -> t -> t

set_flex_basis v t returns a style with updated flex basis.

Sourceval set_grid_template_rows : grid_template_component list -> t -> t

set_grid_template_rows v t returns a style with updated row templates.

Sourceval set_grid_template_columns : grid_template_component list -> t -> t

set_grid_template_columns v t returns a style with updated column templates.

Sourceval set_grid_auto_rows : track_sizing_function list -> t -> t

set_grid_auto_rows v t returns a style with updated auto row sizing.

Sourceval set_grid_auto_columns : track_sizing_function list -> t -> t

set_grid_auto_columns v t returns a style with updated auto column sizing.

Sourceval set_grid_auto_flow : grid_auto_flow -> t -> t

set_grid_auto_flow v t returns a style with updated auto-flow algorithm.

Sourceval set_grid_template_areas : grid_template_area list -> t -> t

set_grid_template_areas v t returns a style with updated named areas.

Sourceval set_grid_template_column_names : string list list -> t -> t

set_grid_template_column_names v t returns a style with updated column line names.

Sourceval set_grid_template_row_names : string list list -> t -> t

set_grid_template_row_names v t returns a style with updated row line names.

Sourceval set_grid_row : grid_placement Geometry.line -> t -> t

set_grid_row v t returns a style with updated row placement.

Sourceval set_grid_column : grid_placement Geometry.line -> t -> t

set_grid_column v t returns a style with updated column placement.

Common style patterns

Sourceval flex_row : t

Style with flex display and row direction.

Sourceval flex_column : t

Style with flex display and column direction.

Sourceval absolute : t

Style with absolute positioning.

Sourceval flex_1 : t

Style with flex_grow=1, flex_shrink=1, flex_basis=0.