- Guide
- _Notification.cshtml
Notification Component Usage
The _Notification.cshtml component is a reusable notification/alert box component that displays an icon, title, and content message.
Parameters
The component accepts a tuple with the following parameters:
- Icon (string?, optional): SVG HTML string for the icon. If not provided, a default info icon will be displayed.
- Title (string, required): The title text displayed in bold.
- Content (string, required): The main content/message text.
- TitleColor (string?, optional): Color for the title text. Defaults to
#00A79D(teal). - BorderColor (string?, optional): Color for the right border accent. Defaults to
#00A79D(teal).
Usage Examples
Basic Usage (Required Parameters Only)
@await Html.PartialAsync("UI/_Notification", (
Icon: (string?)null,
Title: "تنوية",
Content: "هذا النص هو مثال لنص يمكن أن يستبدل في نفس المساحة.",
TitleColor: (string?)null,
BorderColor: (string?)null
))
With Custom Icon
@{
var customIcon = @"<svg width=""40"" height=""40"" viewBox=""0 0 40 40"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
<path d=""M0 20C0 8.95431 8.95431 0 20 0C31.0457 0 40 8.95431 40 20C40 31.0457 31.0457 40 20 40C8.95431 40 0 31.0457 0 20Z"" fill=""#F9FAFB"" />
<!-- Add your SVG paths here -->
</svg>";
}
@await Html.PartialAsync("UI/_Notification", (
Icon: customIcon,
Title: "تنوية",
Content: "هذا النص هو مثال لنص يمكن أن يستبدل في نفس المساحة.",
TitleColor: (string?)null,
BorderColor: (string?)null
))
With Custom Colors
@await Html.PartialAsync("UI/_Notification", (
Icon: (string?)null,
Title: "تحذير",
Content: "هذا تحذير مهم يجب الانتباه إليه.",
TitleColor: "#DC2626", // Red color
BorderColor: "#DC2626" // Red border
))
Complete Example (All Parameters)
@{
var warningIcon = @"<svg width=""40"" height=""40"" viewBox=""0 0 40 40"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
<path d=""M0 20C0 8.95431 8.95431 0 20 0C31.0457 0 40 8.95431 40 20C40 31.0457 31.0457 40 20 40C8.95431 40 0 31.0457 0 20Z"" fill=""#FEF3C7"" />
<!-- Warning icon paths -->
</svg>";
}
@await Html.PartialAsync("UI/_Notification", (
Icon: warningIcon,
Title: "تنبيه مهم",
Content: "هذا النص هو مثال لنص يمكن أن يستبدل في نفس المساحة، لقد تم توليد هذا النص من مولّد النص العربي.",
TitleColor: "#D97706", // Orange color
BorderColor: "#D97706" // Orange border
))
Styling
The component uses inline styles and Bootstrap classes:
- Background: White (
bg-white) - Border: 1px solid
#e4e7eawith a 6px right border accent - Padding:
p-3 - Border radius:
rounded - Flexbox layout with gap between icon and content
Notes
- If
Iconis null or empty, a default info icon will be displayed - The default icon color matches the
TitleColorparameter - The component is RTL-friendly (right-to-left layout)
- All text colors default to
#00A79D(teal) if not specified
@model (string? Icon, string Title, string Content, string? TitleColor, string? BorderColor)
@{
var titleColor = Model.TitleColor ?? "#00A79D";
var borderColor = Model.BorderColor ?? "#00A79D";
}
<div class="d-flex align-items-start gap-2 p-3 rounded bg-white"
style="border: 1px solid #e4e7ea; border-right: 6px solid @borderColor; color:#374151;">
<div>
@if (!string.IsNullOrEmpty(Model.Icon))
{
@Html.Raw(Model.Icon)
}
else
{
<!-- Default Info Icon -->
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 20C0 8.95431 8.95431 0 20 0C31.0457 0 40 8.95431 40 20C40 31.0457 31.0457 40 20 40C8.95431 40 0 31.0457 0 20Z" fill="#F9FAFB" />
<path d="M19.5752 19.7925C19.5173 19.7915 19.4504 19.7915 19.3678 19.7915C19.0227 19.7915 18.7428 19.5117 18.7428 19.1665C18.7428 18.8213 19.0227 18.5415 19.3678 18.5415L19.3965 18.5415C19.5675 18.5414 19.7523 18.5414 19.9083 18.5623C20.0911 18.5869 20.3246 18.6501 20.5211 18.8466C20.7176 19.0431 20.7808 19.2766 20.8053 19.4594C20.8263 19.6154 20.8262 19.8002 20.8262 19.9711L20.8262 24.1665C20.8262 24.5117 20.5463 24.7915 20.2012 24.7915C19.856 24.7915 19.5762 24.5117 19.5762 24.1665V19.9999C19.5762 19.9173 19.5761 19.8504 19.5752 19.7925Z" fill="@titleColor" />
<path d="M19.9928 15.8332C19.5326 15.8332 19.1595 16.2063 19.1595 16.6665C19.1595 17.1267 19.5326 17.4998 19.9928 17.4998H20.0003C20.4606 17.4998 20.8337 17.1267 20.8337 16.6665C20.8337 16.2063 20.4606 15.8332 20.0003 15.8332H19.9928Z" fill="@titleColor" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.041 19.9998C11.041 24.9474 15.0518 28.9582 19.9993 28.9582C24.9469 28.9582 28.9577 24.9474 28.9577 19.9998C28.9577 15.0523 24.9469 11.0415 19.9993 11.0415C15.0518 11.0415 11.041 15.0523 11.041 19.9998ZM19.9993 27.7082C15.7422 27.7082 12.291 24.257 12.291 19.9998C12.291 15.7426 15.7422 12.2915 19.9993 12.2915C24.2565 12.2915 27.7077 15.7426 27.7077 19.9998C27.7077 24.257 24.2565 27.7082 19.9993 27.7082Z" fill="@titleColor" />
</svg>
}
</div>
<div>
@if (!string.IsNullOrEmpty(Model.Title))
{
<h6 class="mb-2 fw-bold" style="color: @titleColor;">@Model.Title</h6>
}
@if (!string.IsNullOrEmpty(Model.Content))
{
<p class="mb-0" style="line-height: 1.6;">
@Model.Content
</p>
}
</div>
</div>