API

JSX elements

The JSX elements from @zplkit/core/jsx and their props.

import { Label, Text, Box, Code128, build, mm, dots } from "@zplkit/core/jsx";

JSX shows how to set it up and build labels. Elements take the same options as the Label methods, with x and y instead of position, and text or barcode data as children.

build(element)

Turns a <Label> element, or a component that returns one, into a Label, with toZPL(), lint() and commands. It throws a ZplError for anything else, or for text outside a <Text>.

<Label>

PropertyTypeDefaultDescription
widthLength

Label width (^PW)

heightLength

Label height (^LL)

dpmm6 | 8 | 12 | 24

Dots per millimeter of the printer: 6, 8, 12 or 24 for 152, 203, 300 or 600 dpi

reverse?booleanfalse

Print the label white on black (^LR)

characterSet?number28 (UTF-8)

Character set (^CI)

home?PositionThe top left corner

Where positions are measured from (^LH)

minify?booleantrue

Leave out line breaks between commands in the output

copies?number1

How many copies to print (^PQ)

speed?numberThe printer's setting

Print speed in inches per second, 1 to 14 depending on the printer (^PR)

darkness?number0

Darkness relative to the printer's setting, -30 to 30 (^MD)

children?ZplNode

The label's elements

<Text>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

file?string

A font file on the printer instead, like "E:ARIAL.TTF"

height?Length

Character height

width?Length

Character width

orientation?Orientation

Which way the text runs

direction?"horizontal" | "reverse" | "vertical""horizontal"

Which way the characters run: across, down (one under the other) or right to left (^FP)

letterSpacing?LengthNone

Extra space between characters (^FP)

clock?booleanfalse

Fill in date and time codes like %Y-%m-%d %H:%M from the printer's clock (^FC)

block?TextBlockOptionsOne line

Wrap the text in a block (^FB)

serial?SerialOptionsThe same text on every copy

Count the text up on each copy, from the number at its end (^SN)

font?stringThe label's default font

One of the printer's fonts, or a font name

childrenTextChildren

The text; characters ZPL would read as commands are escaped

<Box>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

widthLength

Box width

heightLength

Box height

thicknessLength

Line thickness; the smaller of width and height draws a solid box

color?Color"B"

B for black, W for white

rounding?0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 80

How round the corners are, from 0 (square) to 8

<Ellipse>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

widthLength

Ellipse width

heightLength

Ellipse height

thicknessLength

Line thickness; half the width or height draws a solid ellipse

color?Color"B"

B for black, W for white

<Circle>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

diameterLength

Circle diameter

thicknessLength

Line thickness; half the diameter draws a solid circle

color?Color"B"

B for black, W for white

Barcodes

<Code11>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

checkDigits?1 | 22

Number of check digits

childrenTextChildren

The data to encode; it's escaped for you

<Code39>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

checkDigit?booleanfalse

Add a Mod-43 check digit

childrenTextChildren

The data to encode; it's escaped for you

<Code128>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

useUcc?booleanfalse

Add a UCC check digit

mode?"A" | "D" | "N" | "U""N"

N (none), U (UCC case), A (automatic) or D (UCC/EAN)

childrenTextChildren

The data to encode; it's escaped for you

<Interleaved2of5>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

checkDigit?booleanfalse

Add a Mod-10 check digit

childrenTextChildren

The data to encode; it's escaped for you

<EAN13>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<EAN8>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<UpcA>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

printCheckDigit?booleantrue

Print the check digit in the interpretation line

childrenTextChildren

The data to encode; it's escaped for you

<UpcE>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

printCheckDigit?booleantrue

Print the check digit in the interpretation line

childrenTextChildren

The data to encode; it's escaped for you

<UpcEanExtension>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<Code93>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

printCheckDigit?booleanfalse

Print the two check characters in the interpretation line

childrenTextChildren

The data to encode; it's escaped for you

<Codabar>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

start?"A" | "B" | "C" | "D""A"

The start character

stop?"A" | "B" | "C" | "D""A"

The stop character

childrenTextChildren

The data to encode; it's escaped for you

<Industrial2of5>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<Standard2of5>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<LOGMARS>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHriAbove?booleanfalse

Print that text above the bars instead of below

childrenTextChildren

The data to encode; it's escaped for you

<MSI>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

checkDigits?"A" | "B" | "C" | "D""B"

A for none, B for one Mod 10, C for two Mod 10, D for Mod 11 then Mod 10

printCheckDigit?booleanfalse

Print the check digits in the interpretation line

childrenTextChildren

The data to encode; it's escaped for you

<Plessey>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHri?booleantrue

Print the data as text with the bars

printHriAbove?booleanfalse

Print that text above the bars instead of below

printCheckDigit?booleanfalse

Print the two check characters in the interpretation line

childrenTextChildren

The data to encode; it's escaped for you

<Postnet>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHriAbove?booleanfalse

Print that text above the bars instead of below

printHri?booleanfalse

Print the data as text with the bars

childrenTextChildren

The data to encode; it's escaped for you

<Planet>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Bar height

printHriAbove?booleanfalse

Print that text above the bars instead of below

printHri?booleanfalse

Print the data as text with the bars

childrenTextChildren

The data to encode; it's escaped for you

<IntelligentMail>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

height?LengthThe height set with ^BY

Height of the tallest bars

childrenTextChildren

The data to encode; it's escaped for you

<GS1DataBar>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

type?union"omnidirectional"

Which GS1 DataBar

moduleSize?Length2 dots, 3 at 300 dpi and 6 at 600 dpi

Size of a module, 1 to 10 dots

separatorHeight?1 | 21

Height of the separator rows in stacked symbols, in modules

segments?number22

Segments per row for Expanded, an even number from 2 to 22

childrenTextChildren

The data to encode; it's escaped for you

<MicroPDF417>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

rowHeight?LengthThe height set with ^BY

Height of each row

mode?number0

0 to 33, which sets the columns, rows and error correction; the reference lists them

childrenTextChildren

The data to encode; it's escaped for you

<PDF417>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

rowHeight?LengthThe height set with ^BY

Height of each row

securityLevel?0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 80

Error correction level, from 0 (detection only) to 8

columns?number

Number of data columns, 1 to 30

rows?number

Number of rows, 3 to 90

truncate?booleanfalse

Leave out the right row indicators and stop pattern

childrenTextChildren

The data to encode; it's escaped for you

<DataMatrix>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

moduleSizeLength

Size of each square module

quality?0 | 50 | 80 | 100 | 140 | 200200 (ECC 200)

Error correction level

columns?number

Number of columns

rows?number

Number of rows

formatId?1 | 2 | 3 | 4 | 5 | 6

Format ID, not used with quality 200

escapeCharacter?string

Escape sequence control character

childrenTextChildren

The data to encode; it's escaped for you

<QrCode>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

moduleSize?LengthThe printer's default for its resolution

Size of each square module

errorCorrection?"H" | "L" | "M" | "Q""M"

H (highest), Q, M (standard) or L (densest)

childrenTextChildren

The data to encode; it's escaped for you

<Aztec>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

orientation?Orientation

Which way the barcode runs

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

moduleSize?LengthThe printer's default for its resolution

Size of each square module, 1 to 10 dots

errorControl?number

Error correction percentage (1 to 99), or 101 to 104 for a compact symbol and 201 to 232 for a full-range one with that many layers

childrenTextChildren

The data to encode; it's escaped for you

<MaxiCode>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

serial?SerialOptionsThe same data on every copy

Count the data up on each copy, from the number at its end (^SN)

mode?2 | 3 | 4 | 5 | 62

2 or 3 for carrier messages with a numeric or alphanumeric postal code, 4 to 6 for other data. In modes 2 and 3 the data starts with the class of service, country code and postal code.

childrenTextChildren

The data to encode; it's escaped for you

Images

<Graphic>

PropertyTypeDescription
xLength

Distance from the left

yLength

Distance from the top

graphicGraphic

The image, for example from ImageConverter

<StoredGraphic>

PropertyTypeDefaultDescription
xLength

Distance from the left

yLength

Distance from the top

namestring

Name of the graphic on the printer

device?StorageDevice"R"

Where the graphic is stored: R (DRAM), E (flash), B or A

magnification?object\{ x: 1, y: 1 \}

How many times larger to print it, across and down

Other elements

<Field>

A field with any command, for elements without their own component.

PropertyTypeDescription
xLength

Distance from the left

yLength

Distance from the top

commandunion

The command(s) for the field, added as written, like "^B3N,N,100,Y,N"

children?TextChildren

Field data, if the command needs any; it's escaped for you

<DefaultFont>

The font (^CF) for text that follows and doesn't set one.

PropertyTypeDescription
fontstring

One of the printer's fonts, like ZebraFontFamily.ZERO, or a font name

height?Length

Character height

width?Length

Character width

<FieldOrientation>

The orientation (^FW) of the fields that follow and don't give one.

PropertyTypeDescription
orientationOrientation

Orientation of the fields that follow

<Raw>

Plain ZPL, added as written. Nothing is escaped, so keep user input out.

PropertyTypeDescription
zplstring

ZPL added as written