Pear

PCheckbox

PCheckbox keeps native checkbox behavior and adds the bits you usually want in Vue: boolean models, array models, switches, and indeterminate state.

Checkboxes & Switches
Agreement
Notifications
Disabled states
vue
<p-fieldset legend="Agreement">
  <p-checkbox v-model="acceptedTerms" name="accepted-terms">
    I agree to the terms
  </p-checkbox>
</p-fieldset>

<p-fieldset legend="Notifications">
  <p-checkbox v-model="notificationSwitch" name="notifications" switch>
    Enable notifications
  </p-checkbox>
</p-fieldset>
Checkbox Groups
Features
Select all
vue
<p-checkbox-group
  v-model="selectedFeatures"
  legend="Features"
  name="features"
  :options="availableFeatureOptions"
/>

PRadio

PRadio is the same idea for radio buttons: native inputs with a tidy scalar v-model.

States
Features
Pick at least one feature.
Support plan
Choose a support plan.
vue
<p-checkbox-group
  v-model="missingFeatures"
  legend="Features"
  error="Pick at least one feature."
  name="features"
  :options="availableFeatureOptions"
/>

<p-radio-group
  v-model="supportPlan"
  legend="Support plan"
  error="Choose a support plan."
  name="support-plan"
  :options="supportOptions"
/>
Radio Group
Contact preference
Disabled
vue
<p-radio-group
  v-model="contactPreference"
  legend="Contact preference"
  name="contact-preference"
  :options="contactOptions"
/>
API

PCheckboxGroup & PRadioGroup Props

NameTypeDefaultDescription
v-modelPChoiceValue[] | PChoiceValue-Selected checkbox values, or the selected radio value.
optionsPChoiceOption[]-Options with label, value, and optional disabled state.
namestring-Native input name. Pear creates one when omitted.
legendstring-Fieldset legend for the group.
helperstring-Helper text below the options.
errorstring-Error text below the options. Also marks the group invalid.
disabledbooleanfalseDisables the whole group.
invalidbooleanfalseMarks the whole group invalid.
horizontalbooleanfalseLays options out in a wrapping row.
switchbooleanfalsePCheckboxGroup only. Renders options as switches.

PCheckbox Props

NameTypeDefaultDescription
v-modelstring | number | boolean | Array<string | number | boolean>-Checked value or selected values array.
valuestring | number | booleantrueValue written when checked, or array item used in group mode.
uncheckedValuestring | number | booleanfalseValue written when unchecked outside array mode.
switchbooleanfalseRenders the checkbox with role switch for Pico switch styling.
indeterminatebooleanfalseSets the native indeterminate visual state.
disabledbooleanfalseDisables the checkbox. Inherits from PField when present.
invalidbooleanfalseSets aria-invalid. Inherits from PField when present.

PRadio Props

NameTypeDefaultDescription
v-modelstring | number | boolean-Selected radio value.
valuestring | number | boolean-Value written when this radio is checked.
disabledbooleanfalseDisables the radio. Inherits from PField when present.
invalidbooleanfalseSets aria-invalid. Inherits from PField when present.

Slots

NameTypeDefaultDescription
defaultslot-Label content rendered next to the native checkbox or radio.
optionslot-PCheckboxGroup and PRadioGroup option label slot.

Events

NameTypeDefaultDescription
update:modelValuevalue or value[]-Emitted by v-model when the native input changes.