Form Components

Checkbox

The <Checkbox> component adds an interactive tick box to a PDF form. It stores one of two string states, and the reader toggles between them.

New to forms? Start with the Forms guide.

Props

PropTypeDefaultDescription
namestring''Field identifier. This is the key the value is exported under.
checkedbooleanfalseWhether the box starts in its on state.
onStatestring'Yes'Value exported when the box is ticked.
offStatestring'Off'Value exported when the box is not ticked.
xMarkbooleanfalseDraw a cross instead of a tick when checked.
backgroundColorstringInterior colour of the box.
borderColorstringOutline colour of the box.
valuestring | numberThe field's current value. Usually set through checked instead.
defaultValuestring | numberThe value the field reverts to when the form is reset.
requiredbooleanfalseMarks the field as mandatory before the form can be submitted.
readOnlybooleanfalseDisplays the state but prevents the reader from toggling it.
noExportbooleanfalseExcludes the field from the exported form data.
styleStyle | Style[]Size and position of the box.

Usage

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <View :style="{ flexDirection: 'row', alignItems: 'center', gap: 6 }">
        <Checkbox
          name="terms"
          checked
          :style="{ width: 14, height: 14 }"
        />
        <Text :style="{ fontSize: 10 }">
          I accept the terms and conditions
        </Text>
      </View>
    </Page>
  </Document>
</template>
A <Checkbox> has no intrinsic size. Give it an explicit width and height or it will be invisible. Square dimensions look best in most readers.

Appearance

The tick and cross glyphs come from the ZapfDingbats font, which vue-pdf embeds automatically the first time a checkbox is rendered.

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <!-- Tick mark (default) -->
      <Checkbox name="tick" checked :style="{ width: 14, height: 14 }" />

      <!-- Cross mark -->
      <Checkbox name="cross" checked x-mark :style="{ width: 14, height: 14 }" />

      <!-- Styled interior and outline -->
      <Checkbox
        name="styled"
        background-color="#f1f5f9"
        border-color="#0f172a"
        :style="{ width: 14, height: 14 }"
      />
    </Page>
  </Document>
</template>

Custom States

By default a checkbox exports Yes or Off. Override onState and offState when the system consuming the form expects specific values:

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <Checkbox
        name="newsletter"
        checked
        on-state="Subscribed"
        off-state="Unsubscribed"
        :style="{ width: 14, height: 14 }"
      />
    </Page>
  </Document>
</template>
Use the same onState and offState for every checkbox in a document. Readers differ in how they handle a form whose checkboxes use inconsistent state names, and mixed naming is a common source of boxes that appear blank or refuse to toggle.

Grouping

Wrap checkboxes in a FieldSet to namespace them under a shared prefix.