Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

@cargos/cs-modal

Package Overview
Dependencies
Maintainers
10
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cargos/cs-modal

Modal for Angular applications

latest
Source
npmnpm
Version
0.14.0
Version published
Weekly downloads
44
83.33%
Maintainers
10
Weekly downloads
 
Created
Source

Angular cs-modal

This library was generated with [Angular CLI].

Getting started

Step 1: Install cs-modal:

NPM

npm install --save @cargos/cs-modal

Step 2: Import the CsModalModule:

import { CsModalModule } from '@cargos/cs-modal';

@NgModule({
  declarations: [AppComponent],
  imports: [CsModalModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

Step 3: Import the csModal in AppComponent and initialize the settings:

import { csModal, Modal } from '@cargos/cs-modal';

export class AppComponent {

  public settingsModal: Observable<Modal>;

  constructor() {
    this.settingsModal = csModal.getSettings();
  }

}

Step 4: Declare cs-modal component in app.component.html:

<cs-modal [settings]="settingsModal"></cs-modal>

Step 5: Include style dependencies and a theme:

In angular.json, add to your project's styles array:

"styles": [
  "node_modules/material-icons/iconfont/material-icons.css",
  "node_modules/@cargos/cs-modal/styles/modal.css",
  "node_modules/@cargos/cs-modal/styles/sprintpass.theme.css"
]

Note: Only sprintpass.theme is available at the moment.

Settings

ModalParams<T> accepts the following options. T is an optional generic parameter representing the Angular component injected as modal content — it propagates type-safe access to modal.contentInstance in all callbacks.

KeyTypeDefaultDescription
titlestring''Modal title text
titleClassstring''CSS class applied to the title
titleAlign'left''center''right''center'Title alignment
contentModalContent''Modal body: string, component class, or async function
contentAlign'left''center''right''center'Content alignment
type'default''warning''error''success''info''default'Visual style variant
spinner'dots''circle''dots'Spinner style for async content
buttonsButtonOptions<T>[][]Action buttons
buttonsAlign'left''center''right''space-evenly''center'Buttons alignment
iconNamestring''Material icon name
iconFontClassstring'material-icons'Icon font class
iconAlign'left''center''right''center'Icon alignment
bgTheme'black''white''black'Overlay background color
theme'sprintpass''sprintpass'Visual theme
animation'scale''fade''fade'Open animation
closeAnimation'scale''fade''fade'Close animation
closeIconbooleanModalCallback<T>nullShow close icon. true closes the modal, a function overrides the behaviour
closeIconNamestring'close'Material icon name for the close button
columnClass'xsmall''small''medium''large''cover''small'Modal width
fontSize'small''medium''large''small'Base font size inside the modal
autoClosenumber0Auto-close delay in milliseconds (0 = disabled)
autoCloseActionModalCallback<T>string''Callback or label executed on auto-close
backgroundDismissbooleanModalCallback<T>nullDismiss on overlay click. true closes, a function overrides
backgroundDismissAnimation'none''shake''shake'Animation when dismissal is blocked
escapeKeybooleanModalCallback<T>nullDismiss on Escape key. true closes, a function overrides
maximizebooleanfalseShow maximize button
onContentReadyModalVoidCallback<T>nullCalled when the dynamic component is ready
onContentErrorModalVoidCallback<T>nullCalled when the dynamic component fails to load
zIndexnumber1000CSS z-index of the modal

Callback types

// Base type — T is the injected component, R is the return type
type ModalCallback<T = DynamicComponent, R = unknown> = (modal?: Modal<T>) => R;

type ModalVoidCallback<T>             = ModalCallback<T, void>;
type ModalBooleanCallback<T>          = ModalCallback<T, boolean>;
type ModalStringCallback<T>           = ModalCallback<T, string>;
type ModalObservableCallback<T>       = ModalCallback<T, Observable<unknown>>;
type ModalObservableStringCallback<T> = ModalCallback<T, Observable<string>>;

Methods

NameSignatureDescription
confirmconfirm<T>(settings: ModalParams<T>): Modal<T>Open a modal
successsuccess<T>(settings: ModalParams<T> | string): Modal<T>Open a success modal
warningwarning<T>(settings: ModalParams<T> | string): Modal<T>Open a warning modal
errorerror<T>(settings: ModalParams<T> | string): Modal<T>Open an error modal
closeclose(): voidClose the current modal

How to use

Basic usage

import { csModal } from '@cargos/cs-modal';

export class MyComponent {

  /* Optional: close the modal when the component is destroyed */
  ngOnDestroy() {
    csModal.close();
  }

  showModal() {
    csModal.confirm({
      title: 'Confirm',
      content: 'Are you sure?'
    });
  }

}

With a dynamic component (typed)

import { csModal, Modal, ButtonFactory } from '@cargos/cs-modal';
import { MyFormComponent } from './my-form.component';

csModal.confirm<MyFormComponent>({
  content: { componentClass: MyFormComponent },
  buttons: [
    ButtonFactory<MyFormComponent>('confirm', {
      action: ({ contentInstance }) => {
        return contentInstance.isFormValid();
      }
    })
  ],
  onContentReady: ({ contentInstance }) => {
    contentInstance.init();
  }
});

Further help

Coming soon.

Keywords

cs-modal

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts