package stk

  1. Overview
  2. Docs

Flex container widget.

Properties

val inter_space : int Props.prop

Property to specify the size of space between two items.

val wrap : bool Props.prop

Property "flex_wrap" to specify whether lines can be wrapped when they don't fit.

val wrap_on_break : bool Props.prop

Property "flex_wrap_on_break" to specify whether a line is broken when a `Break item is encountered.

val collapse_spaces : bool Props.prop

Property "flex_collapse_spaces" to specify whether `Space items must be collapsed.

val expand : int Props.prop

Property "flex_item_expand" to specify how an item must expand. A value higher than the other items on the same line will give more space to this item.

type item_kind = [
  1. | `Block
  2. | `Break
  3. | `Item
  4. | `Space of bool
]

Item kind indicates how to handle an item:

  • `Break indicates a break of line, which can be considered as space or real break, depending on the wrap_on_break property,
  • `Block indicates that this item must be arranged alone on a line,
  • `Item indicates that this item is "normal" and can be arranged inline,
  • `Space b indicates that this item is a space in arrangement algorithm. b = true is used internally to indicate that this space must be taken into account when computing coordinates.
val item_kind : item_kind Props.prop

"flex_item_kind" property. Default value is `Item.

type justification = [
  1. | `Center
  2. | `End
  3. | `Justified
  4. | `Space_around
  5. | `Space_between
  6. | `Start
]

Justification of items:

  • `Start aligns items on the left in horizontal flex, on top in vertical flex.
  • `End aligns items on the right in horizontal flex, on bottom in vertical flex.
  • `Center centers items #CaptainObvious.
  • `Space_around distributes spaces at the beginning of line, between items and at the end of line.
  • `Space_betwwen distributes spaces between items, leaving no space at the beginning and the end of the line.
  • `Justified is like `Space_between except that the last line is justified as `Start (like a regular text paragraph).
val justification : justification Props.prop

"flex_justification" property. Default value is `Start.

type item_alignment = [
  1. | `Baseline
  2. | `Center
  3. | `End
  4. | `Start
  5. | `Stretch
]
val items_alignment : item_alignment Props.prop

"flex_items_alignment" property. Default is `Baseline.

type content_alignment = [
  1. | `Center
  2. | `End
  3. | `Space_around
  4. | `Space_between
  5. | `Start
  6. | `Stretch
]
val content_alignment : content_alignment Props.prop

"flex_content_alignment" property. Default is `Stretch.

class space : ?class_:string option -> ?name:string option -> ?props:Props.t option -> unit -> object ... end

A space item. Use space or break to create it, as it will set the correct value for item_kind property. Default class_ is "flex_space".

val space : ?class_:string -> ?name:string -> ?props:Props.t -> unit -> space

Create a space item with correct item_kind value. See widget_arguments for arguments.

val break : ?class_:string -> ?name:string -> ?props:Props.t -> unit -> space

Create a space item with `Break for item_kind property. Default class_ is "flex_break". See widget_arguments for arguments.

class 'a flex : ?class_:string option -> ?name:string option -> ?props:Props.t option -> unit -> object ... end
val flex : ?class_:string -> ?name:string -> ?props:Props.t -> ?orientation:Props.orientation -> ?justification:justification -> ?items_alignment:item_alignment -> ?content_alignment:content_alignment -> ?inter_space:int -> ?wrap:bool -> ?wrap_on_break:bool -> ?collapse_spaces:bool -> ?pack:(Widget.widget -> unit) -> unit -> 'a flex

Convenient function to create a flex. Optional arguments:

  • orientation specifies horizontal or vertical packing. Default is Props.orientation.Horizontal.
  • justification, items_alignment, content_alignment, inter_space, wrap, wrap_on_break and collapse_spaces are used to set the corresponding properties.

See widget_arguments for other arguments.

OCaml

Innovation. Community. Security.