| name | tw-blazor |
| description | Razor file authoring — one @code at the top, markup, optional <style> last. Use when creating or editing .razor files, @code blocks, or in-file <style> tags. CSS placement: tw-blazor-css-strategy. App shell: tw-blazor-layout. |
.razor file order
- Directives (
@namespace, @inherits, @using, @inject, comments)
- One
@code { … } — omit if none or code-behind only
- Markup
- Optional
<style> last (Exception B — tw-blazor-css-strategy)
Never two @code blocks. Never @code after markup. Never <style> above markup.
Hand-written members live in @code. A .razor.cs exists only for attributes the C# source
generators and class-level analyzers must see ([Page], [Authorize], [CrossSliceReference]).
PageSourceGenerator does not run on .razor files. Do not put [Page] in @code or use
@page on a page that already has [Page].
@namespace TimeWarp.Architecture.Features.Example
@inherits BaseComponent
@code {
[Parameter] public string? Title { get; set; }
}
<div class="twe-example">@Title</div>
<style>
@(@"
.twe-example { color: var(--twe-ink); }
")
</style>