Skip to main content

nitro-ui-sketch

nitro-ui-sketch is a PencilKit-style ink canvas for NitroUI apps on iOS and Android. It gives you pressure- and tilt-sensitive inks, stroke and pixel erasers, lasso selection, a ruler, zoom, undo, and PNG, JPEG, SVG and PDF export, plus a themeable tool picker to drive them.

One C++ ink engine renders with tgfx: Metal on iOS, OpenGL ES on Android. Touches never cross into JavaScript; you observe the result through callbacks and a controller.

import { useState } from 'react'
import { Drawing, SketchCanvas } from 'nitro-ui-sketch'

export function Notes() {
const [drawing] = useState(() => new Drawing())
return (
<SketchCanvas
layout={{ flex: 1 }}
drawing={drawing}
tool={{ type: 'ink', ink: 'pen', color: 0x1e88e5ff, width: 4 }}
/>
)
}

What's in the package​

ExportWhat it does
SketchCanvasThe native ink canvas view.
CanvasControllerImperative control of a mounted canvas: viewport, selection, listeners.
DrawingStrokes with undo history, serialization and export. Works without a canvas.
StrokeOne immutable stroke and its points.
ToolPickerA PencilKit-style palette of instruments, colours, widths, undo/redo and the ruler.
Tool picker partsThe picker's building blocks, exported for custom layouts.
GlassBackgroundA Liquid Glass backdrop on iOS 26 and later, with a solid fallback.

Compared with PencilKit​

Featurenitro-ui-sketchPencilKit
iOS✅✅
Android✅❌
macOS / visionOS❌✅
Pen✅✅
Monoline✅✅
Fountain pen✅✅
Marker✅✅
Pencil✅✅
Crayon✅✅
Watercolor✅✅
Reed❌✅
Pressure and tilt✅✅
Stroke eraser✅✅
Pixel eraser✅✅
Lasso selection✅✅
Selection from code✅❌
Ruler✅✅
Zoom and pan✅✅
Undo and redo✅✅
Stylus-only drawing✅✅
Tool picker✅✅
Themeable tool picker✅❌
Colour picker✅✅
Apple Pencil double-tap❌✅
Apple Pencil squeeze❌✅
Stroke and point access✅✅
Save and load drawings✅✅
PNG / JPEG export✅✅
SVG export✅❌
PDF export✅❌

Requirements​

RequirementVersion
nitro-ui-renderer0.3.0 or later
react19.2.0 or later
nitro-core1.0.0-alpha.nightly.137.gd4793c40b8b8, exactly
iOS16 or later; Liquid Glass needs iOS 26
AndroidThe Android SDK and NDK your NitroUI release requires

Conventions​

  • Colours are 0xRRGGBBAA numbers: 0x1e88e5ff is opaque blue.
  • Sizes and positions are content points. Zoom changes how many view points one content point covers, not the stroke data.

Next steps​