Skip to main content

Tool picker parts

ToolPicker is built from these components. Each takes the same optional theme; without it, it uses the preset for the current colour scheme.

ComponentWhat it draws
InstrumentButtonA drawn ink instrument, eraser or lasso.
RulerButtonA drawn ruler toggle.
ColorPaletteA grid of round colour swatches.
ColorPickerHue, saturation, brightness and opacity sliders.
StrokeWidthPickerA row of squiggles, one per width.
EraserModePickerA segmented control for the eraser mode.
ToolPickerButtonA round button like undo and redo.
UndoRedoControlsUndo and redo buttons on a bar-styled panel.

InstrumentButton​

function InstrumentButton(props: InstrumentButtonProps): ReactElement
const instrumentButtonWidth = 34

A drawn ink instrument (pen, monoline, fountain pen, marker, pencil, crayon or watercolour brush), eraser or lasso. It is instrumentButtonWidth points wide and taller than it looks: place it in a container with a fixed height and overflow: 'hidden' so the barrel ends at the container's edge.

PropTypeDescription
toolToolThe tool the instrument shows: its kind picks the drawing; an ink tool tints the tip and band.
selectedbooleanRaises the instrument. Changes animate with a spring.
onPress() => voidCalled on tap. Omit to make the instrument inert.
themeToolPickerThemeColours of the barrel.

RulerButton​

function RulerButton(props: RulerButtonProps): ReactElement

A drawn ruler that rises while the canvas shows its ruler. It is instrumentButtonWidth points wide; place it like an InstrumentButton.

PropTypeDescription
activebooleanRaises the ruler. Changes animate with a spring.
onPress() => voidCalled on tap. Omit to make the ruler inert.
themeToolPickerThemeColours of the ruler.

ColorPalette​

function ColorPalette(props: ColorPaletteProps): ReactElement

A grid of round colour swatches; the selected one gets a ring in its own colour.

PropTypeDefaultDescription
colorsreadonly number[]Swatch colours as 0xRRGGBBAA, in reading order.
selectedColornumberThe colour to ring. Omit when no swatch is current.
onSelectColor(color: number) => voidCalled with the tapped swatch's colour.
rowsnumber2Number of rows; swatches fill rows left to right.
swatchSizenumber30Swatch diameter in points, including the ring.
themeToolPickerThemeColours of the swatch outlines.

ColorPicker​

function ColorPicker(props: ColorPickerProps): ReactElement

Hue, saturation, brightness and opacity sliders for any colour, as in the picker's colour card. Drag a slider's track to move its thumb.

PropTypeDefaultDescription
colornumberThe colour to edit, as 0xRRGGBBAA.
onSelectColor(color: number) => voidCalled with the new colour while a slider is dragged.
widthnumber240Slider length in points.
themeToolPickerThemeColours of the slider outlines.

StrokeWidthPicker​

function StrokeWidthPicker(props: StrokeWidthPickerProps): ReactElement

A row of squiggles that thicken with each width; the selected one is inverted in a rounded square. Thickness follows the order of widths, not their values, so any range reads evenly.

PropTypeDescription
widthsreadonly number[]Widths in content points, thinnest first, such as one entry of InstrumentWidths.
selectedWidthnumberThe width to highlight. Omit when none is current.
onSelectWidth(width: number) => voidCalled with the tapped width.
themeToolPickerThemeColours of the glyphs and the highlight.

EraserModePicker​

function EraserModePicker(props: EraserModePickerProps): ReactElement

A segmented control choosing between the stroke and pixel eraser.

PropTypeDefaultDescription
modeEraserModeThe current mode.
onSelectMode(mode: EraserMode) => voidCalled with the tapped mode.
labelsToolPickerLabelsdefaultToolPickerLabelsSegment titles.
themeToolPickerThemeColours.

ToolPickerButton​

function ToolPickerButton(props: ToolPickerButtonProps): ReactElement

A round button styled like the picker's undo and redo buttons. Pass it to ToolPicker's accessory for extra actions.

PropTypeDefaultDescription
childrenReactNodeA short glyph such as '↶', or custom content such as an Image.
onPress() => voidCalled on tap.
disabledbooleanfalseDims the button and ignores taps.
sizenumber32Diameter in points.
themeToolPickerThemeColours.

UndoRedoControls​

function UndoRedoControls(props: UndoRedoControlsProps): ReactElement

Undo and redo buttons for a Drawing on a panel styled like the picker's bar, for layouts that keep them apart from the picker. Each button is disabled while its action would do nothing.

<UndoRedoControls drawing={drawing} layout={{ position: 'absolute', top: 16, right: 16 }} />
PropTypeDefaultDescription
drawingDrawingThe drawing to undo and redo.
direction'row' | 'column''row'Places redo beside or below undo.
buttonSizenumber32Button diameter in points.
themeToolPickerThemeColours and material.
layoutNitroUI layoutLayout of the panel holding the two buttons.