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!

    Textarea

    <pc-textarea> 1.0.0-alpha.1 experimental

    Textareas collect data from the user and allow multiple lines of text.

    <pc-textarea></pc-textarea>
    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 textarea an accessible label. For labels that contain HTML, use the label slot instead.

    Edit

    Hints#

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

    Edit

    Rows#

    Use the rows attribute to change the number of text rows that get shown.

    Edit

    Placeholders#

    Use the placeholder attribute to add a placeholder.

    Edit

    Filled#

    Add the filled attribute to draw a filled textarea.

    Edit

    Disabled#

    Use the disabled attribute to disable the textarea.

    Edit

    Sizes#

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

    Edit

    Prevent resizing#

    By default, textareas can be resized vertically by the user. To prevent resizing, set the resize attribute to none.

    Edit

    Expand with content#

    Textareas will automatically resize to fit their content when resize is set to auto.

    Edit

    Properties#

    NameDescriptionReflectsDefault
    nameThe name of the textarea, submitted as a name/value pair with form data.
    Type: string
    ""
    valueThe current value of the textarea, submitted as a name/value pair with form data.
    Type: string
    ""
    sizeThe textarea’s size.
    Type: "small" | "medium" | "large"
    "medium"
    filledDraws a filled textarea control.
    Type: boolean
    false
    labelThe textarea’s label. If you need to display HTML, use the label slot instead.
    Type: string
    ""
    hintThe textarea’s hint. If you need to display HTML, use the hint slot instead.
    Type: string
    ""
    placeholderPlaceholder text to show as a hint when the textarea is empty.
    Type: string
    ""
    rowsThe number of rows to display by default.
    Type: number
    4
    resizeControls how the textarea can be resized.
    Type: "none" | "vertical" | "horizontal" | "both" | "auto"
    "vertical"
    disabledDisables the textarea.
    Type: boolean
    false
    readonlyMakes the textarea readonly.
    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 textarea must be filled in or not.
    Type: boolean
    false
    minlengthThe minimum length of text in the textarea that will be considered valid.
    Type: number | undefined
    maxlengthThe maximum length of text in the textarea that will be considered valid.
    Type: number | undefined
    autocapitalizeControls whether and how text is automatically capitalised as it is entered by the user.
    Type: "off" | "none" | "on" | "sentences" | "words" | "characters"
    "sentences"
    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 in form fields. Refer to this page on MDN for valid values.
    Type: string | undefined
    autofocusIndicates that the textarea should receive focus on page load.
    Type: boolean
    false
    enterkeyhintUsed to customise the label or icon of the Enter key on virtual keyboards.
    Type: "enter" | "done" | "go" | "next" | "previous" | "search" | "send"
    "enter"
    spellcheckEnable spellcheck on the textarea.
    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" | undefined
    defaultValueThe default value of the textarea. Primarily used for resetting the textarea.
    Type: string
    ""
    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
    labelThe textarea’s label. Alternatively, you can use the label attribute.
    hintText that describes how to use the textarea. Alternatively, you can use the hint attribute.

    Learn more about using slots.

    Methods#

    NameDescriptionArguments
    focus()Focuses the textarea.options: FocusOptions
    blur()Unfocuses the textarea (i.e., blurs it).
    select()Selects all the text in the textarea.
    getScrollPosition()Gets the textarea’s scroll position.
    setScrollPosition()Sets the textarea’s scroll position.position: { top?: number; left?: number }
    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"
    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 select 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-inputEmitted when the textarea receives input.
    pc-changeEmitted when an alteration to the textarea’s value is committed by the user.
    pc-focusEmitted when the textarea gains focus.
    pc-blurEmitted when the textarea loses focus.
    pc-invalidEmitted when the textarea 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, textarea and hint.
    baseThe internal textarea element’s wrapper.
    labelThe textarea’s label.
    hintThe textarea’s hint.
    textareaThe internal <textarea> element.

    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/textarea/textarea.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/textarea/textarea.js";

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

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