package virtual_dom

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

This type covers both properties and attributes, despite the name.

val create : string -> string -> t

create name value creates a simple string-only attribute

val create_float : string -> float -> t

create_float name float creates a simple float-only attribute

val string_property : string -> string -> t

string_property name value creates a simple string-only property

val bool_property : string -> bool -> t

bool_property name value creates a simple bool-only property

val property : string -> Js_of_ocaml.Js.Unsafe.any -> t

property name value creates a property with a generic value

val suppress_merge_warnings : t -> t

This function does not affect hooks, styles, classes, or on_* handlers, since warnings due to merging those can be avoided. It allows disabling warnings for attributes that are unmergeable. Note that no merging behavior is changed by this function - it only changes whether warnings are emitted.

Example: If href is already on a node, then adding a suppress_merge_warning (href input) attribute to the node will not trigger a warning. However, adding another href which does not use suppress_merge_warnings to the node will again emit a warning. In other words, this function only suppresses warnings for an instance of an attribute, not all attributes of the same type. *

val create_hook : string -> Virtual_dom__.Hooks.t -> t

create_hook name hook creates a hook attribute with a name

val of_opt : t option -> t

of_opt attr returns the underlying Attr.t for a Some, and Attr.empty for a None

val many : t list -> t

many merges several attributes into one. It merges hooks, on_* event handlers, classes, and styles.

  • Hooks get merged via their Input.combine function
  • All handlers get run in the order they appear
  • The set of classes is unioned
  • Styles are merged via concatenation
val many_without_merge : t list -> t

Like many, except instead of merging attributes of the same type, it takes the last one. Don't use this function - use many instead.

val empty : t

Equivalent to many []. It adds no attributes to the DOM.

val (@) : t -> t -> t

Equivalent to combine

val combine : t -> t -> t

Equivalent to many [x; y]

val autofocus : bool -> t
val checked : t
val class_ : string -> t
val classes : string list -> t
val classes' : Core.Set.M(Core.String).t -> t
val disabled : t
val allow : string -> t
val for_ : string -> t
val label : string -> t
val href : string -> t
val target : string -> t
val id : string -> t
val name : string -> t
val placeholder : string -> t
val role : string -> t
val selected : t
val hidden : t
val readonly : t
val style : Css_gen.t -> t
val min : float -> t
val max : float -> t
val min_date : Core.Date.t -> t
val max_date : Core.Date.t -> t
val min_date_time : Core.Date.t -> t

Sets the min time of a datetime-local picker to any time in the specified date. This function receives a Date.t instead of a Time_ns.t because the browser doesn't actually limit the time part of a datetime-local picker, even if a time is specified.

val max_date_time : Core.Date.t -> t

Similar to min_date_time, but sets the maximum instead.

val colspan : int -> t
val rowspan : int -> t
val draggable : bool -> t
val tabindex : int -> t
val type_ : string -> t
val value : string -> t
val rows : int -> t
val cols : int -> t
val value_prop : string -> t
val title : string -> t
val alt : string -> t
val src : string -> t
val open_ : t
val start : int -> t
module Unmerged_warning_mode : sig ... end
val on_input : (Js_of_ocaml.Dom_html.event Js_of_ocaml.Js.t -> string -> unit Ui_effect.t) -> t

on_input fires every time the input changes, i.e., whenever a key is pressed in the input field. The current contents are returned as an OCaml string as a convenience

val on_change : (Js_of_ocaml.Dom_html.event Js_of_ocaml.Js.t -> string -> unit Ui_effect.t) -> t

on_change fires when the input is complete, i.e., when enter is pressed in the input field or the input field loses focus. The current contents are returned as an OCaml string as a convenience

on_file_input is like on_input but for file picker input elements (i.e. type=file). Instead of passing the value of the input as a string, the list of selected files is passed.

See Vdom_input_widgets.File_select, or, if you are a bonsai user, Bonsai_web_ui_form.Elements.File_select, for a convenient API that wraps this.

val css_var : name:string -> string -> t

Sets a css named variable on the element. The "--" prefix is added by this function: css_var ~name:"foo" "red" is equivalent to the css --foo: red.

val __css_vars_no_kebabs : (string * string) list -> t

For ppx use only

module Multi : sig ... end

A collection of CSS attributes.

module Always_focus_hook : sig ... end
module Single_focus_hook () : sig ... end
module No_op_hook (M : sig ... end) : sig ... end
module Expert : sig ... end
module Hooks : sig ... end
module Global_listeners : sig ... end

Hooks to set events listeners on window. This is needed as if we only set them on individual elements we will miss ones that happen outside of the viewport

OCaml

Innovation. Community. Security.