Zum Hauptinhalt springen Seitenleiste
Auf dieser Seite
Zum Inhaltsverzeichnis springen

Radio Group

<pc-radio-group> 0.3.0 experimental

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

Radio groups are used to group multiple radios so they function as a single form control.

<pc-radio-group label="Select an option" name="group-1" value="option-1">
    <pc-radio value="option-1">Option 1</pc-radio>
    <pc-radio value="option-2">Option 2</pc-radio>
    <pc-radio value="option-3">Option 3</pc-radio>
</pc-radio-group>
Code Edit

Demos

Hints

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

Edit

Disabling radios

Radios can be disabled by adding the disabled attribute to the respective options inside the radio group.

Edit

Size

The size of radios will be determined by the radio group’s size attribute.

Edit

Radios also have a size attribute. This can be useful in certain situations, but it will be ignored when used inside of a radio group.

Required

Set the required attribute to make selecting an option mandatory. If a value hasn’t been selected, it will prevent the form from submitting and display an error message.

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. If you want to restore the default validation message, pass an empty string to the setCustomValidity() method.

Edit

Eigenschaften

NameBeschreibungReflektiertStandard
labelThe radio group’s label. This is required for proper accessibility. If you need to display HTML, use the label slot instead.
Typ: string
""
hintThe radio group’s hint. This is required for proper accessibility. If you need to display HTML, use the hint slot instead.
Typ: string
""
nameThe name of the radio group, submitted as a name/value pair with form data.
Typ: string
"option"
valueThe current value of the radio group, submitted as a name/value pair with form data.
Typ: string
""
sizeThe radio group’s size. This size will be applied to all child radios.
Typ: "small" | "medium" | "large"
"medium"
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 an option of the radio group must be chosen or not.
Typ: boolean
false
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 default slot where <pc-radio> elements are placed.
labelThe radio group’s label. This is required for proper accessibility. Alternatively, you can use the label attribute.
hintText that describes how to use the radio group. Alternatively, you can use the hint attribute.

Erfahre mehr über die Benutzung von Slots.

Methoden

NameBeschreibungArgumente
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 radio group is invalid.
setCustomValidity()Sets a custom validation message. Pass an empty string to restore validity.message: string
focus()Sets focus on the radio group.options: FocusOptions

Erfahre mehr über Methoden.

Events

NameBeschreibungEvent‐Detail
pc-changeEmitted when the radio group’s selected value changes.
pc-inputEmitted when the radio group receives user input.
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 radio group’s label.
inputThe radio group.
hintThe radio group’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.3/cdn/components/radio-group/radio-group.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/radio-group/radio-group.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/radio-group/radio-group.js";

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!