react

    Type-safe MoonBit bindings for React with virtual DOM, hooks, and CSS-in-JS support (early experimental)

    react
    binding
    Download zip
    Author
    Version
    0.4.0
    License
    Apache-2.0
    Last updated
    16 days ago
    Downloads
    103

    #tiye/react

    React bindings for MoonBit

    #Project Status

    🚧 This is an early project

    This is an experimental hobby project exploring MoonBit bindings for React. The API is unstable and may change frequently. Not recommended for production use. This project is intended for technical exploration and learning purposes only.

    #API Stability and JavaScript Boundary

    All public APIs are experimental. The virtual-node, element-helper, and basic hook APIs are the maintained baseline; React 19 concurrent hooks and the broad event catalogue are newer additions that should receive application-level testing before adoption. Deprecated compatibility APIs remain available only until the next breaking release.

    JsObscure is the explicit escape hatch at the MoonBit/JavaScript boundary. Use it for hook dependency values with obscure(value) and for intentional JS interoperation only. Generic hook and component values cross React using the MoonBit JavaScript representation, so they must be values that the generated MoonBit runtime can pass directly; do not assume JSON serialization or deep cloning occurs.

    The browser entry point must initialize globalThis.React, globalThis.ReactDOM, and globalThis.ReactDOMClient before calling this package. (window and globalThis are the same global object in a browser.) ReactDOM supplies DOM-specific Hooks such as use_form_status; the bundled demo shows the supported ESM integration pattern.

    Component functions must be placed in the virtual DOM through component, not called directly. Use component_with_children when the component needs to place caller-supplied children in its own tree.

    Apply with_key to children in dynamic collections, using stable application identities rather than array indexes.

    #Bound APIs and Types

    #Core Rendering API

    • render(vdom: VirtualNode, parent: @dom.Element) -> Unit - Render virtual DOM to specified parent element
    • render_with_options(vdom: VirtualNode, parent: @dom.Element, options: RootOptions) -> Unit - Create and render through a configured React root
    • hydrate_root(vdom: VirtualNode, parent: @dom.Element, options?: RootOptions) -> Unit - Attach React to matching server-rendered HTML
    • unmount(parent: @dom.Element) -> Unit - Unmount the React root for an element
    • create_portal(child: VirtualNode, parent: @dom.Element, key?: String) -> VirtualNode - Place DOM in another container while retaining React-tree context and event propagation
    • render_to_string(vdom: VirtualNode, identifier_prefix?: String) -> String - Basic synchronous SSR/SSG renderer
    • render_to_readable_stream(vdom: VirtualNode, options?: StreamRenderOptions) -> ReactReadableStream - Start React 19.2 progressive SSR on runtimes with Web Streams
    • StreamRenderOptions::new(...) -> StreamRenderOptions - Configure identifier prefixes, bootstrap scripts/modules, CSP nonce, and server error reporting
    • ReactReadableStream::{wait_all_ready, read_text, abort, to_js_readable_stream} - Wait for suspended content, consume HTML, cancel work, or integrate the one-shot Web Stream directly
    • RootOptions::new(...) -> RootOptions - Configure identifierPrefix and caught, uncaught, and recoverable error callbacks
    • ReactError::message() -> String, ReactErrorInfo::component_stack() -> String - Inspect root callback values
    • component[T](f: (T) -> VirtualNode, props: T, children: Array[VirtualNode]) -> VirtualNode - Create a leaf component
    • component_with_children[T](f: (T, Array[VirtualNode]) -> VirtualNode, props: T, children: Array[VirtualNode]) -> VirtualNode - Create a component that places its children
    • define_component[T](render: (T) -> VirtualNode) -> ReactComponent[T] - Define a stable reusable component type with typed MoonBit props
    • ReactComponent::render(props: T) -> VirtualNode - Render a reusable typed component
    • ReactComponent::memo(are_props_equal?: (T, T) -> Bool) -> ReactComponent[T] - Memoize a typed component with default identity or a typed comparator
    • lazy_component[T](loader: async () -> ReactComponent[T]) -> ReactComponent[T] - Lazily load and cache a typed component through Suspense
    • suspense(fallback: VirtualNode, children: Array[VirtualNode]) -> VirtualNode - Display fallback UI until suspended children are ready
    • activity(mode: ActivityMode, children: Array[VirtualNode]) -> VirtualNode - React 19.2 boundary that hides and restores UI while retaining child state
    • resource_from_promise[T](promise: Promise[T]) -> ReactResource[T] - Preserve one cached JavaScript Promise as a typed React resource
    • resource_from_async[T](loader: async () -> T) -> ReactResource[T] - Start one MoonBit async operation outside render and preserve its Promise identity
    • use_resource[T](resource: ReactResource[T]) -> T - Read a cached resource with React 19 use, suspending or throwing to the nearest boundary
    • error_boundary(fallback, children, reset_key?, on_error?) -> VirtualNode - Render a local fallback for render/resource errors and retry when its reset key changes
    • component_from_js[T](component: JsObscure) -> ReactComponent[T] - Declare the typed MoonBit props contract for a trusted JavaScript component
    • VirtualNode::with_key(key: String) -> VirtualNode - Assign a stable React reconciliation key without adding a DOM wrapper
    • create_context[T](default_value: T) -> ReactContext[T] - Create a typed React Context
    • ReactContext::provider(value: T, children: Array[VirtualNode]) -> VirtualNode - Provide a value without adding a DOM wrapper
    • flush_sync(callback: () -> Unit) -> Unit - Force callback updates into the DOM before returning for rare third-party integrations
    • prefetch_dns, preconnect, preload, preload_module, preinit, preinit_module - Emit React-managed browser resource hints
    • PreloadOptions, ModuleHintOptions, PreinitOptions - Configure typed destination, CORS, priority, integrity, CSP, image, module, and stylesheet-precedence metadata

    For example, use component(my_component, props, []), never my_component(props) directly in a virtual DOM tree.

    #Hooks API

    • use_state[T](initial: T) -> (T, (T) -> Unit) - State management hook
    • use_context[T](context: ReactContext[T]) -> T - Read and subscribe to the nearest typed Context provider
    • use_state_with_updater[T](initial: T) -> (T, (StateUpdate[T]) -> Unit) - State hook with direct and functional updates
    • use_reducer_with_initial[S, A](initial: S, reducer: (S, A) -> S) -> (S, (A) -> Unit) - Reducer hook for any explicit state type
    • use_reducer[S: Default, A](initial?: S, reducer: (S, A) -> S) -> (S, (A) -> Unit) - Reducer hook
    • use_effect_once(effect: () -> Unit) -> Unit - Effect hook that runs only once
    • use_effect_cleanup_deps(effect: () -> () -> Unit, deps: Array[JsObscure]) -> Unit - Effect hook with a cleanup function
    • use_effect_once_with_cleanup(effect: () -> () -> Unit) -> Unit - One-time effect with a cleanup function
    • use_effect_deps(effect: () -> Unit, deps: Array[JsObscure]) -> Unit - Effect hook with dependencies
    • use_layout_effect_deps(effect: () -> Unit, deps: Array[JsObscure]) -> Unit - Layout effect hook
    • use_memo_deps[A](factory: () -> A, deps: Array[JsObscure]) -> A - Memoization hook
    • use_callback_deps[F](callback: F, deps: Array[JsObscure]) -> F - Callback memoization hook
    • use_effect_event[F](callback: F) -> F - React 19.2 effect-only callback that reads latest state without re-subscribing an effect
    • use_action_state[S, A](initial: S, action: (S, A) -> S) -> (S, (A) -> Unit, Bool) - React 19 action state, dispatch, and pending flag
    • use_async_action_state[S, A](initial: S, action: async (S, A) -> S) -> (S, (A) -> Unit, Bool) - Export a MoonBit async reducer as a Promise-returning React Action
    • use_optimistic[S, A](value: S, reducer: (S, A) -> S) -> (S, (A) -> Unit) - Temporary optimistic state scoped to a React Action
    • use_form_status() -> FormStatus - Read pending data, method, and action from the nearest parent form
    • use_callback0_deps(f: () -> Unit, deps: Array[JsObscure]) -> () -> Unit - Zero-argument callback hook
    • use_ref[T](initial: T) -> ReactRef[T] - Reference hook
    • use_dom_ref() -> ReactDomRef - Nullable DOM-element ref hook whose current() value is None before mount and after unmount
    • use_id() -> String - Stable component-local identifier hook
    • use_deferred_value[T](value: T) -> T - Deferred-value hook for non-urgent rendering
    • use_transition() -> (Bool, (() -> Unit) -> Unit) - Transition state and starter hook
    • start_transition(action: () -> Unit) -> Unit - Start a transition when pending state is not needed
    • use_sync_external_store[T](subscribe, get_snapshot, get_server_snapshot?) -> T - Read and subscribe to a typed immutable external-store snapshot
    • use_imperative_ref[T]() -> ImperativeRef[T] - Create a nullable typed ref for a custom component handle
    • use_imperative_handle_deps[T](ref: ImperativeRef[T], create_handle: () -> T, deps: Array[JsObscure]) -> Unit - Expose a typed React 19 imperative handle
    • obscure[T](v: T) -> JsObscure - Dependency conversion helper function

    #HTML Element Bindings

    • div, span, p, h1, h2, h3 - Basic text elements
    • form, button, input, textarea, select, option - Form elements
    • a, img, video, audio - Media and link elements
    • ul, ol, li - List elements
    • section, article, header, footer, nav, aside - Semantic elements
    • label - Label element
    • Generated table helpers: table, caption, colgroup, col, thead, tbody, tfoot, tr, th, and td
    • Generated form and interactive helpers: fieldset, legend, datalist, optgroup, output, progress, meter, dialog, details, and summary
    • Generated React 19 metadata helpers: title, meta, link, style_tag, and script_tag
    • Generated core SVG helpers include svg, g, defs, symbol, path, circle, ellipse, rect, line, gradients, clipping/masking, text, and use_

    The generated set contains 54 helpers across six categories. Every generated helper includes typed common role, title, tab_index, hidden, aria_label, and data_testid props plus the applicable tag-specific props. SVG and metadata names use React camel case at the JavaScript boundary, such as viewBox, strokeWidth, httpEquiv, and xlinkHref.

    #Event Handling

    DOMEventType covers clipboard, composition, keyboard, mouse, pointer, wheel, form, drag, touch, media, animation, and transition events. It maps each value to React's camel-cased onXxx property automatically.

    • DOMEvent type and its methods:
      • target_value() -> String - Get form element value
      • target_checked() -> Bool - Get checkbox or radio checked state
      • key() -> String, key_code() -> Int - Keyboard events
      • client_x() -> Int, client_y() -> Int - Mouse coordinates
      • prevent_default(), stop_propagation() - Event control
      • ctrl_key(), shift_key(), alt_key(), meta_key() -> Bool - Modifier key detection

    #Styles and Attributes

    • ElementAttrs - HTML attribute management, including typed string, boolean, integer, floating-point, and JavaScript-value setters
    • ElementEvents - Event handler management
    • RespoStyle - CSS styles (from @css module)
    • InputType enum - Support for all HTML input types
    • StateUpdate[T] - Set(value) or Update(fn(previous) { ... }) for safely deriving state from the latest React value

    innerHTML parameters are converted to React's dangerouslySetInnerHTML API. Only pass trusted, sanitized HTML through this escape hatch. Combining innerHTML with children is rejected before the element reaches React.

    Use ElementAttrs::set for string attributes, set_bool for React boolean properties such as disabled, set_int for integral properties such as rows, and set_float for fractional numeric properties such as progress and meter values. The built-in element helpers use these typed conversions automatically. Use set_js_value only for explicit React values such as a DOM ref: attrs.set_js_value("ref", input_ref.to_js_obscure()). For controlled checkbox or radio inputs, use input(checked=value) so both true and false reach React as booleans. Use default_value and default_checked for uncontrolled form elements; combining them with value or checked is rejected. For DOM elements, prefer use_dom_ref() and attach its JavaScript ref object through set_js_value. ReactDomRef::current() returns Some(element) only while the element is mounted. Controlled fields require on_change, or an explicit read_only=true or disabled=true state. A multiple=true select uses the values or default_values array parameters; individual options do not accept selected.

    React 19 function Actions use the typed FormAction wrapper. Wrap the ReactFormData dispatcher returned by use_action_state or use_async_action_state with form_action(dispatch), or convert a direct MoonBit async form function with async_form_action. Pass the result through form(action=...), button(form_action=...), or a submit/image input(form_action=...). use_form_status must run in a child component below the form it observes. The async bridge is pinned to moonbitlang/async@0.20.3, the newest release compatible with this repository's pinned MoonBit compiler.

    declare_contained_style is deprecated; use contained_static_style instead. ReactRef::from is deprecated because its constructor-like name hides a Hook call; use use_ref or use_dom_ref at the top level of a component.

    Static-style declarations are safe during server-side rendering or pre-rendering: without a browser document they return their deterministic class name without injecting a tag. The browser's module evaluation then performs the injection.

    #React DOM Operational APIs

    flush_sync is a last-resort integration escape hatch. It guarantees that updates scheduled inside its callback are reflected in the DOM by the next line, but it may also flush pending work, run Effects, or reveal Suspense fallbacks. Use it in an event or browser/third-party callback only; do not call it while React is rendering or running an Effect, and do not replace normal React batching with it.

    The six resource-hint helpers mirror React 19.2:

    • prefetch_dns resolves a host speculatively; preconnect additionally asks the browser to open an early connection.
    • preload and preload_module download a classic resource or ESM module without applying/evaluating it.
    • preinit and preinit_module download and immediately apply a stylesheet or evaluate a classic/ESM script when ready.

    Use PreloadOptions::new with a typed PreloadDestination. Fetch destinations must supply cross_origin; the image source-set and sizes fields are image-only. Use PreinitOptions::script or PreinitOptions::style; the style constructor requires typed precedence so a required React option cannot be omitted. Module hints always use as: "script" internally.

    React deduplicates equivalent hints. Browser calls may be made during render, Effects, or events; server-rendered hints only take effect during component rendering or async work originating from it. Frameworks commonly manage resource discovery, ordering, and deduplication already, so consult the framework documentation before calling these APIs directly.

    #Portals, Roots, and SSR Scope

    create_portal changes physical DOM placement only: context and events still follow the owning React tree. render_with_options applies its options only when it creates a root; later calls for the same parent reuse that root.

    The supported SSR/SSG paths are deliberately explicit:

    • render_to_string is a synchronous react-dom/server binding.
    • render_to_readable_stream resolves when the shell is ready and supports progressive Suspense output on runtimes that implement Web Streams and AbortController.
    • wait_all_ready delays static generation until all suspended content is ready; read_text and to_js_readable_stream expose the same one-shot body, so choose one consumption path.
    • abort cancels pending server work and leaves unresolved boundaries for client recovery. Use StreamRenderOptions::new(on_error=...) to observe server failures.
    • hydrate_root requires markup identical to the initial client tree.
    • identifier_prefix must be identical between either server renderer and RootOptions::new when the tree uses use_id.
    • React Server Components and framework routing/data protocols are not provided.

    For a server or build entry, initialize only the renderer globals it needs:

    import * as React from "react"; import * as ReactDOMServer from "react-dom/server"; globalThis.React = React; globalThis.ReactDOMServer = ReactDOMServer;

    Then initialize React, ReactDOM, and ReactDOMClient in the browser entry before calling hydrate_root. Do not bundle react-dom/server into ordinary client code merely to hydrate markup that was already generated on the server.

    #External Stores and Component Integration

    use_sync_external_store follows React's immutable snapshot contract. Keep the subscribe function stable across renders, return an unsubscribe callback, and return the same snapshot value while the store has not changed. When rendering on the server, provide get_server_snapshot and return the same initial value during hydration.

    ReactComponent[T] carries a single typed MoonBit props value. A component created through component_from_js receives that value as props.moonbitProps; this explicit carrier avoids spreading or depending on MoonBit's generated JavaScript object representation. memo compares this single value with Object.is by default, or receives previous and next typed values in its custom comparator.

    Declare memoized and lazy components outside ordinary render paths. A lazy_component loader resolves to ReactComponent[T]; React caches both the loader Promise and its resolved component. Render it below suspense so a fallback is visible while loading.

    React 19 makes refs available as component props, so this binding intentionally does not add a new forwardRef wrapper. Pass ImperativeRef[T] through typed props and call use_imperative_handle_deps in the child. current() returns None before commit and after cleanup. Prefer declarative props whenever the behavior does not genuinely require an imperative handle.

    #Resources and local errors / 资源与局部错误

    Create a ReactResource[T] outside component render with resource_from_promise or resource_from_async, then call use_resource while rendering below suspense. Reuse the same resource identity across retries; creating a new Promise during every render repeatedly suspends and triggers React's uncached-Promise warning. Rejections flow to the nearest error_boundary. Change its reset_key after selecting a new cached resource to retry. The optional on_error receives React's component stack; root error callbacks remain separate observability hooks. Error Boundaries do not catch event-handler failures or arbitrary asynchronous errors outside render.

    请在组件 render 之外通过 resource_from_promiseresource_from_async 创建 ReactResource[T],并在 suspense 内调用 use_resource。重试时必须复用 稳定 resource;每次 render 新建 Promise 会反复 suspend,并触发 React 的 uncached-Promise warning。rejection 会进入最近的 error_boundary;选择新的缓存 resource 后改变 reset_key 即可重试。on_error 用于局部组件栈观测,root error callback 仍是独立观测点。Error Boundary 不捕获事件处理器或 render 外任意异步错误。

    #Activity / 活动边界

    activity(ActivityMode::Hidden, children) keeps its child state and DOM tree, but React hides that DOM with display: none, cleans up Effects, and deprioritizes hidden updates. Switching the same boundary back to Visible restores the preserved state and remounts Effects. Use stable child keys when an Activity contains dynamic collections.

    activity(ActivityMode::Hidden, children) 会保留子组件 state 与 DOM 树,但 React 会用 display: none 隐藏 DOM、清理 Effects,并降低隐藏更新的优先级。 切回 Visible 后,原 state 会恢复且 Effects 会重新挂载;动态列表仍需使用稳定 key。

    #Virtual DOM Types

    • VirtualNode - Base virtual node type
    • VirtualElement - Virtual element type
    • Text(String) - Text node

    #Quick Start

    Before writing any MoonBit code, make sure to include the React bindings in your project.

    import * as React from "react"; import * as ReactDOM from "react-dom"; import * as ReactDOMClient from "react-dom/client"; globalThis.React = React; globalThis.ReactDOM = ReactDOM; globalThis.ReactDOMClient = ReactDOMClient;

    Here's a simple example of how to use this library:

    // Define your component props
    struct ContainerProps {} derive(Default)

    // Create a functional component
    fn comp_container(_v : ContainerProps) -> @react.VirtualNode {
    let (counter, set_counter) = @react.use_state(Float::from_double(0.0))

    @react.div(
    id="container",
    style=@css.respo_style(
    color=@css.CssColor::Blue,
    font_family="Arial",
    padding=@css.CssSize::Px(10.0),
    ),
    on_click=fn(_) {
    println("clicked \{counter}")
    set_counter(counter + 1.0)
    },
    [
    @react.Fragment([@react.Text("Demo: ")]),
    @react.Text("Counter \{counter}")
    ],
    )
    }

    // Render to DOM
    fn main {
    let window = @dom.window()
    let doc = window.document()
    let body = doc.body()
    let props : ContainerProps = Default::default()

    @react.render(
    @react.component(comp_container, props, []),
    body,
    )
    println("loaded")
    }

    #Features

    • Type-safe virtual DOM construction
    • React-style hooks (useState)
    • CSS-in-JS styling support
    • Event handling
    • Component composition

    #Development

    The package follows the current MoonBit manifest format (moon.mod and moon.pkg). To run the checks locally:

    moon check moon test moon info corepack yarn install --frozen-lockfile corepack yarn generate:dom corepack yarn check:generated corepack yarn check:docs corepack yarn test:server corepack yarn build corepack yarn test:browser

    CI pins MoonBit compiler 0.10.4+2cc641edf and validates Node 22 with Yarn 1.22.22. check:docs automatically discovers explicit public declarations in the library package instead of relying on an API allowlist; the current gate requires all 228 declarations to carry doc comments. test:server covers progressive Suspense chunks, all-ready static output, abort/error behavior, bootstrap metadata, and identifier prefixes against the real React server renderer. test:browser runs deterministic TodoMVC and React runtime conformance flows in Chromium, including StrictMode lifecycle, batching, root reuse, DOM ref cleanup, async form Actions, form status, optimistic rollback, portals, root error callbacks, synchronous and Web Stream server rendering, hydration, external-store subscription lifecycles, memo/lazy/Suspense, typed JavaScript interoperation, imperative handles, Activity state/Effect lifecycles, cached resources and local Error Boundary retry paths, and generated HTML/SVG/metadata DOM behavior; install it once locally with yarn playwright install chromium. Update the toolchain pin only through the full check, unit-test, interface, browser-test, and browser-build matrix. This revision was verified with MoonBit 0.1.20260713, React 19.2.8, and Vite 8.2.x.

    The browser entry point loads React, ReactDOM, ReactDOMClient, and the demo-only server renderer before the generated MoonBit application. render can be called again for the same parent element; the binding reuses its React root rather than creating a second one.

    #Release

    Prepare releases on a branch by aligning moon.mod, package.json, the dated Changelog section, and bilingual release-notes/vX.Y.Z.md. Run yarn check:release; it requires exact version agreement, complete historical tag coverage, an empty Unreleased section, and an exact 18-file package allowlist.

    After the preparation PR is merged, create an annotated vX.Y.Z tag on main, then create and publish a GitHub Release whose title exactly matches that tag. The release.published event triggers Publish release. It verifies tag identity and main ancestry, generated sources, MoonBit check/test/interface/format results, real Chromium conformance, the browser build, and the package allowlist before uploading the archive and SHA256SUMS to the Release.

    The same workflow publishes to mooncakes.io using the repository or inherited organization Secret MOON_CREDENTIALS; registry credentials never leave the ephemeral Actions runner. The publish command intentionally is not frozen: MoonBit validates the archive from a fresh extracted module that must install its declared dependencies. All source/package inputs are frozen and checked by the preceding release gates. The workflow then resolves tiye/react@X.Y.Z from a fresh temporary consumer, runs JS check/build, verifies exact Node SSR output, and exercises client render, DOM-reusing hydration, and post-hydration state updates in Chromium. It requires zero browser diagnostics and preserves the exact logs as an Actions artifact. A release is not complete until this downstream runtime check passes.

    Release source is always checked out from the immutable tag. The downstream verifier is sparse-checked out separately from github.workflow_sha, so a verifier bug can be corrected without changing or republishing tagged source.

    Use the workflow's workflow_dispatch input only to recover or verify an already-published GitHub Release, such as one created before the workflow was installed. The separate Verify published package workflow remains available for registry-only rechecks.

    #License

    Apache 2.0

    ActivityMode

    pub(all) enum ActivityMode {
    Visible
    Hidden
    } derive(Eq)

    React 19.2 Activity visibility modes.

    ActivityMode::to_string

    fn ActivityMode::to_string(self : ActivityMode) -> String

    Returns the React mode property for this Activity mode.

    DOMEvent

    pub type DOMEvent

    An opaque React synthetic event passed to MoonBit event handlers.

    Use the typed accessors where available or to_js_obscure as an escape hatch for event fields that do not yet have a binding.

    DOMEvent::alt_key

    fn DOMEvent::alt_key(self : DOMEvent) -> Bool

    检查是否按下了 Alt 键

    DOMEvent::client_x

    fn DOMEvent::client_x(self : DOMEvent) -> Int

    获取鼠标事件的 X 坐标

    DOMEvent::client_y

    fn DOMEvent::client_y(self : DOMEvent) -> Int

    获取鼠标事件的 Y 坐标

    DOMEvent::ctrl_key

    fn DOMEvent::ctrl_key(self : DOMEvent) -> Bool

    检查是否按下了 Ctrl 键

    DOMEvent::key

    fn DOMEvent::key(self : DOMEvent) -> String

    获取键盘事件的键值

    DOMEvent::key_code

    fn DOMEvent::key_code(self : DOMEvent) -> Int

    获取键盘事件的键码

    DOMEvent::meta_key

    fn DOMEvent::meta_key(self : DOMEvent) -> Bool

    检查是否按下了 Meta 键(Mac 上的 Cmd 键)

    DOMEvent::native_event

    fn DOMEvent::native_event(self : DOMEvent) -> NativeEvent

    Returns an explicit view of the browser event wrapped by this React SyntheticEvent. This view is intentionally distinct from DOMEvent: use native_pointer_event or native_wheel_event to obtain a checked dom-ffi event-family value.

    DOMEvent::native_pointer_event

    fn DOMEvent::native_pointer_event(self : DOMEvent) ->
    PointerEvent
    ?

    Returns the checked dom-ffi PointerEvent carried by this React event, or None when the handler received another event family.

    DOMEvent::native_wheel_event

    fn DOMEvent::native_wheel_event(self : DOMEvent) ->
    WheelEvent
    ?

    Returns the checked dom-ffi WheelEvent carried by this React event, or None when the handler received another event family.

    DOMEvent::prevent_default

    fn DOMEvent::prevent_default(self : DOMEvent) -> Unit

    阻止事件的默认行为

    DOMEvent::shift_key

    fn DOMEvent::shift_key(self : DOMEvent) -> Bool

    检查是否按下了 Shift 键

    DOMEvent::stop_propagation

    fn DOMEvent::stop_propagation(self : DOMEvent) -> Unit

    阻止事件冒泡

    DOMEvent::target_checked

    fn DOMEvent::target_checked(self : DOMEvent) -> Bool

    Returns whether the event target is checked. This is intended for controlled checkbox and radio inputs; non-checkable targets return false.

    DOMEvent::target_value

    fn DOMEvent::target_value(self : DOMEvent) -> String

    获取事件目标元素的值(通常用于 input、textarea 等表单元素)

    DOMEvent::to_js_obscure

    Returns the underlying React synthetic event for advanced JavaScript interop.

    DOMEventType

    pub(all) enum DOMEventType {
    Copy
    Cut
    Paste
    CompositionEnd
    CompositionStart
    CompositionUpdate
    Click
    DoubleClick
    MouseDown
    MouseUp
    MouseMove
    MouseEnter
    MouseLeave
    MouseOver
    MouseOut
    ContextMenu
    PointerDown
    PointerMove
    PointerUp
    PointerCancel
    PointerEnter
    PointerLeave
    PointerOver
    PointerOut
    GotPointerCapture
    LostPointerCapture
    KeyDown
    KeyUp
    KeyPress
    BeforeInput
    Input
    Change
    Submit
    Reset
    Focus
    Blur
    Select
    Load
    Unload
    Resize
    Scroll
    Wheel
    Drag
    DragStart
    DragEnd
    DragEnter
    DragLeave
    DragOver
    Drop
    TouchStart
    TouchMove
    TouchEnd
    TouchCancel
    Error
    Abort
    CanPlay
    CanPlayThrough
    DurationChange
    Ended
    LoadedData
    LoadedMetadata
    LoadStart
    Pause
    Play
    Playing
    Progress
    RateChange
    Seeked
    Seeking
    Stalled
    Suspend
    TimeUpdate
    VolumeChange
    Waiting
    AnimationStart
    AnimationEnd
    AnimationIteration
    TransitionEnd
    Invalid
    Toggle
    Cancel
    Close
    } derive(Compare, Eq, Hash)

    DOM 事件类型枚举

    DOMEventType::to_string

    fn DOMEventType::to_string(self : DOMEventType) -> String

    将 DOMEventType 转换为字符串

    ElementAttrs

    pub struct ElementAttrs(Map[String, ElementPropValue]) derive(Default)

    A mutable collection of React element properties.

    Use the typed setters for primitive values and set_js_value only for values such as refs that are already represented as JavaScript objects.

    ElementAttrs::add

    fn ElementAttrs::add(self : ElementAttrs, key : String, value : String) -> ElementAttrs

    Adds a string-valued React property and returns the same attribute map.

    ElementAttrs::new

    Creates an empty React element-property collection.

    ElementAttrs::set

    fn ElementAttrs::set(self : ElementAttrs, key : String, value : String) -> Unit

    Sets a string-valued React property.

    ElementAttrs::set_bool

    fn ElementAttrs::set_bool(self : ElementAttrs, key : String, value : Bool) -> Unit

    Sets a boolean React property without converting it to a string.

    ElementAttrs::set_float

    fn ElementAttrs::set_float(self : ElementAttrs, key : String, value : Float) -> Unit

    Sets a floating-point React property without converting it to a string.

    ElementAttrs::set_int

    fn ElementAttrs::set_int(self : ElementAttrs, key : String, value : Int) -> Unit

    Sets an integer React property without converting it to a string.

    ElementAttrs::set_js_value

    fn ElementAttrs::set_js_value(self : ElementAttrs, key : String, value :
    JsObscure
    ) -> Unit

    Sets an explicitly pre-converted JavaScript property. Use this escape hatch for React values such as ref that cannot be represented as strings, booleans, or integers.

    ElementEvents

    type ElementEvents derive(Default)

    ElementEvents::add

    fn ElementEvents::add(self : ElementEvents, event_type : DOMEventType, value : (DOMEvent) -> Unit) -> ElementEvents

    使用 DOMEventType 添加事件处理器

    ElementEvents::new

    Creates an empty mapping from DOM event types to React event handlers.

    ElementEvents::set

    fn ElementEvents::set(self : ElementEvents, event_type : DOMEventType, value : (DOMEvent) -> Unit) -> Unit

    使用 DOMEventType 设置事件处理器

    ElementEvents::to_js_value

    Converts this event map to a JavaScript React-props object whose keys use handler names such as onClick.

    ElementPropValue

    type ElementPropValue

    FormAction

    type FormAction

    A typed React action or formAction property.

    FormStatus

    type FormStatus

    Status for the nearest parent React form. A component calling this Hook must be rendered below the form rather than in the same component that creates it.

    FormStatus::action

    fn FormStatus::action(self : FormStatus) -> FormAction?

    Returns the Action function associated with the pending submission, or None when the parent form has no active Action submission.

    FormStatus::data

    fn FormStatus::data(self : FormStatus) -> ReactFormData?

    Returns the submitted data while the parent form Action is pending.

    FormStatus::pending

    fn FormStatus::pending(self : FormStatus) -> Bool

    Returns whether the nearest parent form Action is currently pending.

    FormStatus::submission_method

    fn FormStatus::submission_method(self : FormStatus) -> String

    Returns the HTTP method used by the pending parent-form submission. React reports "get" when no active submission supplies another method.

    ImperativeRef

    type ImperativeRef[T]

    A nullable typed ref for a custom imperative component handle.

    ImperativeRef::current

    fn[T] ImperativeRef::current(self : ImperativeRef[T]) -> T?

    Returns the committed handle, or None before mount and after cleanup.

    ImperativeRef::to_js_obscure

    Returns the underlying React ref object for an explicit JavaScript bridge.

    InputType

    pub(all) enum InputType {
    Button
    Checkbox
    Color
    Date
    DatetimeLocal
    Email
    File
    Hidden
    Image
    Month
    Number
    Password
    Radio
    Range
    Reset
    Search
    Submit
    Tel
    Text
    Time
    Url
    Week
    } derive(Eq)

    HTML input element type enumeration based on MDN specification https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input

    InputType::to_string

    fn InputType::to_string(self : InputType) -> String

    Converts InputType enum to its corresponding HTML string value

    ModuleHintOptions

    type ModuleHintOptions

    Shared typed options for ESM module preload and preinit hints. React always receives as: "script"; callers configure only CORS and security metadata.

    ModuleHintOptions::new

    fn ModuleHintOptions::new(cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String) -> ModuleHintOptions

    Creates ESM resource-hint options shared by preload_module and preinit_module. Repeated calls with the same URL are deduplicated by React, regardless of how many times the wrapper is invoked.

    NativeEvent

    #external
    pub type NativeEvent

    An opaque view of the browser event associated with a React SyntheticEvent.

    It is not a React SyntheticEvent and only exposes checked conversions to specific dom-ffi event families.

    NativeEvent::pointer_event

    Returns a dom-ffi PointerEvent when this native event has the required pointer payload. The structural check keeps non-pointer React handlers from being reinterpreted as pointer events.

    NativeEvent::wheel_event

    Returns a dom-ffi WheelEvent when this native event has the required wheel payload. Non-wheel React handlers receive None instead of an unchecked cast.

    PreinitOptions

    type PreinitOptions

    Typed options for React DOM preinit of classic scripts or stylesheets. Use the dedicated constructors so stylesheet precedence cannot be omitted.

    PreinitOptions::script

    fn PreinitOptions::script(cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String, fetch_priority? : ResourceFetchPriority) -> PreinitOptions

    Creates preinit options for a classic external script. The resource is fetched and executed when ready; use preload when execution should wait.

    PreinitOptions::style

    fn PreinitOptions::style(precedence : ResourceStylePrecedence, cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String, fetch_priority? : ResourceFetchPriority) -> PreinitOptions

    Creates preinit options for a stylesheet. precedence is mandatory and determines its order relative to other React-managed stylesheets.

    PreloadDestination

    pub(all) enum PreloadDestination {
    Audio
    Document
    Embed
    Fetch
    Font
    Image
    Object
    Script
    Style
    Track
    Video
    Worker
    } derive(Eq)

    Valid as destinations for preload according to React 19.2. Select the destination that matches how the browser will consume the URL.

    PreloadOptions

    type PreloadOptions

    Typed options for React DOM preload. Image-only fields are meaningful only with PreloadDestination::Image.

    PreloadOptions::new

    fn PreloadOptions::new(destination : PreloadDestination, cross_origin? : ResourceCrossOrigin, referrer_policy? : ResourceReferrerPolicy, integrity? : String, mime_type? : String, nonce? : String, fetch_priority? : ResourceFetchPriority, image_src_set? : String, image_sizes? : String) -> PreloadOptions

    Creates options for preload.

    destination is required by React. Fetch resources must also provide a cross_origin policy. image_src_set and image_sizes apply only to Image; equivalent image hints are deduplicated by URL, source set, and sizes, while other destinations are deduplicated by URL. Construction aborts when Fetch is selected without cross_origin.

    ReactComponent

    type ReactComponent[T]

    A stable React component type carrying one typed MoonBit props value.

    Render it with ReactComponent::render. JavaScript component bridges receive the typed value in a single moonbitProps property rather than relying on the generated representation being spread into JavaScript props.

    ReactComponent::memo

    fn[T] ReactComponent::memo(self : ReactComponent[T], are_props_equal? : (T, T) -> Bool) -> ReactComponent[T]

    Returns a memoized component. Without are_props_equal, React compares the single typed moonbitProps value with Object.is; a custom comparator receives the previous and next MoonBit values directly.

    ReactComponent::render

    fn[T] ReactComponent::render(self : ReactComponent[T], props : T) -> VirtualNode

    Renders this component with one typed MoonBit props value.

    ReactComponent::to_js_obscure

    Returns the underlying React component type for explicit JavaScript interoperation.

    ReactContext

    type ReactContext[T]

    A typed handle to a React Context object.

    ReactContext::provider

    fn[T] ReactContext::provider(self : ReactContext[T], value : T, children : Array[VirtualNode]) -> VirtualNode

    Provides value to descendant components without adding a DOM wrapper.

    ReactContext::to_js_obscure

    Returns the underlying Context object for explicit JavaScript interoperation.

    ReactDomRef

    type ReactDomRef

    A DOM element ref whose current value is absent before mount and after unmount. Attach it with ElementAttrs::set_js_value("ref", ref.to_js_obscure()).

    ReactDomRef::current

    Returns the mounted DOM element, or None before mount and after unmount.

    ReactDomRef::to_js_obscure

    Returns the underlying React ref object for an explicit ref prop.

    ReactError

    #external
    pub type ReactError

    The JavaScript error passed to a React root error callback.

    ReactError::message

    fn ReactError::message(self : ReactError) -> String

    Returns the JavaScript Error message reported by React.

    ReactErrorInfo

    #external
    pub type ReactErrorInfo

    Metadata passed to a React root error callback.

    ReactErrorInfo::component_stack

    fn ReactErrorInfo::component_stack(self : ReactErrorInfo) -> String

    Returns the React component stack associated with a root error.

    ReactFormData

    #external
    pub type ReactFormData

    The browser FormData payload supplied to React form Actions.

    Convert it with to_dom_form_data when the complete file-aware dom-ffi FormData API is needed.

    ReactFormData::get_string

    fn ReactFormData::get_string(self : ReactFormData, key : String) -> String?

    Returns a string form field, or None when the field is absent or is a non-string value such as a File.

    ReactFormData::to_dom_form_data

    Returns the same browser object as dom-ffi FormData, without copying its entries. This preserves the React Action callback API while exposing file-aware FormData operations.

    ReactReadableStream

    type ReactReadableStream

    A React 19.2 server-rendered Web Stream and its abort controller. Reading the stream transfers its one-shot body ownership to the consumer.

    ReactReadableStream::abort

    fn ReactReadableStream::abort(self : ReactReadableStream, reason? : String) -> Unit

    Aborts pending server work. React emits the nearest Suspense fallbacks and leaves unfinished content for the client to render.

    ReactReadableStream::read_text

    async fn ReactReadableStream::read_text(self : ReactReadableStream) -> String

    Consumes the entire stream as UTF-8 HTML. A stream body can be consumed only once; use to_js_readable_stream for direct Web API integration instead.

    ReactReadableStream::to_js_readable_stream

    Returns the underlying one-shot Web ReadableStream for a Response or other JavaScript server-runtime integration.

    ReactReadableStream::wait_all_ready

    async fn ReactReadableStream::wait_all_ready(self : ReactReadableStream) -> Unit

    Waits until the shell and every suspended boundary are ready. Use this for crawlers or static generation when progressive delivery is unnecessary.

    ReactRef

    type ReactRef[T]

    ReactRef::from

    #deprecated("This function is deprecated.")
    fn[T] ReactRef::from(initial : T) -> ReactRef[T]

    Deprecated Hook-shaped constructor for ReactRef.

    Despite its constructor-like name, this calls React useRef and therefore must only run at the top level of a component or another Hook. Use use_ref(initial) instead, or use_dom_ref() for nullable DOM refs.

    ReactRef::get

    fn[T] ReactRef::get(self : ReactRef[T]) -> T

    Returns the current value stored in this React ref.

    ReactRef::set

    fn[T] ReactRef::set(self : ReactRef[T], value : T) -> Unit

    Replaces the current value stored in this React ref.

    ReactRef::to_js_obscure

    fn[T] ReactRef::to_js_obscure(self : ReactRef[T]) ->
    JsObscure

    Returns the underlying React ref object for an explicit JavaScript property, for example attrs.set_js_value("ref", input_ref.to_js_obscure()).

    ReactResource

    type ReactResource[T]

    A typed, identity-stable Promise resource for React 19 use.

    Create resources outside render paths and reuse the same value across retries. Recreating a Promise during render causes repeated suspension and a React uncached-Promise warning.

    ReactResource::to_js_obscure

    Returns the cached JavaScript Promise for explicit interoperation.

    ResourceCrossOrigin

    pub(all) enum ResourceCrossOrigin {
    Anonymous
    UseCredentials
    } derive(Eq)

    Cross-origin policies supported by React DOM resource hints. Anonymous omits credentials, while UseCredentials includes them.

    ResourceFetchPriority

    pub(all) enum ResourceFetchPriority {
    Auto
    High
    Low
    } derive(Eq)

    Browser fetch priorities supported by React DOM resource hints. This is a hint only; the browser retains control over actual scheduling.

    ResourceReferrerPolicy

    pub(all) enum ResourceReferrerPolicy {
    NoReferrerWhenDowngrade
    NoReferrer
    Origin
    OriginWhenCrossOrigin
    UnsafeUrl
    } derive(Eq)

    Referrer policies accepted by React 19.2's preload options.

    ResourceStylePrecedence

    pub(all) enum ResourceStylePrecedence {
    Reset
    Low
    Medium
    High
    } derive(Eq)

    Stylesheet precedence levels supported by React 19.2 preinit. Higher levels are inserted so they can override lower-precedence styles.

    RootOptions

    type RootOptions

    Configuration shared by createRoot and hydrateRoot.

    RootOptions::new

    fn RootOptions::new(identifier_prefix? : String, on_caught_error? : (ReactError, ReactErrorInfo) -> Unit, on_uncaught_error? : (ReactError, ReactErrorInfo) -> Unit, on_recoverable_error? : (ReactError, ReactErrorInfo) -> Unit) -> RootOptions

    Creates root options matching React 19's root error and identifier options. identifier_prefix must match the server renderer during hydration.

    StateUpdate

    pub(all) enum StateUpdate[T] {
    Set(T)
    Update((T) -> T)
    }

    Represents a React state update. Set replaces state directly and Update calculates the next state from React's current value.

    StreamRenderOptions

    type StreamRenderOptions

    Options for React 19.2 Web Streams server rendering.

    StreamRenderOptions::new

    fn StreamRenderOptions::new(identifier_prefix? : String, bootstrap_scripts? : Array[String], bootstrap_modules? : Array[String], nonce? : String, on_error? : (ReactError) -> Unit) -> StreamRenderOptions

    Creates options for render_to_readable_stream. identifier_prefix must match the client RootOptions during hydration.

    VirtualElement

    pub struct VirtualElement {
    name : String
    attrs : ElementAttrs
    event : ElementEvents
    style :
    RespoStyle

    children : Array[VirtualNode]
    }

    Represents a virtual DOM element with all its properties and children.

    This structure encapsulates all the information needed to create and manage a DOM element in the virtual DOM tree, including its tag name, attributes, event handlers, styles, and child nodes.

    VirtualElement::to_node

    Wraps this virtual element as a general VirtualNode.

    VirtualNode

    pub(all) enum VirtualNode {
    Element(VirtualElement)
    Fragment(Array[VirtualNode])
    Text(String)
    JsNode(
    JsObscure
    )
    }

    Represents a virtual DOM node in the React rendering system.

    This is the core type for building virtual DOM trees. Each variant represents a different kind of node that can be rendered to the actual DOM.

    VirtualNode::to_js_obscure

    Converts a virtual node into the JavaScript value consumed by React.

    Most applications pass virtual nodes to render, component, or another element helper instead of calling this interop method directly.

    VirtualNode::with_key

    fn VirtualNode::with_key(self : VirtualNode, key : String) -> VirtualNode

    Assigns a stable React reconciliation key to a virtual node.

    This works uniformly for elements, components, fragments, and text without adding a DOM wrapper. Use stable application identities rather than list indexes when rendering dynamic collections.
    fn a(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, href? : String, target? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an a element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an a element.

    activity

    fn activity(mode : ActivityMode, children : Array[VirtualNode]) -> VirtualNode

    Creates a React 19.2 Activity boundary.

    A hidden Activity keeps its children and their state while hiding their DOM, cleans up their Effects, and deprioritizes their updates. Restoring it to Visible remounts those Effects without resetting child state.

    address

    fn address(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the address semantic element.

    article

    fn article(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an article element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an article element.

    aside

    fn aside(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an aside element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an aside element.

    async_form_action

    fn async_form_action(action : async (ReactFormData) -> Unit) -> FormAction

    Converts a MoonBit async form Action into a JavaScript Promise-returning React Action. Rejections are forwarded to React by the official moonbitlang/async/js_async bridge.

    audio

    fn audio(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], src? : String, controls? : Bool, autoplay? : Bool, loop_enabled? : Bool, muted? : Bool, on_play? : (DOMEvent) -> Unit, on_pause? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an audio element with the specified attributes, event handlers, and audio properties.

    Returns a virtual DOM node representing an audio element.

    blockquote

    fn blockquote(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cite? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the blockquote semantic element.

    button

    fn button(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, button_type? : String, name? : String, value? : String, disabled? : Bool, form_action? : FormAction, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a button element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a button element.

    caption

    fn caption(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the caption table element.

    circle

    fn circle(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, r? : String, fill? : String, stroke? : String, stroke_width? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the circle svg element.

    clip_path

    fn clip_path(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the clipPath svg element.

    code

    fn code(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the code semantic element.

    col

    fn col(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the col table element.

    colgroup

    fn colgroup(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the colgroup table element.

    component

    fn[T] component(f : (T) -> VirtualNode, props : T, children : Array[VirtualNode]) -> VirtualNode

    Creates a component virtual node from a function, props, and children.

    This bridges MoonBit component functions with React's rendering system, enabling type-safe component creation with strongly-typed props.

    Example

    struct ButtonProps {
    text : String
    disabled : Bool
    } derive(Default)

    fn my_button(props : ButtonProps) -> VirtualNode {
    button(disabled=props.disabled, [Text(props.text)])
    }

    let node = component(my_button, ButtonProps { text: "Click me", disabled: false }, [])

    component_from_js

    fn[T] component_from_js(component :
    JsObscure
    ) -> ReactComponent[T]

    Declares the expected MoonBit props type for a trusted JavaScript React component. The JavaScript component receives { moonbitProps } and the rendered value remains a JsNode escape hatch.

    component_with_children

    fn[T] component_with_children(f : (T, Array[VirtualNode]) -> VirtualNode, props : T, children : Array[VirtualNode]) -> VirtualNode

    Creates a component virtual node whose function receives the child nodes.

    Use this when a component needs to decide where to place its children. The existing component function remains the concise choice for leaf components.

    console_log2

    fn console_log2(msg : String, v :
    JsObscure
    ) -> Unit

    Logs a message and an opaque JavaScript value to the browser console.

    This is a low-level debugging helper; application rendering must not depend on its side effect.

    contained_static_style

    #callsite(autofill(loc))
    fn[U : Show] contained_static_style(rules : Array[(String?, U,
    RespoStyle
    )], loc~ : SourceLoc) -> String

    Declares a static style in the document head, for example:
    let style_demo : String = contained_static_style(
    [(Some("@media only screen and (max-width: 600px)"), "&", respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96)))],
    )

    convert_prop_value

    fn convert_prop_value(prop_name : String, value : String) ->
    JsObscure

    Converts string values to appropriate JavaScript values for React props. Handles boolean attributes by converting "true"/"false" strings to actual booleans. The internal innerHTML attribute is converted to React's dangerouslySetInnerHTML object; only provide trusted HTML to that API.

    Parameters

    • prop_name: React property name.
    • value: String value from the attribute.

    Returns

    JsObscure - Properly typed JavaScript value for React.

    Inspect Examples

    inspect(convert_prop_value("checked", "true"), content="JsObscure::from_bool(true)") inspect(convert_prop_value("className", "my-class"), content="JsObscure::from_string("my-class")")

    convert_style_to_js_object

    Converts a RespoStyle to a JavaScript style object. This function takes CSS properties from RespoStyle and converts them to React-compatible camelCase property names with string values.

    Parameters

    • style: RespoStyle containing CSS properties

    Returns

    JsObject - JavaScript object with camelCase CSS properties

    Example

    let style = @css.respo_style(background_color=Red, font_size=16.0 |> Px)
    let js_style = convert_style_to_js_object(style)
    // Results in: { backgroundColor: "red", fontSize: "16px" }

    create_context

    fn[T] create_context(default_value : T) -> ReactContext[T]

    Creates a typed React Context with the value returned when no matching provider exists above a consumer.

    Create contexts outside ordinary render paths, or memoize them when their lifetime intentionally belongs to a component instance.

    create_element

    fn create_element(name : String, attrs : ElementAttrs, event : ElementEvents, style~ :
    RespoStyle
    , children : Array[VirtualNode]) -> VirtualElement

    Creates a virtual DOM element with the specified properties.

    This is the internal implementation used by built-in element functions like div, span, etc. It can also be used to create custom HTML elements that are not provided by the library.

    Parameters

    • name: HTML tag name (e.g., "div", "span", "custom-element")
    • attrs: Element attributes
    • event: Event handlers
    • style: CSS styles
    • children: Child virtual nodes

    Example

    // Create a custom element
    let _custom_elem = create_element(
    "my-custom-element",
    ElementAttrs::new(),
    ElementEvents::new(),
    style=@css.respo_style(),
    [Text("Custom content")],
    )

    create_portal

    fn create_portal(child : VirtualNode, parent :
    Element
    , key? : String) -> VirtualNode

    Creates a React portal whose DOM is placed in parent while context and event propagation continue to follow the owning React tree.

    css_prop_to_camel_case

    fn css_prop_to_camel_case(name : String) -> String

    Converts CSS property names from hyphen-case (kebab-case) to React camelCase. Supports vendor prefixes (leading hyphen) by capitalizing the first segment.

    Parameters

    • name: CSS property name such as "background-color" or "-webkit-line-clamp".

    Returns

    String - React-style camelCase property.

    inspect(css_prop_to_camel_case("background-color"), content="backgroundColor") inspect(css_prop_to_camel_case("border-top-left-radius"), content="borderTopLeftRadius") inspect(css_prop_to_camel_case("-webkit-line-clamp"), content="WebkitLineClamp")

    datalist

    fn datalist(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the datalist form element.

    declare_contained_style

    #deprecated("This function is deprecated.")
    #callsite(autofill(loc))
    fn[U : Show] declare_contained_style(rules : Array[(String?, U,
    RespoStyle
    )], loc~ : SourceLoc) -> String

    Deprecated compatibility alias for contained_static_style.

    Use contained_static_style in new code. This alias remains available for existing callers and will be removed only in a future breaking release.

    define_component

    fn[T] define_component(render_component : (T) -> VirtualNode) -> ReactComponent[T]

    Defines a stable typed React component from a MoonBit render function. Prefer module-level declarations; repeated calls with the same function also reuse the same JavaScript component type.

    defs

    fn defs(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the defs svg element.

    details

    fn details(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, open? : Bool, on_click? : (DOMEvent) -> Unit, on_toggle? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the details interactive element.

    dialog

    fn dialog(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, open? : Bool, on_click? : (DOMEvent) -> Unit, on_cancel? : (DOMEvent) -> Unit, on_close? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the dialog interactive element.

    div

    fn div(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a div element with optional React attributes, events, styles, raw HTML, and child nodes.

    Do not provide both innerHTML and non-empty children; React elements must have exactly one content source.

    dom_attr_to_react_prop

    fn dom_attr_to_react_prop(attr_name : String) -> String

    Converts legacy DOM attribute names to React-compatible property names. This function provides backward compatibility for traditional HTML attribute names. Most attributes should use the correct React property names directly in element definitions.

    Parameters

    • attr_name: HTML attribute name such as "class", "for", or "innerHTML".

    Returns

    String - React-compatible property name.

    inspect(dom_attr_to_react_prop("class"), content="className") inspect(dom_attr_to_react_prop("for"), content="htmlFor") inspect(dom_attr_to_react_prop("innerHTML"), content="dangerouslySetInnerHTML") inspect(dom_attr_to_react_prop("id"), content="id") inspect(dom_attr_to_react_prop("data-test"), content="data-test")

    dom_event_to_react_handler

    fn dom_event_to_react_handler(event_type : DOMEventType) -> String

    Converts DOM event types to React-compatible event handler names. Ensures proper camelCase formatting for React event handlers.

    Parameters

    • event_type: DOM event type enum value.

    Returns

    String - React-compatible event handler name with "on" prefix.
    inspect(dom_event_to_react_handler(KeyDown), content="onKeyDown") inspect(dom_event_to_react_handler(Click), content="onClick") inspect(dom_event_to_react_handler(MouseEnter), content="onMouseEnter") inspect(dom_event_to_react_handler(DoubleClick), content="onDoubleClick")

    ellipse

    fn ellipse(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, rx? : String, ry? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the ellipse svg element.
    fn em(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the em semantic element.

    error_boundary

    fn error_boundary(fallback : (ReactError) -> VirtualNode, children : Array[VirtualNode], reset_key? : String, on_error? : (ReactError, ReactErrorInfo) -> Unit) -> VirtualNode

    Creates a local React Error Boundary around children.

    Render failures and rejected resources produce fallback(error). Changing reset_key remounts the boundary and retries its children. on_error receives React's component stack after the fallback commits. Event-handler and arbitrary asynchronous errors outside render are not caught.

    fieldset

    fn fieldset(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, disabled? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the fieldset form element.

    figcaption

    fn figcaption(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the figcaption semantic element.

    figure

    fn figure(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the figure semantic element.

    flush_sync

    fn flush_sync(callback : () -> Unit) -> Unit

    Forces React to apply updates scheduled inside callback before returning.

    This is a last-resort escape hatch for third-party or browser integrations that must observe the updated DOM synchronously. It can hurt performance, flush pending work outside the callback, run pending Effects, or reveal Suspense fallbacks. Do not call it during render or an Effect.
    fn footer(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a footer element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a footer element.

    form

    fn form(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], action? : FormAction, method_? : String, on_submit? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a React form. A function-valued action runs in a React Action and receives the submitted ReactFormData payload.

    form_action

    fn form_action(dispatch : (ReactFormData) -> Unit) -> FormAction

    Wraps a use_action_state dispatcher for a form action or submit-control formAction property.
    fn g(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, transform? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the g svg element.
    fn h1(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h1 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h1 element.

    fn h2(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h2 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h2 element.

    fn h3(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h3 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h3 element.

    fn h4(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h4 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h4 element.

    fn h5(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h5 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h5 element.

    fn h6(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an h6 element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an h6 element.

    fn header(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a header element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a header element.

    hydrate_root

    fn hydrate_root(vdom : VirtualNode, parent :
    Element
    , options? : RootOptions) -> Unit

    Hydrates React-generated HTML already present in parent. The initial VDOM must produce identical markup. Later render calls reuse the hydrated root.

    img

    fn img(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , src? : String, alt? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit, on_load? : (DOMEvent) -> Unit, on_error? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an img element with the specified attributes, event handlers, and image properties.

    Returns a virtual DOM node representing an img element.

    input

    fn input(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , type_? : InputType, name? : String, value? : String, default_value? : String, placeholder? : String, disabled? : Bool, read_only? : Bool, checked? : Bool, default_checked? : Bool, form_action? : FormAction, on_click? : (DOMEvent) -> Unit, on_change? : (DOMEvent) -> Unit, on_input? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an input element with the specified attributes, event handlers, and properties.

    Returns a virtual DOM node representing an input element.

    is_boolean_prop

    fn is_boolean_prop(prop_name : String) -> Bool

    Checks if a React property should be treated as a boolean attribute. Returns true for attributes that React expects as boolean values.

    Parameters

    • prop_name: React property name (already converted from DOM attribute).

    Returns

    Bool - true if the property should be treated as boolean.

    inspect(is_boolean_prop("checked"), content="true") inspect(is_boolean_prop("disabled"), content="true") inspect(is_boolean_prop("readOnly"), content="true") inspect(is_boolean_prop("className"), content="false")

    label

    fn label(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit, for_? : String) -> VirtualNode

    Creates a label element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a label element.

    lazy_component

    fn[T] lazy_component(loader : async () -> ReactComponent[T]) -> ReactComponent[T]

    Defines a lazy typed component. Declare it outside render paths. React calls and caches loader on first render; the MoonBit async bridge resolves to the { default: component } module shape required by React.lazy.

    legend

    fn legend(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the legend form element.
    fn li(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a li (list item) element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a li element.

    line

    fn line(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x1? : String, y1? : String, x2? : String, y2? : String, stroke? : String, stroke_width? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the line svg element.

    linear_gradient

    fn linear_gradient(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x1? : String, y1? : String, x2? : String, y2? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the linearGradient svg element.
    fn link(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, rel? : String, href? : String, media? : String, precedence? : String, cross_origin? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the link metadata element.

    main_

    fn main_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the main semantic element.

    mask

    fn mask(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the mask svg element.

    meta

    fn meta(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, content? : String, charset? : String, http_equiv? : String, item_prop? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the meta metadata element.

    meter

    fn meter(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, value? : Float, min? : Float, max? : Float, low? : Float, high? : Float, optimum? : Float, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the meter form element.
    fn nav(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a nav element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a nav element.

    obscure

    fn[T] obscure(v : T) ->
    JsObscure

    a short hand to turn value into JsObscure in hook deps
    fn ol(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates an ol (ordered list) element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing an ol element.

    optgroup

    fn optgroup(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, label? : String, disabled? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the optgroup form element.

    option

    fn option(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, value? : String, disabled? : Bool) -> VirtualNode

    Creates an option element with the specified attributes and properties.

    Returns a virtual DOM node representing an option element.

    output

    fn output(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, html_for? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the output form element.
    fn p(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a p element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a p element.

    path

    fn path(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, d? : String, fill? : String, stroke? : String, stroke_width? : String, path_length? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the path svg element.

    polygon

    fn polygon(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, points? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the polygon svg element.

    polyline

    fn polyline(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, points? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the polyline svg element.

    pre

    fn pre(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the pre semantic element.

    preconnect

    fn preconnect(href : String, cross_origin? : ResourceCrossOrigin) -> Unit

    Hints that the browser may open an early connection to the server in href. Use cross_origin when the eventual request uses CORS. Equivalent calls for the same server have the effect of one call.

    prefetch_dns

    fn prefetch_dns(href : String) -> Unit

    Hints that the browser may resolve the host in href ahead of use. Equivalent calls for the same server are deduplicated by React. During SSR, call this only while rendering or in async work originating from rendering.

    preinit

    fn preinit(href : String, options : PreinitOptions) -> Unit

    Hints that the browser should download and immediately apply a stylesheet or execute a classic script. Select the matching PreinitOptions constructor; use preload when the resource must not take effect yet.

    preinit_module

    fn preinit_module(href : String, options? : ModuleHintOptions) -> Unit

    Hints that the browser should download and evaluate the ESM module at href. Use preload_module when evaluation should wait. Framework-managed applications usually do not need to call this API directly.

    preload

    fn preload(href : String, options : PreloadOptions) -> Unit

    Hints that the browser should start downloading href with the configured destination and metadata. Prefer framework resource management when one is present; frameworks commonly emit and deduplicate these hints themselves.

    preload_module

    fn preload_module(href : String, options? : ModuleHintOptions) -> Unit

    Hints that the browser should download the ESM module at href without evaluating it. Use preinit_module when it should execute when ready.

    progress

    fn progress(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, value? : Float, max? : Float, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the progress form element.

    radial_gradient

    fn radial_gradient(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, r? : String, fx? : String, fy? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the radialGradient svg element.

    rect

    fn rect(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, width? : String, height? : String, rx? : String, ry? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the rect svg element.

    render

    fn render(vdom : VirtualNode, parent :
    Element
    ) -> Unit

    Renders a virtual DOM node to the specified parent element. Repeated calls for the same parent reuse its React root.

    render_to_readable_stream

    async fn render_to_readable_stream(vdom : VirtualNode, options? : StreamRenderOptions) -> ReactReadableStream

    Starts React 19.2 Web Streams rendering and resolves as soon as the shell is ready. A shell failure rejects this async call.

    render_to_string

    fn render_to_string(vdom : VirtualNode, identifier_prefix? : String) -> String

    Renders a React tree to an HTML string for basic synchronous SSR or SSG. This intentionally does not provide streaming or wait for suspended data.

    render_with_options

    fn render_with_options(vdom : VirtualNode, parent :
    Element
    , options : RootOptions) -> Unit

    Renders through a new root configured with React 19 root options. Options are consumed only when this call creates the root; later renders reuse it.

    resource_from_async

    fn[T] resource_from_async(loader : async () -> T) -> ReactResource[T]

    Starts one MoonBit async operation and wraps its exported JavaScript Promise. Call this outside component render paths so the resource identity is cached.

    resource_from_promise

    fn[T] resource_from_promise(promise :
    Promise
    [T]) -> ReactResource[T]

    Wraps an existing JavaScript Promise without changing its identity.

    script_tag

    fn script_tag(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, src? : String, type_? : String, cross_origin? : String, async_? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the script metadata element.

    section

    fn section(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a section element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a section element.

    select

    fn select(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], value? : String, values? : Array[String], default_value? : String, default_values? : Array[String], disabled? : Bool, multiple? : Bool, on_change? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a select element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a select element.

    span

    fn span(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a span element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a span element.

    Example:

    let _ = span(
    class_name="text-bold",
    on_click=fn(_e) { println("Clicked!") }, []
    )

    start_transition

    fn start_transition(action : () -> Unit) -> Unit

    Marks updates made by action as non-urgent without reading transition state. Use use_transition when the component also needs is_pending.

    static_style

    #callsite(autofill(loc))
    fn[U : Show] static_style(rules : Array[(U,
    RespoStyle
    )], loc~ : SourceLoc) -> String

    Declares a static style in the document head, for example:
    let style_demo : String = static_style(
    [("&", respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96)))],
    )

    stop

    fn stop(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, offset? : String, stop_color? : String, stop_opacity? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the stop svg element.

    strong

    fn strong(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the strong semantic element.

    style_tag

    fn style_tag(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, precedence? : String, href? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the style metadata element.

    summary

    fn summary(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the summary interactive element.

    suspense

    fn suspense(fallback : VirtualNode, children : Array[VirtualNode]) -> VirtualNode

    Creates a Suspense boundary that displays fallback until every child is ready, then reveals the children together.

    svg

    fn svg(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, view_box? : String, width? : String, height? : String, xmlns? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the svg svg element.

    svg_text

    fn svg_text(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, dx? : String, dy? : String, text_anchor? : String, fill? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the text svg element.

    symbol

    fn symbol(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, view_box? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the symbol svg element.

    table

    fn table(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the table table element.

    tbody

    fn tbody(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the tbody table element.
    fn td(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, headers? : String, col_span? : Int, row_span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the td table element.

    textarea

    fn textarea(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , value? : String, default_value? : String, placeholder? : String, rows? : Int, cols? : Int, disabled? : Bool, read_only? : Bool, on_change? : (DOMEvent) -> Unit, on_input? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a textarea element with the specified attributes, event handlers, and properties.

    Returns a virtual DOM node representing a textarea element.

    tfoot

    fn tfoot(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the tfoot table element.
    fn th(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, scope? : String, headers? : String, abbr? : String, col_span? : Int, row_span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the th table element.

    thead

    fn thead(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the thead table element.

    time_

    fn time_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, date_time? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the time semantic element.

    title

    fn title(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the title metadata element.
    fn tr(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the tr table element.

    tspan

    fn tspan(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, dx? : String, dy? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the tspan svg element.
    fn ul(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a ul (unordered list) element with the specified attributes, event handlers, and children.

    Returns a virtual DOM node representing a ul element.

    unmount

    fn unmount(parent :
    Element
    ) -> Unit

    Unmounts the React root associated with a parent element, if one exists. A later call to render or hydrate_root creates a fresh root.

    use_

    fn use_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, href? : String, xlink_href? : String, x? : String, y? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode

    Generated typed helper for the use svg element.

    use_action_state

    fn[S, A] use_action_state(initial : S, action : (S, A) -> S) -> (S, (A) -> Unit, Bool)

    Stores state managed by a React 19 action. The action receives the current MoonBit state and its dispatched value, then returns the next state.

    React reports whether an action transition is pending in the final tuple value. Dispatch from a form action or start_transition when appropriate.

    use_async_action_state

    fn[S, A] use_async_action_state(initial : S, action : async (S, A) -> S) -> (S, (A) -> Unit, Bool)

    Stores state managed by an asynchronous React Action. The MoonBit async reducer is exported as a JavaScript Promise so React can keep is_pending true until it settles and can serialize queued Actions.

    use_callback0_deps

    fn use_callback0_deps(f : () -> Unit, deps : Array[
    JsObscure
    ]) -> (() -> Unit)

    Preserves the identity of a zero-argument callback until one of deps changes.

    use_callback_deps

    fn[F] use_callback_deps(callback : F, deps : Array[
    JsObscure
    ]) -> F

    Preserves callback identity until one of deps changes.

    use_context

    fn[T] use_context(context : ReactContext[T]) -> T

    Reads and subscribes to the nearest provider value for context. This is a React Hook and must only be called while rendering a component.

    use_deferred_value

    fn[T] use_deferred_value(value : T) -> T

    Defers a value so that urgent updates can render before expensive consumers of that value. The returned value keeps the original MoonBit type.

    use_dom_ref

    fn use_dom_ref() -> ReactDomRef

    Creates a nullable DOM ref Hook.

    Call this only at the top level of a React component or another Hook.

    use_effect_cleanup_deps

    fn use_effect_cleanup_deps(effect : () -> (() -> Unit), deps : Array[
    JsObscure
    ]) -> Unit

    Runs an effect with dependencies and registers its returned cleanup function.

    use_effect_deps

    fn use_effect_deps(effect : () -> Unit, deps : Array[
    JsObscure
    ]) -> Unit

    Runs an effect after rendering whenever one of deps changes.

    Use use_effect_cleanup_deps when the effect owns subscriptions or other resources that must be released.

    use_effect_event

    fn[F] use_effect_event(callback : F) -> F

    Creates a non-reactive callback for use from an effect. The callback always observes the latest props and state without becoming an effect dependency. React requires effect events to be invoked only from effects.

    use_effect_once

    fn use_effect_once(effect : () -> Unit) -> Unit

    Runs an effect after the component mounts and does not rerun it for later renders. Use use_effect_once_with_cleanup when cleanup is required.

    use_effect_once_with_cleanup

    fn use_effect_once_with_cleanup(effect : () -> (() -> Unit)) -> Unit

    Runs an effect once and registers its returned cleanup function.

    use_form_status

    fn use_form_status() -> FormStatus

    Reads React's submission status for the nearest parent form.

    Call this Hook from a component rendered inside the form. A component that creates the form cannot observe that same form's status with this Hook.

    use_id

    fn use_id() -> String

    Returns a stable identifier suitable for associating component-local DOM elements, such as a label and its input.

    use_imperative_handle_deps

    fn[T] use_imperative_handle_deps(handle_ref : ImperativeRef[T], create_handle : () -> T, deps : Array[
    JsObscure
    ]) -> Unit

    Exposes a typed imperative handle through a nullable imperative ref.

    React assigns Some(handle) after commit and restores None on cleanup. In React 19 the ref can be carried in ordinary typed component props, so a forwardRef wrapper is not required.

    use_imperative_ref

    fn[T] use_imperative_ref() -> ImperativeRef[T]

    Creates an empty typed imperative ref. Pass it through typed component props and bind it inside the child with use_imperative_handle_deps.

    use_layout_effect_cleanup_deps

    fn use_layout_effect_cleanup_deps(effect : () -> (() -> Unit), deps : Array[
    JsObscure
    ]) -> Unit

    Runs a layout effect with dependencies and registers its returned cleanup function. Prefer this only when the effect must run before the browser paints.

    use_layout_effect_deps

    fn use_layout_effect_deps(effect : () -> Unit, deps : Array[
    JsObscure
    ]) -> Unit

    Runs a layout effect after React mutates the DOM and before the browser paints. Use obscure to construct dependencies that are not already JsObscure values.

    use_memo_deps

    fn[A] use_memo_deps(factory : () -> A, deps : Array[
    JsObscure
    ]) -> A

    Memoizes the value returned by factory until one of deps changes.

    Treat this as a performance optimization rather than a semantic guarantee.

    use_optimistic

    fn[S, A] use_optimistic(value : S, reducer : (S, A) -> S) -> (S, (A) -> Unit)

    Returns a temporary optimistic state and a typed dispatcher. React restores the supplied base value when the surrounding Action finishes unless the owner commits a new base value.

    use_reducer

    fn[S : Default, A] use_reducer(initial? : S, reducer : (S, A) -> S) -> (S, (A) -> Unit)

    Compatibility reducer helper with an optional initial state. Prefer use_reducer_with_initial for new code so the state type need not derive Default.

    use_reducer_with_initial

    fn[S, A] use_reducer_with_initial(initial : S, reducer : (S, A) -> S) -> (S, (A) -> Unit)

    Creates a reducer with an explicit initial state. Unlike the compatibility use_reducer overload, this accepts state types that do not implement Default.

    use_ref

    fn[T] use_ref(initial : T) -> ReactRef[T]

    Creates a React ref Hook with an explicit initial value.

    Call this only at the top level of a React component or another Hook. For a DOM element ref with a safe empty state, prefer use_dom_ref.

    use_resource

    fn[T] use_resource(resource : ReactResource[T]) -> T

    Reads a cached resource with React 19 use.

    Unlike ordinary Hooks, React permits this call inside conditions and loops, but it must still run while rendering a component. A pending resource suspends to the nearest suspense; a rejected resource throws to the nearest error_boundary.

    use_state

    fn[T] use_state(initial : T) -> (T, (T) -> Unit)

    Creates React state initialized with initial and returns its current value plus a setter that replaces the state directly.

    Use use_state_with_updater when the next state depends on the previous value.

    use_state_with_updater

    fn[T] use_state_with_updater(initial : T) -> (T, (StateUpdate[T]) -> Unit)

    Like use_state, but its setter supports functional updates through StateUpdate::Update. Prefer this form when the next state depends on the previous value and React may batch or defer updates.

    use_sync_external_store

    fn[T] use_sync_external_store(subscribe : (() -> Unit) -> (() -> Unit), get_snapshot : () -> T, get_server_snapshot? : () -> T) -> T

    Reads and subscribes to a typed immutable snapshot from an external store.

    subscribe must return an unsubscribe callback and should keep stable identity across renders. Repeated get_snapshot calls must return the same value while the store has not changed. Supply get_server_snapshot when the component can render on the server; its initial value must also match during hydration.

    use_transition

    fn use_transition() -> (Bool, (() -> Unit) -> Unit)

    Marks state updates made by action as non-urgent. The returned boolean is true while React is rendering the transition.

    video

    fn video(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? :
    RespoStyle
    , children : Array[VirtualNode], src? : String, controls? : Bool, autoplay? : Bool, loop_enabled? : Bool, muted? : Bool, width? : String, height? : String, on_click? : (DOMEvent) -> Unit, on_play? : (DOMEvent) -> Unit, on_pause? : (DOMEvent) -> Unit) -> VirtualNode

    Creates a video element with the specified attributes, event handlers, and video properties.

    Returns a virtual DOM node representing a video element.