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

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

NavnAttributt-synkTypeStandardverdiArvet fraBeskrivelse
iconstring''Ikonet som skal vises
disableBackgroundbooleanfalseHvis denne er satt, kan man ikke trykke utenfor dialogen for å lukke den.
modalnew 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.
dialogHTMLElementSlDialog
panelHTMLElementSlDialog
overlayHTMLElementSlDialog
openbooleanfalseSlDialogIndicates 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.
noHeaderbooleanfalseSlDialogDisables 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
updated
changedProperties: any
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.