MANDATORY: Read Samples Before Implementation
STOP - You MUST read ALL sample files in the SAME folder as this SKILL.md before writing ANY code:
EntityViewTemplate.razorEntityViewTemplate.cs
Then read the target component .razor, .razor.cs, and related project files such as DTOs, enums, and shared styles.
If any sample file cannot be accessed: stop immediately, confirm the SKILL.md folder location, retry from that location, and if still inaccessible report which file is missing. Do not proceed with partial implementation or approximation.
MANDATORY: Match Sample Layout (Visual Structure)
When a sample exists, you MUST match the sample's visual structure, not only its data-loading behavior.
Required process:
- Reuse the sample's top-level component layout (hero header + main card) unless the user explicitly requests otherwise.
- If the sample uses shared utility classes (e.g.
ux-gradient-primary,ux-fade-in-up), verify they exist in the target app's styles (typically underwwwroot, such asux-token.cssorux-mudblazor.css) and then reuse them.
Required baseline layout (when supported by the target app):
- A hero header using
MudPaperwithClass="pa-4 mb-4 ux-gradient-primary"andElevation="0" - A main content card using
MudCardwithClass="ux-fade-in-up"andStyle="animation-delay: 0.1s"
Forbidden:
- Replacing the hero header with a different structure (e.g.
MudCardHeader) unless explicitly requested - Dropping the sample's utility classes when they exist in the target project
Preserve Existing Implementation
Use for: Read-only view or detail entity pages in Blazor with MudBlazor
Do NOT use for: Add or edit forms, search pages, dialogs, or non-Blazor projects
Source of truth: Existing .razor.cs file defines data loading, service calls, navigation, and the DTO structure
You MUST NOT:
- Modify existing backend methods such as
LoadEntity()orLoadEntityAsync() - Change service calls or their parameters
- Add, rename, or remove DTO properties
- Invent fields or services not present in the backing class
- Rewrite existing C# functionality
- Put C# logic in the
.razorfile using@code - Render editable inputs — this page is read-only
1. Data Loading
Load data through existing lifecycle methods and backing methods such as OnInitializedAsync(), OnParametersSetAsync(), or explicit load methods already present in .razor.cs.
Show a loading indicator while the data object is null, using the same pattern as the sample (MudProgressCircular inside a centered MudStack).
Do not display entity content until the data object is non-null.
2. Map DTO Properties to Read-Only Display
Render all scalar DTO properties as labeled read-only fields using MudText:
| Property Type | Display |
|---------------|---------|
| String / number | MudText Typo="Typo.body1" with MudText Typo="Typo.overline" label above |
| Boolean / status | MudChip with conditional Color and Variant |
| Enum | Resolved display label (not raw integer) in MudChip or MudText |
| Nullable object | Conditional section rendered only when non-null |
| Collection | Iterated with @foreach, each item in a MudPaper card |
Chip rules:
- Use
T="string"on everyMudChip - Match
Colorsemantics:Color.Successfor positive/active,Color.DefaultorColor.Errorfor inactive/negative - Match
Variantsemantics:Variant.Filledfor active,Variant.Outlinedfor inactive or neutral
Enum rules:
- Locate the real enum definition before referencing it
- Use verified member names only — never copy from sample code without confirming they match the target enum
3. Nullable Object Sections
Render optional nested objects inside an @if guard matching the existing null check in the backing class.
Do not render nested fields outside their guard block.
4. Child Collections
Render child collections with @foreach inside a guarded @if block.
- When the collection has items, render each in a
MudPapercard (outlined, rounded) usingMudGrid - When the collection is empty or null, render a
MudTextfallback message usingColor.Secondary - Never use
forloops with index variables for read-only collections —@foreachis correct here
5. Navigation Actions
Render navigation buttons at the bottom of the card in a right-aligned MudStack:
- Render an Edit button only when a matching edit route or method exists in
.razor.cs - Always render a Back button that calls the existing
Cancel()or equivalent navigation method - Never invent navigation methods or routes
Button placement:
- Use
Justify="Justify.FlexEnd"onMudStack Row="true",Spacing="2",AlignItems="AlignItems.Center"
6. Styling
- Prefer shared utility styles first
- Keep component-specific styles minimal
- Never modify existing shared styles, variables, or theme values
- Match the sample layout without introducing unnecessary wrappers
- If the sample uses shared utility classes (for example
ux-gradient-primary,ux-fade-in-up), verify they exist in the target app's styles (usually underwwwroot) and reuse them
Design context (if design.md is present)
If a design.md file exists in the project, read it before choosing MudBlazor component properties. Use it for:
- Button variant and fill preferences (
Variant.Filled/Variant.Outlined, gradient vs flat) Colorsemantics for primary, secondary, and error actions- Card elevation and hover behaviour
- Page header treatment (gradient clip text vs plain text, icon badge style)
- Chip
ColorandVariantsemantics for status display
design.md informs prop choices only — it does not override the sample's layout structure.
Definition of Done
- [ ] All properties displayed in
.razorexist on the DTO returned by the backing class - [ ] No
@codeblock was introduced in.razor - [ ] No editable inputs (e.g.
MudTextField,MudSelect) were rendered - [ ] Data is loaded through existing lifecycle or backing methods only
- [ ] A loading state is shown while the data object is null
- [ ] Nullable object sections are guarded by
@ifmatching existing backing logic - [ ] Child collections use
@foreachwith an empty-state fallback message - [ ] Enum values were verified against the real enum definition before use
- [ ] Navigation buttons call only existing methods or use existing routes
- [ ] Shared styles were preserved and component styling remained minimal
- [ ] Sample visual structure was matched (hero header + main card)
- [ ] Sample utility classes were verified to exist in the target project and reused when available