diff --git a/libs/components/src/callout/callout.component.html b/libs/components/src/callout/callout.component.html
index 0e496db00ab..569daa643f3 100644
--- a/libs/components/src/callout/callout.component.html
+++ b/libs/components/src/callout/callout.component.html
@@ -18,14 +18,19 @@
@if (title) {
}
-
diff --git a/libs/components/src/callout/callout.component.ts b/libs/components/src/callout/callout.component.ts
index fd6e3e13d0d..b097e1b0914 100644
--- a/libs/components/src/callout/callout.component.ts
+++ b/libs/components/src/callout/callout.component.ts
@@ -1,7 +1,8 @@
-import { Component, computed, input } from "@angular/core";
+import { AfterViewInit, Component, computed, ElementRef, input, ViewChild } from "@angular/core";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
+import { A11yTitleDirective } from "../a11y";
import { SharedModule } from "../shared";
import { TypographyModule } from "../typography";
@@ -31,12 +32,12 @@ let nextId = 0;
@Component({
selector: "bit-callout",
templateUrl: "callout.component.html",
- imports: [SharedModule, TypographyModule],
+ imports: [A11yTitleDirective, SharedModule, TypographyModule],
})
-export class CalloutComponent {
+export class CalloutComponent implements AfterViewInit {
readonly type = input("info");
readonly icon = input();
- readonly title = input();
+ readonly title = input();
readonly truncate = input(false);
readonly useAlertRole = input(false);
readonly iconComputed = computed(() =>
@@ -44,10 +45,6 @@ export class CalloutComponent {
);
readonly titleComputed = computed(() => {
const title = this.title();
- if (title === null) {
- return undefined;
- }
-
const type = this.type();
if (title == null && defaultI18n[type] != null) {
return this.i18nService.t(defaultI18n[type]);
@@ -58,8 +55,16 @@ export class CalloutComponent {
protected readonly titleId = `bit-callout-title-${nextId++}`;
+ @ViewChild("content", { static: false })
+ private contentRef!: ElementRef;
+ contentText = "";
+
constructor(private i18nService: I18nService) {}
+ ngAfterViewInit() {
+ this.contentText = this.contentRef?.nativeElement?.textContent?.trim() ?? "";
+ }
+
protected readonly calloutClass = computed(() => {
switch (this.type()) {
case "danger":