Theme

npm_versionnpm Paragon package page

A simple checkbox for use with Form.CheckboxSet.

Note: extra props added to this component are passed as attributes to the underlying input node. See MDN for documentation on available input attributes.

Controlled Standalone Usage

Any Paragon component or export may be added to the code example.

Unlabeled control

Any Paragon component or export may be added to the code example.

Controlled Group Usage with useCheckboxSetValues

useCheckboxSetValues(initialValues[]) returns an array: [state, dispatchers].

dispatchers includes add(value) remove(value) set(values[]) and clear()

Any Paragon component or export may be added to the code example.

Uncontrolled Usage

Any Paragon component or export may be added to the code example.

Indeterminate Usage

Any Paragon component or export may be added to the code example.

Inline layout

Any Paragon component or export may be added to the code example.

Validation

Group Level Validation

Any Paragon component or export may be added to the code example.

Individual option validation

Any Paragon component or export may be added to the code example.

Label Position

The label is positioned to the right of the checkbox control by default. The label can be rendered on the left instead by passing the floatLabelLeft prop.

Any Paragon component or export may be added to the code example.

Theme Variables#

CSS VariableComputed Value










Props API#

FormCheckbox Props API
  • id string

    Specifies id of the FormCheckbox component.

  • children node Required

    Specifies contents of the component.

  • className string

    Specifies class name to append to the base element.

  • controlClassName string

    Specifies class name for control component.

  • labelClassName string

    Specifies class name for label component.

  • description node

    Specifies description to show under the checkbox.

  • isInvalid bool

    Specifies whether to display checkbox in invalid state, this affects styling.

    Defaultfalse
  • isValid bool

    Specifies whether to display checkbox in valid state, this affects styling.

    Defaultfalse
  • controlAs elementType

    Specifies control element.

    DefaultReact.forwardRef( ({ isIndeterminate, ...props }, ref) => { const { getCheckboxControlProps, hasCheckboxSetProvider } = useCheckboxSetContext(); const defaultRef = React.useRef(); const resolvedRef = ref || defaultRef; const { getControlProps } = useFormGroupContext(); let checkboxProps = getControlProps({ ...props, className: classNames('pgn__form-checkbox-input', props.className), }); if (hasCheckboxSetProvider) { checkboxProps = getCheckboxControlProps(checkboxProps); } React.useEffect(() => { // this if(resolvedRef.current) prevents console errors in testing if (resolvedRef.current) { resolvedRef.current.indeterminate = isIndeterminate; } }, [resolvedRef, isIndeterminate]); return ( <input type="checkbox" {...checkboxProps} ref={resolvedRef} /> ); }, )
  • floatLabelLeft bool

    Specifies whether the floating label should be aligned to the left.

    Defaultfalse
  • disabled bool

    Specifies whether the FormCheckbox is disabled.

    Defaultfalse
CheckboxControl Props API
  • isIndeterminate bool

    Specifies whether the checkbox should be rendered in indeterminate state.

    Defaultfalse
  • className string

    Specifies class name to append to the base element.

FormCheckboxSet Props API
  • children node Required

    Specifies contents of the component.

  • className string

    Specifies class name to append to the base element.

  • name string Required

    Specifies name for the component.

  • value string[]

    Specifies values for the checkboxes.

  • defaultValue string[]

    Specifies default values for the checkboxes.

  • isInline bool

    Specifies whether to display components with inline styling.

    Defaultfalse
  • onChange func

    Specifies onChange event handler.

  • onFocus func

    Specifies onFocus event handler.

  • onBlur func

    Specifies onBlur event handler.

Usage Insights#

CheckboxControl

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.32
frontend-app-course-authoring21.5.63
frontend-app-learner-portal-enterprise20.45.42
frontend-lib-content-components21.5.64

FormCheckbox

Project NameParagon VersionInstance Count
frontend-app-account20.46.32
frontend-app-admin-portal20.46.39
frontend-app-authn20.46.23
frontend-app-communications20.46.27
frontend-app-course-authoring21.5.64
frontend-app-discussions20.46.32
frontend-app-gradebook20.45.01
frontend-app-learner-dashboard20.46.21
frontend-app-learner-portal-enterprise20.45.41
frontend-app-library-authoring21.5.64
frontend-app-support-tools20.46.01
frontend-lib-content-components21.5.67
prospectus20.46.21

FormCheckboxSet

Project NameParagon VersionInstance Count
frontend-app-communications20.46.21
frontend-app-course-authoring21.5.62
frontend-app-learner-dashboard20.46.21
frontend-lib-content-components21.5.61