Zum Hauptinhalt springen Seitenleiste
Auf dieser Seite
Zum Inhaltsverzeichnis springen

Input

<pc-input> 0.4.0 experimental

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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

Eigenschaften

NameBeschreibungReflektiertStandard
typeThe type of input. Works the same as a native <input> element, but only a subset of types are supported.
Typ: "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.
Typ: string
""
valueThe current value of the input, submitted as a name/value pair with form data.
Typ: string
""
defaultValueThe default value of the input. Primarily used for resetting the input.
Typ: string
""
sizeThe input’s size.
Typ: "small" | "medium" | "large"
"medium"
filledDraws a filled input.
Typ: boolean
false
pillDraws a pill‐style input.
Typ: boolean
false
labelThe input’s label. If you need to display HTML, use the label slot instead.
Typ: string
""
hintThe input’s hint. If you need to display HTML, use the hint slot instead.
Typ: string
""
clearableAdds a clear button when the input is not empty.
Typ: boolean
false
disabledDisables the input.
Typ: boolean
false
placeholderPlaceholder text to show as a hint when the input is empty.
Typ: string
""
readonlyMakes the input readonly.
Typ: 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.
Typ: 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.
Typ: 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.
Typ: 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.
Typ: string
""
requiredIndicates if the input must be filled in or not.
Typ: boolean
false
patternA RegEx pattern to validate the input against.
Typ: string | undefined
minlengthThe minimum length of input that will be considered valid.
Typ: number | undefined
maxlengthThe maximum length of input that will be considered valid.
Typ: number | undefined
minThe input’s minimum value. Only applies when the input’s type is set to date or number.
Typ: number | string | undefined
maxThe input’s maximum value. Only applies when the input’s type is set to date or number.
Typ: 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.
Typ: number | "any" | undefined
autocapitalizeControls whether and how text input is automatically capitalised as it is entered by the user.
Typ: "off" | "none" | "on" | "sentences" | "words" | "characters"
"none"
autocorrectIndicates whether the browser’s autocorrect feature is on or off.
Typ: 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.
Typ: string | undefined
autofocusIndicates that the input should receive focus on page load.
Typ: boolean
enterkeyhintUsed to customise the label or icon of the Enter key on virtual keyboards.
Typ: "enter" | "done" | "go" | "next" | "previous" | "search" | "send"
"enter"
spellcheckEnables spellcheck on the input.
Typ: 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.
Typ: "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 Ein schreibgeschütztes Promise, das erfüllt ist, sobald die Komponente fertig aktualisiert wurde.

Erfahre mehr über Attribute und Eigenschaften.

Slots

NameBeschreibung
(Standard)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.

Erfahre mehr über die Benutzung von Slots.

Methoden

NameBeschreibungArgumente
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

Erfahre mehr über Methoden.

Events

NameBeschreibungEvent‐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.

Erfahre mehr über Events.

Parts

NameBeschreibung
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.

Erfahre mehr über das Anpassen von CSS‐Parts.

Importieren

Wenn du den Autoloader oder den Standard‐Loader nutzt, kannst du diesen Abschnitt überspringen. Falls du „Cherry Picking“ betreibst, kannst du die folgenden Snippets verwenden, um diese Komponente zu importieren.

CDN (Skript‐Tag)CDN (Import)npm (Import)

Um diese Komponente manuell vom CDN zu importieren, kannst du dieses Code‐Snippet kopieren und es in dein HTML einfügen.

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

Um diese Komponente manuell vom CDN zu importieren, kannst du dieses Code‐Snippet kopieren und es in deine JavaScript‐Datei einfügen.

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

Um diese Komponente manuell von npm zu importieren, kannst du dieses Code‐Snippet kopieren und es in deine JavaScript‐Datei einfügen.

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

Abhängigkeiten

Diese Komponente importiert automatisch folgende Komponenten:

Wir würden uns freuen, von dir zu hören. Kontaktiere uns bitte bei Fragen oder Anliegen, die du hast.

Du kannst uns per E‐Mail unter placer.coc.reports+contact@gmail.com erreichen.

Wir freuen uns darauf, von dir zu hören!

Alles klar!
Gefährliche Lande

Ui! Du bist in die gefährlichen Lande von Placer Toolkit geraten. Version 0 ist veraltet und entspricht nicht den EU‐Datenschutzstandards, einschließlich DSGVO.

Willst du die neuesten Kräfte, Sicherheit und Compliance? Bleib bei der aktuellen Version von Placer Toolkit!

Ups! Aufladen!

Unsere Website ist zu 100 % frei von Cookies! Wir legen großen Wert auf deine Privatsphäre und speichern daher keinerlei Cookies oder persönliche Informationen über dich.

Dein Browserverlauf bleibt sauber und deine Daten sind geschützt, ganz im Einklang mit modernen Datenschutzstandards wie der DSGVO. Genieße deinen Besuch ganz ohne digitale Cookies! 🍪🚫

Weitere Informationen findest du in unserer Datenschutzerklärung.

Alles klar!