GitHub

Checkbox

The <Checkbox /> element represents one of two states the user can toggle between. Some viewers behave differently based on wether the name prop is set or not and wether there are name duplicates or not. This can result in inconsistencies which makes the name prop recommendable to use and to achieve a consistent result across various viewers.

import { View, Text, Checkbox } from '@react-pdf/renderer';

const box = { width: 12, height: 12, borderWidth: 1, borderColor: '#c9c2b6' };
const label = { fontSize: 9, color: '#3e3e3e' };

const Consent = () => (
  <View style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>
    <Checkbox name="terms" checked style={box} />
    <Text style={label}>I accept the terms</Text>
  </View>
);
Show preview

Valid props

Prop nameDescriptionTypeDefault
backGroundColorIt defines the color of the inside of the checkbox it applies toStringundefined
borderColorDefines the color used to paint the outline of the checkboxStringundefined
checkedIf set to true the checkbox is checkedBooleanfalse
onStateIf set to true tells the pdf viewer to not spellcheck the textStringYes
offStateDefines the format the textinput should be formatted toStringNo
xMarkIf set to true the onState appears as a X otherwise a checkmark is displayedBooleanfalse

See also Common Form Attributes

On this page