Skip to content

components/pixel-number

PixelNumberSize = "sm" | "md" | "lg" | "xl"

Supported PixelNumber sizes: one font pixel is 2, 3, 4 or 6 CSS pixels.


PixelNumberTone = "current" | "primary" | "accent" | "success" | "warning" | "error"

Semantic tones supplied by the current theme.


PixelNumberProps = Omit<HTMLAttributes<HTMLSpanElement>>, "children"> > & object

Props accepted by PixelNumber. Pass a value, or readout text.

optional value?: number

A number to draw.

optional text?: string

Readout text instead of a number: digits and : . + - / × % and spaces.

optional pad?: number

Left-pad the whole part of value with zeros to this many digits.

optional signed?: boolean

Prefix a positive value with +, for gains and floating numbers.

optional size?: PixelNumberSize

optional tone?: PixelNumberTone

optional outline?: boolean

Ring every lit pixel with the ink line, like a sprite outline, so the number reads over any world: damage, pickups and floating gains.

const PIXEL_NUMBER_CHARACTERS: readonly string[]

Characters the pixel face can draw.


const PixelNumber: ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLSpanElement>>, "children"> > & object & RefAttributes<HTMLSpanElement>>>>

Crisp pixel numerals drawn as SVG, so they stay sharp at every size and never depend on a font file. The readable text is kept for assistive tech.

formatPixelNumber(value, pad?, signed?): string

Format a number the way PixelNumber draws it.

number

number = 0

boolean = false

string


checkPixelText(text): string

Reject characters the pixel face cannot draw, naming the ones it can.

string

string