Skip to main content Design tokens Components Style utilities
Skip to table of contents

    Checkbox

    Checkboxes allow the user to toggle an option on or off.

    <pc-checkbox>Checkbox</pc-checkbox>
    Code

    This component works well with standard <form> elements. Please refer to the form controls page to learn more about form submission and client‐side validation.

    Demos

    Checked

    Use the checked attribute to enable the checkbox.

    Indeterminate

    Use the indeterminate attribute to make the checkbox indeterminate.

    Disabled

    Use the disabled attribute to disable the checkbox.

    Sizes

    Use the size attribute to change the checkbox’s size.

    Hint

    Add a hint to a checkbox with the hint attribute. For hints that contain HTML, use the hint slot instead.

    Custom validity

    Use the setCustomValidity() method to set a custom validation message. This will prevent the form from submitting and make the browser display the error message you provide. To clear the error, call this function with an empty string.

    Properties

    NameDescriptionReflectsDefault
    dependencies object{ "pc-icon": PcIcon }
    input HTMLInputElement-
    checked booleanfalse
    defaultChecked booleanfalse
    disabled booleanfalse
    form string""
    hint string""
    indeterminate booleanfalse
    invalid booleanfalse
    name string""
    pressed booleanfalse
    required booleanfalse
    size "small" | "medium" | "large""medium"
    title string""
    value string""
    validity -
    validationMessage -
    updateComplete A read‐only promise that resolves when the component has finished updating. -

    Learn more about attributes and properties.

    Methods

    NameDescriptionArguments
    handleDisabledChange()-
    handleStateChange()-
    click()-
    focus()options: FocusOptions
    blur()-
    checkValidity()-
    getForm()-
    reportValidity()-
    setCustomValidity()message: string

    Learn more about methods.

    Importing

    If you’re using the autoloader or the standard loader, you can ignore this section. If you’re cherry picking, you can use any of the following snippets to import this component.

    ScriptImportBundler

    To import this component from the CDN with a script tag, copy this snippet and paste it in your HTML.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@0.5.1/dist/components/checkbox/checkbox.js"></script>

    To import this component from the CDN using a JavaScript import, copy this snippet and paste it in your JavaScript:

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@0.5.1/dist/components/checkbox/checkbox.js";

    To import this component with a bundler using a JavaScript import, copy this snippet and paste it in your JavaScript:

    import "placer-toolkit/dist/components/checkbox/checkbox.js";