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.
| Component | What it draws |
|---|---|
InstrumentButton | A drawn ink instrument, eraser or lasso. |
RulerButton | A drawn ruler toggle. |
ColorPalette | A grid of round colour swatches. |
ColorPicker | Hue, saturation, brightness and opacity sliders. |
StrokeWidthPicker | A row of squiggles, one per width. |
EraserModePicker | A segmented control for the eraser mode. |
ToolPickerButton | A round button like undo and redo. |
UndoRedoControls | Undo 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.
| Prop | Type | Description |
|---|---|---|
tool | Tool | The tool the instrument shows: its kind picks the drawing; an ink tool tints the tip and band. |
selected | boolean | Raises the instrument. Changes animate with a spring. |
onPress | () => void | Called on tap. Omit to make the instrument inert. |
theme | ToolPickerTheme | Colours 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.
| Prop | Type | Description |
|---|---|---|
active | boolean | Raises the ruler. Changes animate with a spring. |
onPress | () => void | Called on tap. Omit to make the ruler inert. |
theme | ToolPickerTheme | Colours 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.
| Prop | Type | Default | Description |
|---|---|---|---|
colors | readonly number[] | Swatch colours as 0xRRGGBBAA, in reading order. | |
selectedColor | number | The colour to ring. Omit when no swatch is current. | |
onSelectColor | (color: number) => void | Called with the tapped swatch's colour. | |
rows | number | 2 | Number of rows; swatches fill rows left to right. |
swatchSize | number | 30 | Swatch diameter in points, including the ring. |
theme | ToolPickerTheme | Colours 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.
| Prop | Type | Default | Description |
|---|---|---|---|
color | number | The colour to edit, as 0xRRGGBBAA. | |
onSelectColor | (color: number) => void | Called with the new colour while a slider is dragged. | |
width | number | 240 | Slider length in points. |
theme | ToolPickerTheme | Colours 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.
| Prop | Type | Description |
|---|---|---|
widths | readonly number[] | Widths in content points, thinnest first, such as one entry of InstrumentWidths. |
selectedWidth | number | The width to highlight. Omit when none is current. |
onSelectWidth | (width: number) => void | Called with the tapped width. |
theme | ToolPickerTheme | Colours of the glyphs and the highlight. |
EraserModePicker
function EraserModePicker(props: EraserModePickerProps): ReactElement
A segmented control choosing between the stroke and pixel eraser.
| Prop | Type | Default | Description |
|---|---|---|---|
mode | EraserMode | The current mode. | |
onSelectMode | (mode: EraserMode) => void | Called with the tapped mode. | |
labels | ToolPickerLabels | defaultToolPickerLabels | Segment titles. |
theme | ToolPickerTheme | Colours. |
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.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | A short glyph such as '↶', or custom content such as an Image. | |
onPress | () => void | Called on tap. | |
disabled | boolean | false | Dims the button and ignores taps. |
size | number | 32 | Diameter in points. |
theme | ToolPickerTheme | Colours. |
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 }} />
| Prop | Type | Default | Description |
|---|---|---|---|
drawing | Drawing | The drawing to undo and redo. | |
direction | 'row' | 'column' | 'row' | Places redo beside or below undo. |
buttonSize | number | 32 | Button diameter in points. |
theme | ToolPickerTheme | Colours and material. | |
layout | NitroUI layout | Layout of the panel holding the two buttons. |