Zum Hauptinhalt springen
VelinStyle v1.2.0
⌂ Home
  1. Docs
  2. Erste Schritte
  3. Modal

Modal 1.2.0

<velin-modal> is a centered dialog overlay with header, body, and optional footer slot. In 1.2.0, open/close lifecycle uses Fokus-manager for background inert and body scroll lock. English: Modal

Reifegrad: Dokumentiert als stabil in VelinStyle 1.2.0. Design Intelligence (Plan / Review / Agent-Meta) ist separat und Beta / Grundlage wo entsprechend angegeben.

Wann verwenden

Wann nicht verwenden

Einfaches Modal

Öffnen with open() or the open attribute. Set the sichtbar title with title (HTML-escaped). Standard slot is the body; use slot="footer" for actions.

This is a basic modal with a title and body content.

<button type="button" class="velin-btn velin-btn--primary"
        onclick="document.getElementById('myModal').open()">
  Open Modal
</button>

<velin-modal id="myModal" title="Modal title">
  <p>This is a basic modal body.</p>
  <button type="button" class="velin-btn velin-btn--primary" slot="footer"
          onclick="document.getElementById('myModal').close()">Done</button>
</velin-modal>

Place action Buttons in the named footer slot. They render in the dialog footer bar.

<velin-modal id="confirmUi" title="Save changes?">
  <p>Unsaved edits will be lost if you leave.</p>
  <button type="button" class="velin-btn velin-btn--outline" slot="footer"
          onclick="this.closest('velin-modal').close()">Cancel</button>
  <button type="button" class="velin-btn velin-btn--primary" slot="footer">Save</button>
</velin-modal>

Barrierefreiheit

Dark Mode, Responsivität, Bewegung, RTL

API

Attribut

AttributTypBeschreibung
openBooleanObserved — presence opens the modal
titleStringHeader title (escaped); drives aria-labelledby when set
aria-labelStringFallback name when title is empty

Slots & parts

NameArtBeschreibung
(Standard)SlotModal body
footerSlotFooter actions
overlay, dialog, header, body, footer, closeCSS partsShadow styling hooks

Methoden & events

APIBeschreibung
open()Sets open
close()Removes open; dispatches velin-close (bubbles)
velin-closeFired from close()

CSS-Variablen

VariableRolle
--velin-z-modalOverlay-Z-Index (Standard 500)
--velin-color-overlayBackdrop
--velin-color-surface-brightDialog background
--velin-radius-lgDialog radius
--velin-shadow-xlDialog shadow

Best practices & pitfalls