Angular Portal and Overlay Rendering | ng-hub-ui-portal

Angular portal library for dynamic component, template and overlay rendering outside the current DOM tree with positioning control.

API reference

Here's the full contract for portal: 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 portal in with 15 inputs. Bind them like any Angular @Input.

NameTypeDefaultDescription
animationbooleanIf true, portal opening and closing will be animated. Default: true
ariaLabelledBystring`aria-labelledby` attribute value to set on the portal window
ariaDescribedBystring`aria-describedby` attribute value to set on the portal window
beforeDismiss() => boolean | Promise<boolean>Callback right before the portal will be dismissed. Return false to prevent dismissal.
containerstring | HTMLElementA selector specifying the element all new portal windows should be appended to. If not specified, will be `body`.
injectorInjectorThe `Injector` to use for portal content to enable dependency injection.
keyboardbooleanIf true, the portal will be closed when Escape key is pressed. Default: true
scrollablebooleanScrollable portal content (false by default).
windowClassstringA custom class to append to the portal window for custom styling and positioning.
portalDialogClassstringA custom class to append to the portal dialog container.
portalContentClassstringA custom class to append to the portal content wrapper.
headerSelectorstringCustom selector for the header element of the portal window. Useful for targeting specific portal sections.
footerSelectorstringCustom selector for the footer element of the portal window. Useful for targeting specific portal sections.
dismissSelectorstringCustom selector for elements that can trigger the dismissal of the portal window. Default: `[data-dismiss="portal"]`
closeSelectorstringCustom selector for elements that can trigger the closing of the portal window. Default: `[data-close="portal"]`

Outputs

No outputs documented yet.

Templates

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

NameDescriptionExample
Portal TemplateTemplate reference that can be passed to the HubPortal service for dynamic rendering<ng-template #portalTemplate> <div class="portal-content"> <div class="portal-header"> <h4>Portal Title</h4> <button data-dismiss="portal">×</button> </div> <div class="portal-body"> Portal content goes here </div> <div class="portal-footer"> <button data-dismiss="portal">Cancel</button> <button data-close="portal">OK</button> </div> </div> </ng-template> <!-- Open the portal --> <button (click)="portal.open(portalTemplate)">Open Portal</button>

CSS variables

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

Portal Base Variables

Core styling variables for portal structure and positioning

VariableDefaultTypeDescription
--portal-zindex1050number Z-index of the portal overlay
--portal-padding1remlength Default padding for portal content
--portal-margin0.5remlength Margin around portal dialog

Portal Appearance

Variables controlling portal colors, borders, and visual effects

VariableDefaultTypeDescription
--portal-bg#ffffffcolor Background color of portal content
--portal-color#212529color Text color of portal content
--portal-border-color#dee2e6color Border color of portal
--portal-border-width1pxborder Border width of portal
--portal-border-radius0.375remborder Border radius of portal corners
--portal-box-shadow0 0.5rem 1rem rgba(0, 0, 0, 0.15)shadow Box shadow for portal elevation

Portal Header & Footer

Styling variables for portal header and footer sections

VariableDefaultTypeDescription
--portal-header-padding1remlength Padding of portal header
--portal-header-border-color#dee2e6color Border color of portal header
--portal-footer-padding1remlength Padding of portal footer
--portal-footer-border-color#dee2e6color Border color of portal footer

Backdrop & Overlay

Variables controlling backdrop appearance and behavior

VariableDefaultTypeDescription
--portal-backdrop-bgrgba(0, 0, 0, 0.5)color Background color for portal backdrop
--portal-backdrop-zindex1040number Z-index of the backdrop (must be lower than portal z-index)

Styling and theming

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