Primitives
Display an image that represents a user with a text fallback.
Import the Avatar primitives from ng-primitives/avatar.
import { NgpAvatar, NgpAvatarImage, NgpAvatarFallback } from 'ng-primitives/avatar';
Assemble the avatar directives in your template.
<span ngpAvatar>
<img ngpAvatarImage src="..." alt="..." />
<span ngpAvatarFallback>NG</span>
</span>
Create a reusable component that uses the NgpAvatar directive.
Generate a reusable avatar component using the Angular CLI.
ng g ng-primitives:primitive avatar
path: The path at which to create the component file.prefix: The prefix to apply to the generated component selector.component-suffix: The suffix to apply to the generated component class name.file-suffix: The suffix to apply to the generated component file name. Defaults to component.styles: How component styles should be generated. css (default) includes the full example styles; unstyled omits them entirely so you can style the component yourself.example-styles (deprecated): still supported for compatibility - true maps to styles: css, false maps to styles: unstyled.The following directives are available to import from the ng-primitives/avatar package:
You can configure the default options for all avatars in your application by using the provideAvatarConfig function in a providers array.
import { provideAvatarConfig } from 'ng-primitives/avatar';
bootstrapApplication(AppComponent, {
providers: [provideAvatarConfig({ delay: 1000 })],
});
Copyright © 2026 Angular Primitives
This site is powered by Netlify