Skip to content

nve-checkbox

En avkrysningsboks. Ikke bruk `size`, i NVE bruker vi kun en størrelse på avkrysningsbokser.

Arvet fra: SlCheckbox

html
<nve-checkbox>Ja, jeg vil!</nve-checkbox>

Eksempler

Ledetekst

Teksten på høyre side kan legges inni nve-checkbox.

html
<nve-checkbox>Ledetekst</nve-checkbox>

Checked

checked er satt hvis boksen er krysset av og motsatt. Bruk indeterminate for å vise at man ikke har tatt stilling ennå.

html
<nve-checkbox checked>checked</nve-checkbox>
<nve-checkbox>unchecked</nve-checkbox>
<nve-checkbox indeterminate>indeterminate</nve-checkbox>

Disabled

Bruk disabled for å deaktivere boksen.

html
<nve-checkbox disabled>Disabled</nve-checkbox> <nve-checkbox>Enabled</nve-checkbox>

Spor

NavnBeskrivelse
(standard)The checkbox's label.

Hendelser

NavnArvet fraBeskrivelse
sl-blurSlCheckboxEmitted when the checkbox loses focus.
sl-changeSlCheckboxEmitted when the checked state changes.
sl-focusSlCheckboxEmitted when the checkbox gains focus.
sl-inputSlCheckboxEmitted when the checkbox receives input.
sl-invalidSlCheckboxEmitted when the form control has been checked for validity and its constraints aren't satisfied.

Egenskaper

NavnAttributt-synkTypeStandardverdiArvet fraBeskrivelse
inputHTMLInputElementSlCheckbox
titlestring''SlCheckbox
namestring''SlCheckboxThe name of the checkbox, submitted as a name/value pair with form data.
valuestringSlCheckboxThe current value of the checkbox, submitted as a name/value pair with form data.
size'small' | 'medium' | 'large''medium'SlCheckboxThe checkbox's size.
disabledbooleanfalseSlCheckboxDisables the checkbox.
checkedbooleanfalseSlCheckboxDraws the checkbox in a checked state.
indeterminatebooleanfalseSlCheckboxDraws the checkbox in an indeterminate state. This is usually applied to checkboxes that represents a "select all/none" behavior when associated checkboxes have a mix of checked and unchecked states.
defaultCheckedbooleanfalseSlCheckboxThe default value of the form control. Primarily used for resetting the form control.
formstring''SlCheckboxBy 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.
requiredbooleanfalseSlCheckboxMakes the checkbox a required field.
validitySlCheckboxGets the validity state object
validationMessageSlCheckboxGets the validation message

Metoder

NavnParametreReturtypeArvet fraBeskrivelse
handleDisabledChangeSlCheckbox
handleStateChangeSlCheckbox
clickSlCheckboxSimulates a click on the checkbox.
focus
options: FocusOptions
SlCheckboxSets focus on the checkbox.
blurSlCheckboxRemoves focus from the checkbox.
checkValiditySlCheckboxChecks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid.
getFormHTMLFormElement | nullSlCheckboxGets the associated form, if one exists.
reportValiditySlCheckboxChecks for validity and shows the browser's validation message if the control is invalid.
setCustomValidity
message: string
SlCheckboxSets a custom validation message. The value provided will be shown to the user when the form is submitted. To clear the custom validation message, call this method with an empty string.

Deler

NavnBeskrivelse
baseThe component's base wrapper.
controlThe square container that wraps the checkbox's checked state.
control--checkedMatches the control part when the checkbox is checked.
control--indeterminateMatches the control part when the checkbox is indeterminate.
checked-iconThe checked icon, an `<sl-icon>` element.
indeterminate-iconThe indeterminate icon, an `<sl-icon>` element.
labelThe container that wraps the checkbox's label.