Skip to main content Sidebar Design tokens Components Layout Style utilities

We’d love to hear from you. Please reach out to us with any questions or inquiries you may have.

You can contact us via e‐mail at placer.coc.reports+contact@gmail.com.

We look forward to hearing from you!

Got it!
Skip to table of contents

The Placer Toolkit alpha has arrived! 🎉
Plenty of changes are coming your way—some big, some breaking, some even nuclear! Beware the changelog…

Bring it on!

    Input

    <pc-input> 0.4.0 experimental

    Inputs collect data from the user.

    <pc-input></pc-input>
    Code Edit

    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#

    Labels#

    Use the label attribute to give the input an accessible label. For labels that contain HTML, use the label slot instead.

    Edit

    Hints#

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

    Edit

    Placeholders#

    Use the placeholder attribute to add a placeholder.

    Edit

    Clearable#

    Add the clearable attribute to add a clear button when the input has content.

    Edit

    Password toggle#

    Add the password-toggle attribute to add a toggle button that will show the password when activated.

    Edit

    Filled#

    Add the filled attribute to draw a filled input.

    Edit

    Disabled#

    Use the disabled attribute to disable the input.

    Edit

    Size#

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

    Edit

    Pill#

    Use the pill attribute to give inputs a pill‐shaped look.

    Edit

    Input types#

    Use the type attribute to control the input type that the browser renders.

    Edit

    Prefixes and suffixes#

    Use the prefix and suffix slots to add presentational icons and text. Avoid slotting in interactive elements, such as buttons and links.

    Edit

    Properties#

    NameDescriptionReflectsDefault
    typeThe type of input. Works the same as a native <input> element, but only a subset of types are supported.
    Type: "date" | "datetime-local" | "email" | "number" | "password" | "search" | "tel" | "text" | "time" | "url"
    "text"
    nameThe name of the input, submitted as a name/value pair with form data.
    Type: string
    ""
    valueThe current value of the input, submitted as a name/value pair with form data.
    Type: string
    ""
    defaultValueThe default value of the input. Primarily used for resetting the input.
    Type: string
    ""
    sizeThe input’s size.
    Type: "small" | "medium" | "large"
    "medium"
    filledDraws a filled input.
    Type: boolean
    false
    pillDraws a pill‐style input.
    Type: boolean
    false
    labelThe input’s label. If you need to display HTML, use the label slot instead.
    Type: string
    ""
    hintThe input’s hint. If you need to display HTML, use the hint slot instead.
    Type: string
    ""
    clearableAdds a clear button when the input is not empty.
    Type: boolean
    false
    disabledDisables the input.
    Type: boolean
    false
    placeholderPlaceholder text to show as a hint when the input is empty.
    Type: string
    ""
    readonlyMakes the input readonly.
    Type: boolean
    false
    passwordToggle
    password-toggle
    Adds a button to toggle the password’s visibility. Only applies when the input’s type is set to password.
    Type: boolean
    false
    passwordVisible
    password-visible
    Determines whether or not the password is visible by default. Only applies when the input’s type is set to password.
    Type: boolean
    false
    noSpinButtons
    no-spin-buttons
    Hides the browser’s built‐in increment and decrement spin buttons. Only applies when the input’s type is set to number.
    Type: boolean
    false
    formBy default, form controls are associated with the nearest containing <form> element. This attribute allows you to place the form control outside of a form and associate it with the form that has this id. The form must be in the same document or shadow root for this to work.
    Type: string
    ""
    requiredIndicates if the input must be filled in or not.
    Type: boolean
    false
    patternA RegEx pattern to validate the input against.
    Type: string | undefined
    minlengthThe minimum length of input that will be considered valid.
    Type: number | undefined
    maxlengthThe maximum length of input that will be considered valid.
    Type: number | undefined
    minThe input’s minimum value. Only applies when the input’s type is set to date or number.
    Type: number | string | undefined
    maxThe input’s maximum value. Only applies when the input’s type is set to date or number.
    Type: number | string | undefined
    stepSpecifies the granularity that the value must adhere to, or the special value any which means no stepping is implied, allowing any numeric value. Only applies when the input’s type is set to date or number.
    Type: number | "any" | undefined
    autocapitalizeControls whether and how text input is automatically capitalised as it is entered by the user.
    Type: "off" | "none" | "on" | "sentences" | "words" | "characters"
    "none"
    autocorrectIndicates whether the browser’s autocorrect feature is on or off.
    Type: boolean
    false
    autocompleteSpecifies what permission the browser has to provide assistance in filling out form field values. Refer to this page on MDN for available values.
    Type: string | undefined
    autofocusIndicates that the input should receive focus on page load.
    Type: boolean
    enterkeyhintUsed to customise the label or icon of the Enter key on virtual keyboards.
    Type: "enter" | "done" | "go" | "next" | "previous" | "search" | "send"
    "enter"
    spellcheckEnables spellcheck on the input.
    Type: boolean
    true
    inputmodeTells the browser what type of data will be entered by the user, allowing virtual keyboards to display the correct keyboard type to the user.
    Type: "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url"
    "text"
    valueAsDateGets or sets the current value as a Date object. Returns null fi the value can’t be converted. This will use the native <input type="{{type}}" /> implementation and may result in an error.
    valueAsNumberGets or sets the current value as a number. Returns NaN if the value can’t be converted.
    validityGets the validity state object.
    validationMessageGets the validation message.
    updateComplete A read‐only promise that resolves when the component has finished updating.

    Learn more about attributes and properties.

    Slots#

    NameDescription
    (default)The input’s label. Alternatively, you can use the label attribute.
    prefixA presentational prefix icon or similar element.
    suffixA presentational suffix icon or similar element.
    clear-iconAn icon to use to replace the default clear icon.
    show-password-iconAn icon to use to replace the default show password icon.
    hide-password-iconAn icon to use to replace the default hide password icon.
    hintText that describes how to use the input. Alternatively, you can use the hint attribute.

    Learn more about using slots.

    Methods#

    NameDescriptionArguments
    focus()Focuses the input.options: FocusOptions
    blur()Unfocuses the input (i.e., blurs it).
    select()Selects all the text in the input.
    setSelectionRange()Sets the start and end positions of the text selection (0‐based).selectionStart: number, selectionEnd: number, selectionDirection: "forward" | "backward" | "none"
    setRangeText()Replaces a range of text with a new string.replacement: string, start: number, end: number, selectMode: "select" | "start" | "end" | "preserve"
    showPicker()Displays the browser picker for an input element. This only works if the browser supports it for the input type.
    stepUp()Increments the value of a numeric input type by the value of the step attribute.
    stepDown()Decrements the value of a numeric input type by the value of the step attribute.
    checkValidity()Checks for validity but does not show a validation message. Returns true when valid and false when invalid.
    getForm()Gets the associated form, if one exists.
    reportValidity()Checks for validity and shows the browser’s validation message if the input is invalid.
    setCustomValidity()Sets a custom validation message. Pass an empty string to restore validity.message: string

    Learn more about methods.

    Events#

    NameDescriptionEvent detail
    pc-changeEmitted when an alteration to the input’s value is committed by the user.
    pc-inputEmitted when the input receives input.
    pc-focusEmitted when the input gains focus.
    pc-blurEmitted when the input loses focus (i.e., is blurred).
    pc-clearEmitted when the clear button is activated.
    pc-invalidEmitted when the form control has been checked for validity and its constraints aren’t satisfied.

    Learn more about events.

    Parts#

    NameDescription
    form-controlThe form control that wraps the label, input and hint.
    labelThe input’s label.
    inputThe input.
    hintThe input’s hint.
    comboboxThe container the wraps the prefix, suffix, input and clear icon.
    prefixThe container that wraps the prefix slot.
    suffixThe container that wraps the suffix slot.
    display-inputThe element that displays the input.
    clear-buttonThe clear button.

    Learn more about customising CSS parts.

    Importing#

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

    CDN (script tag) CDN (import) npm (import)

    To manually import this component from the CDN, copy this code snippet and paste it in your HTML.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.1/cdn/components/input/input.js"></script>

    To manually import this component from the CDN, copy this code snippet and paste it in your JavaScript file.

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.1/cdn/components/input/input.js";

    To manually import this component from npm, copy this code snippet and paste it in your JavaScript file.

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

    Dependencies#

    This component automatically imports these components: