SwiftUI.js
Components

Canvas

Canvas exposes the browser's drawing surface with a SwiftUI-style dedicated component wrapper.

Canvas exposes the browser's drawing surface with a SwiftUI-style dedicated component wrapper.

API

PropTypeRequiredDescription
draw(context: globalThis.CanvasRenderingContext2D) => voidNoDrawing callback invoked with a 2d rendering context when available.

Inherits additional props from Omit<IBaseElementComponent<'canvas'>, 'children'>.

Canvas exposes the browser's drawing surface with a SwiftUI-style dedicated component wrapper.

Status: adapted

SwiftUI Correspondence: Adapted from SwiftUI's Canvas.

Notes

  • Rendering is delegated to the supplied draw callback.
  • The current implementation targets a 2D context.

On this page