Skip to content

nve-button

Selveste NVE-knappen. Bruk href for å gjøre den om til en link. Disse feltene skal ikke brukes: circle, caret og pill

Arvet fra: SlButton

html
<nve-button>NVE-knappen</nve-button>

Eksempler

Varianter

Bruk variant for å velge farge. default er standard. success og warning skal ikke brukes.

html
<nve-button>default</nve-button>
<nve-button variant="primary">primary</nve-button>
<nve-button variant="secondary">secondary</nve-button>
<nve-button variant="neutral">neutral</nve-button>
<nve-button variant="text">text</nve-button>
<nve-button variant="danger">danger</nve-button>

Størrelse

Bruk size for å endre størrelse. large er standard.

html
<nve-button size="small">small</nve-button>
<nve-button size="medium">medium</nve-button>
<nve-button>large</nve-button>

Disabled

Bruk disabled for å deaktivere knappen.

html
<nve-button disabled>deaktivert</nve-button> <nve-button>ikke deaktivert</nve-button>

Loading

Bruk loading for å legge til ei snurre.

html
<nve-button loading>loading</nve-button>

Spor

NavnBeskrivelse
(standard)The button's label.
prefixA presentational prefix icon or similar element.
suffixA presentational suffix icon or similar element.

Hendelser

NavnArvet fraBeskrivelse
sl-blurSlButtonEmitted when the button loses focus.
sl-focusSlButtonEmitted when the button gains focus.
sl-invalidSlButtonEmitted when the form control has been checked for validity and its constraints aren't satisfied.

Egenskaper

NavnAttributt-synkTypeStandardverdiArvet fraBeskrivelse
size'small' | 'medium' | 'large''large'
testIdstring''
buttonHTMLButtonElement | HTMLLinkElementSlButton
invalidbooleanfalseSlButton
titlestring''SlButton
variant'default' | 'primary' | 'success' | 'neutral' | 'warning' | 'danger' | 'text''default'SlButtonThe button's theme variant.
caretbooleanfalseSlButtonDraws the button with a caret. Used to indicate that the button triggers a dropdown menu or similar behavior.
disabledbooleanfalseSlButtonDisables the button.
loadingbooleanfalseSlButtonDraws the button in a loading state.
outlinebooleanfalseSlButtonDraws an outlined button.
pillbooleanfalseSlButtonDraws a pill-style button with rounded edges.
circlebooleanfalseSlButtonDraws a circular icon button. When this attribute is present, the button expects a single `<sl-icon>` in the default slot.
type'button' | 'submit' | 'reset''button'SlButtonThe type of button. Note that the default value is `button` instead of `submit`, which is opposite of how native `<button>` elements behave. When the type is `submit`, the button will submit the surrounding form.
namestring''SlButtonThe name of the button, submitted as a name/value pair with form data, but only when this button is the submitter. This attribute is ignored when `href` is present.
valuestring''SlButtonThe value of the button, submitted as a pair with the button's name as part of the form data, but only when this button is the submitter. This attribute is ignored when `href` is present.
hrefstring''SlButtonWhen set, the underlying button will be rendered as an `<a>` with this `href` instead of a `<button>`.
target'_blank' | '_parent' | '_self' | '_top'SlButtonTells the browser where to open the link. Only used when `href` is present.
relstring'noreferrer noopener'SlButtonWhen using `href`, this attribute will map to the underlying link's `rel` attribute. Unlike regular links, the default is `noreferrer noopener` to prevent security exploits. However, if you're using `target` to point to a specific tab/window, this will prevent that from working correctly. You can remove or change the default value by setting the attribute to an empty string or a value of your choice, respectively.
downloadstring | undefinedSlButtonTells the browser to download the linked file as this filename. Only used when `href` is present.
formstringSlButtonThe "form owner" to associate the button with. If omitted, the closest containing form will be used instead. The value of this attribute must be an id of a form in the same document or shadow root as the button.
formActionstringSlButtonUsed to override the form owner's `action` attribute.
formEnctype'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain'SlButtonUsed to override the form owner's `enctype` attribute.
formMethod'post' | 'get'SlButtonUsed to override the form owner's `method` attribute.
formNoValidatebooleanSlButtonUsed to override the form owner's `novalidate` attribute.
formTarget'_self' | '_blank' | '_parent' | '_top' | stringSlButtonUsed to override the form owner's `target` attribute.
validitySlButtonGets the validity state object
validationMessageSlButtonGets the validation message

Metoder

NavnParametreReturtypeArvet fraBeskrivelse
handleDisabledChangeSlButton
clickSlButtonSimulates a click on the button.
focus
options: FocusOptions
SlButtonSets focus on the button.
blurSlButtonRemoves focus from the button.
checkValiditySlButtonChecks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid.
getFormHTMLFormElement | nullSlButtonGets the associated form, if one exists.
reportValiditySlButtonChecks for validity and shows the browser's validation message if the control is invalid.
setCustomValidity
message: string
SlButtonSets a custom validation message. Pass an empty string to restore validity.

Deler

NavnBeskrivelse
baseThe component's base wrapper.
prefixThe container that wraps the prefix.
labelThe button's label.
suffixThe container that wraps the suffix.
caretThe button's caret icon, an `<sl-icon>` element.
spinnerThe spinner that shows when the button is in the loading state.