Build Blazor WebAssembly With Ant Design Blazor

Introduction

In the past years, front-end web development has been dominated by Javascript-based framework React, Angular, and Vue, while Blazor web assembly(wasm), a production-ready front-end framework base on .Net runtime, has supplied an…


This content originally appeared on DEV Community and was authored by YongQuan

Introduction

In the past years, front-end web development has been dominated by Javascript-based framework React, Angular, and Vue, while Blazor web assembly(wasm), a production-ready front-end framework base on .Net runtime, has supplied another choice especially for C# developers. With the default Blazor wasm template, we can create a SPA with a nice-look UI. Alternatively, we can also use Ant Design Blazor, a modern Blazor template with high-quality components, to build rich and interactive interfaces. In this article, we will build Blazor projects with Ant Design of Blazor templates and components.

Create Blazor project with Ant Design Template

To start with it, we need firstly install Ant Design Template.
$ dotnet new --install AntDesign.Templates
Alt Text
With the template installed successfully, we can now create a Blazor project.
$ dotnet new antdesign -o MyAntDesignApp
Alt Text
Now we can run it with Visual Studio 2022.
Alt Text
Alt Text
We can add an ant-design button to see the effect.
Alt Text
Alt Text
There is also an option --full to create a project with comprehensive components.
$ dotnet new antdesign -o MyFullAntDesignApp --full
Alt Text
Alt Text
Alt Text

Import Ant Design of Blazor to Existing Project

We can also import Ant Design of Blazor to existing projects very easily.
Imagining we have an existing Blazor wasm project.
Alt Text
Firstly we install the package.
$ dotnet add package AntDesign
Alt Text
We can also find it through NuGet.
Alt Text
Then we register the service at Program.cs.
builder.Services.AddAntDesign();
Alt Text
Then we add the links of css and js to index.html.


Alt Text
To use it globally, we can add the using statement at _Imports.razor.
Alt Text
To display the pop-up component dynamically, we need add the AntContainer component in App.razor.
Alt Text
Now we can add an ant-design button as well.
Alt Text
Alt Text

Conclusion

We have briefly gone through how to create a Blazor wasm with Ant Design of Blazor from scratch, as well as how to add Ant Design of Blazor template into an existing project. With worldwide popular ant-design components, we can easily create an attractive responsive SPA in the .Net ecosystem just like what React, Angular, and Vue do in Javascript. To know more about Ant Design of Blazor, we can refer to https://antblazor.com/en-US/


This content originally appeared on DEV Community and was authored by YongQuan


Print Share Comment Cite Upload Translate Updates
APA

YongQuan | Sciencx (2021-08-29T12:05:36+00:00) Build Blazor WebAssembly With Ant Design Blazor. Retrieved from https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/

MLA
" » Build Blazor WebAssembly With Ant Design Blazor." YongQuan | Sciencx - Sunday August 29, 2021, https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/
HARVARD
YongQuan | Sciencx Sunday August 29, 2021 » Build Blazor WebAssembly With Ant Design Blazor., viewed ,<https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/>
VANCOUVER
YongQuan | Sciencx - » Build Blazor WebAssembly With Ant Design Blazor. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/
CHICAGO
" » Build Blazor WebAssembly With Ant Design Blazor." YongQuan | Sciencx - Accessed . https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/
IEEE
" » Build Blazor WebAssembly With Ant Design Blazor." YongQuan | Sciencx [Online]. Available: https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/. [Accessed: ]
rf:citation
» Build Blazor WebAssembly With Ant Design Blazor | YongQuan | Sciencx | https://www.scien.cx/2021/08/29/build-blazor-webassembly-with-ant-design-blazor/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.