Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Pages and components

izzy add page adds a new page to your app with its route, its title and a container to start in. izzy add razor adds a component with no route, for a part you use on several pages. Neither needs an account. For a page that lists and edits a model's records, see Pages for a Model.

Add a page

Run it in your app's folder with the page's name:

bash
izzy add page --name MonthlyReports --nav

izzy writes Components/Pages/MonthlyReports.razor at the address /monthly-reports, titled "Monthly reports". With --nav, it adds a link to the page in the app's nav.

Components/Pages/MonthlyReports.razor
@page "/monthly-reports"

<PageTitle>Monthly reports</PageTitle>

<Container Size="ContainerSize.Md" Align="ContainerAlign.Start" Gutters="false">
    <Column Gap="new() { Base = 6, Md = 8 }">
        <PageHeader Title="Monthly reports" />
    </Column>
</Container>
Options of izzy add page
OptionWhat it does
--name <Name>The component's name and its file. Its words are the page's title.
--route <path>The page's address, such as reports or reports/{year:int}. Without it, the name in kebab case.
--folder <folder>The folder the file goes in, from the project's folder. Without it, Components/Pages.
--mode StaticWhere the page's C# runs: Static, Server, WebAssembly or Auto.
--layout <Layout>The layout component, such as EmptyLayout, when the page doesn't use the app's default.
--navAdds a link to the page in the app's nav.
--project <path>The app's project, when it isn't the folder you run izzy in.

izzy doesn't replace a page. When the file is already there, or another page has the route, it stops and names the file.

Render mode

A page is static unless you say otherwise: its C# runs on the server once for each request. --mode server writes @rendermode InteractiveServer on the page. --mode webassembly and --mode auto put the page in the app's .Client project, where it runs in the browser. In an app whose pages are all interactive, the page says nothing and takes the app's mode. See Render modes.

Add a component

bash
izzy add razor --name OrderSummary --folder Components/Shared

izzy writes Components/Shared/OrderSummary.razor, an empty component to fill in. When the folder is new, it adds the folder's @using line to _Imports.razor, so every page can write <OrderSummary />. Without --folder, the file goes in Components.

Name its parameters, and izzy writes a [Parameter] property for each. Give --parameter once per parameter, as its name and type:

bash
izzy add razor --name OrderList --parameter Title:string --parameter "Items:List<TItem>" --typeparam TItem --child-content
Components/OrderList.razor
@typeparam TItem
@* Order list: use it on a page as <OrderList>…</OrderList>. *@

@ChildContent

@code {
    [Parameter] public string? Title { get; set; }
    [Parameter] public List<TItem>? Items { get; set; }
    [Parameter] public RenderFragment? ChildContent { get; set; }
}
Options of izzy add razor
OptionWhat it does
--name <Name>The component's name and its file.
--folder <folder>The folder the file goes in, from the project's folder. Without it, Components.
--parameter <Name:type>A [Parameter] property, such as Title:string or Count:int. A name alone is a string. Give it once for each.
--child-contentTakes content between its tags as ChildContent, and shows it.
--typeparam <T>A generic type parameter, such as TItem. Separate two with a comma.
--code-behindWrites the C# in a .razor.cs partial class beside the component, instead of an @code block.
--cssAdds a .razor.css file whose styles apply to this component only, and a root element for them to style.
--project <path>The app's project, when it isn't the folder you run izzy in.

See the change first

Both commands take --dry-run, --diff and --json. See Previewing changes.

Connection lost

Rejoining the server…