Zum Hauptinhalt springen Seitenleiste
Auf dieser Seite

Checkbox

<pc-checkbox> Seit  0.1.0 Experimentell

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

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

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

Checked

Use the checked attribute to enable the checkbox.

Edit

Indeterminate

Use the indeterminate attribute to make the checkbox indeterminate.

Edit

Disabled

Use the disabled attribute to disable the checkbox.

Edit

Sizes

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

Edit

Hint

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

Edit

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.

Edit

Eigenschaften

NameBeschreibungReflektiertStandard
nameThe name of the checkbox, submitted as a name/value pair with form data.
Typ: string
""
valueThe current value of the checkbox, submitted as a name/value pair with form data.
Typ: string | null
sizeThe checkbox’s size.
Typ: "small" | "medium" | "large"
"medium"
disabledDisables the checkbox.
Typ: boolean
false
checkedChecks the checkbox.
Typ: boolean
false
indeterminateSets the checkbox’s state to indeterminate. This is usually applied to checkboxes that represent a “Select all/none” behaviour when associated checkboxes have a mix of checked and unchecked states.
Typ: boolean
false
defaultChecked
checked
The default value of the checkbox. Primarily used for resetting the checkbox.
Typ: boolean
requiredIndicates that the checkbox must be checked.
Typ: boolean
false
hintThe checkbox’s hint. If you need to display HTML, use the hint slot instead.
Typ: string
""
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 checkbox’s label.
hintText that describes how to use the checkbox. Alternatively, you can use the hint attribute.

Erfahre mehr über die Benutzung von Slots.

Methoden

NameBeschreibungArgumente
click()Simulates a click on the checkbox.
focus()Focuses the checkbox.options: FocusOptions
blur()Unfocuses the checkbox (i.e., blurs it).

Erfahre mehr über Methoden.

Events

NameBeschreibungEvent‐Detail
changeEmitted when the checkbox’s state changes.Event
inputEmitted when the checkbox receives input.
focusEmitted when the checkbox gains focus.
blurEmitted when the checkbox loses focus.
pc-invalidEmitted when the checkbox has been checked for validity and its constraints aren’t satisfied.

Erfahre mehr über Events.

Parts

NameBeschreibung
baseThe component’s base wrapper.
controlThe container that wraps the checkbox’s state.
checkbox-checkedMatches the control part when the checkbox is checked.
checkbox-indeterminateMatches the control part when the checkbox is indeterminate.
icon-checkedThe checked icon, a <pc-icon> element.
icon-indeterminateThe indeterminate icon, a <pc-icon> element.
labelThe container that wraps the checkbox’s label.
hintThe container that wraps the checkbox’s hint.

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.4/cdn/components/checkbox/checkbox.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.4/cdn/components/checkbox/checkbox.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/checkbox/checkbox.js";

Abhängigkeiten

Diese Komponente importiert automatisch folgende Komponenten:

Wir würden uns freuen, von dir zu hören. Kontaktiere uns einfach bei Fragen oder Anliegen.

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!