Form Components

Select

The <Select> component adds a dropdown menu to a PDF form. The reader picks from a list of options you define through the select prop.

For a scrollable box rather than a dropdown, use List — it takes the same props. New to forms? Start with the Forms guide.

Props

PropTypeDefaultDescription
namestring''Field identifier. This is the key the value is exported under.
selectstring[][]The options the reader can choose from.
valuestring | numberThe currently selected option.
defaultValuestring | numberThe option the field reverts to when the form is reset.
editbooleanfalseAllows the reader to type a value that is not in the list.
sortbooleanfalseDisplays the options in alphabetical order.
multiSelectbooleanfalseAllows more than one option to be selected.
noSpellbooleanfalseDisables spell check on typed values. Only meaningful with edit.
requiredbooleanfalseMarks the field as mandatory before the form can be submitted.
readOnlybooleanfalseDisplays the selection but prevents the reader from changing it.
noExportbooleanfalseExcludes the field from the exported form data.
styleStyle | Style[]Size, position, and border of the field box.

Usage

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <Text :style="{ fontSize: 10, marginBottom: 4 }">Country</Text>
      <Select
        name="country"
        :select="['Nigeria', 'Ghana', 'Kenya', 'South Africa']"
        value="Nigeria"
        default-value="Nigeria"
        :style="{
          height: 20,
          borderWidth: 1,
          borderColor: '#cbd5e1',
        }"
      />
    </Page>
  </Document>
</template>
A <Select> has no intrinsic size. Give it a height — and a width if it is not stretching to fill its parent — or it will be invisible.

Editable and Sorted

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <!-- Sorted alphabetically, reader may type a custom value -->
      <Select
        name="role"
        edit
        sort
        no-spell
        :select="['Engineer', 'Designer', 'Analyst']"
        :style="{ height: 20 }"
      />
    </Page>
  </Document>
</template>

Empty Initial Selection

A dropdown always shows its first option. To start a field blank, include an empty string as the first option and set value to it:

vue
<template>
  <Document>
    <Page size="A4" :style="{ padding: 40 }">
      <Select
        name="country"
        :select="['', 'Nigeria', 'Ghana']"
        value=""
        default-value=""
        :style="{ height: 20 }"
      />
    </Page>
  </Document>
</template>
Unlike <TextInput> and <Checkbox>, a <Select> is not namespaced by an enclosing FieldSet — it always registers at the top level of the form. Give every select a globally unique name.