Skip to content

nve-dialog

En dialogboks. Vil du ha ikon foran overskriften, bruk `icon`. Skal det ikke være mulig å trykke utenfor for å lukke dialogen, bruk `disableBackground`.

Arvet fra SlDialog.

Denne komponenten bygger på en Shoelace-komponent. Sjekk også dokumentasjonen i Shoelace for å få full oversikt over hvordan komponenten funker.

Feil / oppgaver / PR

Ingen som vi vet om. Hvis du finner noe muffens, registrer en feil under Issues i Github og merk den med nve-dialog.

 

html
<nve-button onclick="this.nextElementSibling.show()" class="open-dialog">Vis dialogen</nve-button>
<nve-dialog label="label">
  Innhold
  <div slot="footer">
    <nve-button onclick="this.parentElement.parentElement.hide()">Lukk</nve-button>
  </div>
</nve-dialog>

Spor

NavnBeskrivelse
labelteksten som skal vises i overskriften. Eller du kan bruke label-attributtet
bodyhovedinnholdet
footerfeltet i bunnen hvor knappene er plassert
(standard)The dialog's main content.
header-actionsOptional actions to add to the header. Works best with `<sl-icon-button>`.

Hendelser

NavnArvet fraBeskrivelse
sl-showSlDialogEmitted when the dialog opens.
sl-after-showSlDialogEmitted after the dialog opens and all animations are complete.
sl-hideSlDialogEmitted when the dialog closes.
sl-after-hideSlDialogEmitted after the dialog closes and all animations are complete.
sl-initial-focusSlDialogEmitted when the dialog opens and is ready to receive focus. Calling `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.
sl-request-closeSlDialogEmitted when the user attempts to close the dialog by clicking the close button, clicking the overlay, or pressing escape. Calling `event.preventDefault()` will keep the dialog open. Avoid using this unless closing the dialog will result in destructive behavior such as data loss.

Egenskaper

NavnTypeArvet fraBeskrivelseReflected
iconstring = ''Ikonet som skal vises
disableBackgroundboolean = falseHvis denne er satt, kan man ikke trykke utenfor dialogen for å lukke den.
modal = new Modal(this)SlDialogExposes the internal modal utility that controls focus trapping. To temporarily disable focus trapping and allow third-party modals spawned from an active Shoelace modal, call `modal.activateExternal()` when the third-party modal opens. Upon closing, call `modal.deactivateExternal()` to restore Shoelace's focus trapping.
dialogHTMLElement SlDialog
panelHTMLElement SlDialog
overlayHTMLElement SlDialog
openboolean = falseSlDialogIndicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state.
labelstring = ''SlDialogThe dialog's label as displayed in the header. You should always include a relevant label even when using `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead.
noHeaderboolean = falseSlDialogDisables the header. This will also remove the default close button, so please ensure you provide an easy, accessible way for users to dismiss the dialog.

Metoder

NavnParametreReturtypeArvet fraBeskrivelse
handleRequestClose
event: any
Stjålet fra shoelace eksempel. Hindrer at man lukker dialogen ved å trykke utenfor
updateIconOppdaterer ikonet som vises i dialogens tittel. Metoden søker først etter tittel-elementet i komponentens skygge-DOM. Hvis tittel-elementet finnes og `icon`-egenskapen er satt, oppdateres tittel-elementets stil for å inkludere det angitte ikonet. Hvis `icon`-egenskapen ikke er satt, settes ikoninnholdet til 'none' for å unngå å skape unødvendig mellomrom i layouten.
handleOpenChangeSlDialog
showSlDialogShows the dialog.
hideSlDialogHides the dialog

Deler

NavnBeskrivelse
baseThe component's base wrapper.
overlayThe overlay that covers the screen behind the dialog.
panelThe dialog's panel (where the dialog and its content are rendered).
headerThe dialog's header. This element wraps the title and header actions.
header-actionsOptional actions to add to the header. Works best with `<sl-icon-button>`.
titleThe dialog's title.
close-buttonThe close button, an `<sl-icon-button>`.
close-button__baseThe close button's exported `base` part.
bodyThe dialog's body.
footerThe dialog's footer.

Spesifikke CSS-variabler for komponent

NavnBeskrivelse
--widthThe preferred width of the dialog. Note that the dialog will shrink to accommodate smaller screens.
--header-spacingThe amount of padding to use for the header.
--body-spacingThe amount of padding to use for the body.
--footer-spacingThe amount of padding to use for the footer.