Angular Modal Component | ng-hub-ui-modal

Accessible Angular modal component with stacking, fullscreen mode, templates, keyboard handling and CSS variables for standalone apps.

API reference

Here's the full contract for modal: everything you can bind, listen to, project and theme, gathered in one place. Wire up what you need and style what you want — it's standalone and signal-friendly.

Inputs

Dial modal in with 14 inputs. Bind them like any Angular @Input.

NameTypeDefaultDescription
animationbooleanIf true, modal opening and closing will be animated. Default: true
backdropboolean | "static"If true, the backdrop element will be created. Alternatively, specify "static" for a backdrop which doesn't close the modal on click. Default: true
centeredbooleanIf true, the modal will be centered vertically. Default: false
placementHubModalPlacementControls where the modal is placed within the viewport. Default: HubModalPlacement.Center
keyboardbooleanIf true, the modal will be closed when Escape key is pressed. Default: true
closeOnNavigationbooleanIf true, the modal will be closed when the user navigates back in browser history (history.back(), browser back button). Default: true
size"sm" | "lg" | "xl" | stringSize of the modal window
windowClassstringA custom class to append to the modal window
backdropClassstringA custom class to append to the modal backdrop
dismissSelectorstringCustom selector for elements that can trigger the dismissal of the modal window. Default: "[data-dismiss=\"modal\"]"
closeSelectorstringCustom selector for elements that can trigger the closing of the modal window. Default: "[data-close=\"modal\"]"
headerSelectorstringCustom selector for the header element of the modal window
footerSelectorstringCustom selector for the footer element of the modal window
dataanyAdditional data that needs to be passed to the modal window when it is opened

Outputs

No outputs documented yet.

Templates

Make it yours — 1 template slots let you project custom markup.

NameDescriptionExample
Modal TemplateTemplate reference that can be passed to the modal service<ng-template #modalTemplate let-close="close" let-dismiss="dismiss"> <div class="modal-header"> <h4 class="modal-title">Modal Title</h4> </div> <div class="modal-body"> Modal content goes here </div> <div class="modal-footer"> <button class="btn btn-secondary" (click)="dismiss()">Cancel</button> <button class="btn btn-primary" (click)="close('result')">OK</button> </div> </ng-template>

CSS variables

Theme every pixel with 17 CSS variables. Override them at :root or scope them to a wrapper.

Modal Base Variables

Core styling variables for modal structure and positioning

VariableDefaultTypeDescription
--bs-modal-zindex1055number Z-index of the modal
--bs-modal-width500pxlength Default modal width
--bs-modal-padding1remlength Padding around modal content
--bs-modal-margin0.5remlength Margin around modal dialog

Modal Appearance

Variables controlling modal colors, borders, and visual effects

VariableDefaultTypeDescription
--bs-modal-colorvar(--bs-body-color)color Text color of modal content
--bs-modal-bgvar(--bs-body-bg)color Background color of modal content
--bs-modal-border-colorvar(--bs-border-color-translucent)color Border color of modal
--bs-modal-border-widthvar(--bs-border-width)border Border width of modal
--bs-modal-border-radiusvar(--bs-border-radius-lg)border Border radius of modal
--bs-modal-box-shadow0 0.125rem 0.25rem rgba(0, 0, 0, 0.075)shadow Box shadow of modal

Modal Header

Styling variables for modal header section

VariableDefaultTypeDescription
--bs-modal-header-padding-x1remlength Horizontal padding of modal header
--bs-modal-header-padding-y1remlength Vertical padding of modal header
--bs-modal-header-border-colorvar(--bs-border-color)color Border color of modal header
--bs-modal-header-border-width0 0 var(--bs-border-width) 0border Border width of modal header

Modal Footer

Styling variables for modal footer section

VariableDefaultTypeDescription
--bs-modal-footer-gap0.5remlength Gap between elements in modal footer
--bs-modal-footer-border-colorvar(--bs-border-color)color Border color of modal footer
--bs-modal-footer-border-widthvar(--bs-border-width) 0 0 0border Border width of modal footer

Styling and theming

No styling examples are documented yet. This section will include customization recipes and theming examples.