You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/ui-kit/build-your-first-blazor-app-with-blocks.md
+27-28Lines changed: 27 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,30 @@
1
1
---
2
2
layout: post
3
-
title: Build your first Blazor app with our blocks | Syncfusion
4
-
description: Learn all about building your first Blazor app using our blocks from the Essential Blazor UI Kit in Syncfusion Essential Studio and more.
3
+
title: Build your first Blazor app with UI Kit blocks | Syncfusion
4
+
description: Build a Blazor Web App using blocks from the Essential UI Kit. Configure Tailwind or Bootstrap themes and add a Sign in block. Explore to more details.
5
5
platform: Blazor
6
6
control: UI Kit
7
7
documentation: ug
8
8
---
9
9
10
-
# Build your first Blazor App with our blocks
10
+
# Build your first Blazor App with UI Kit blocks
11
11
12
-
This tutorial guides you through building a Blazor Web App using Syncfusion's UI Kit blocks. It demonstrates how to set up a new Blazor Server project, choose between Tailwind CSS or Bootstrap 5.3 themes, and add a sign-in block in your application. The goal is to help developers quickly build responsive, modern web apps using a variety of prebuilt blocks with minimal effort.
12
+
This tutorial guides you through building a Blazor Web App using blocks from the Syncfusion Essential UI Kit for Blazor. It demonstrates how to create a new project, choose Tailwind CSS or Bootstrap 5.3 themes, and add a Sign in block. The goal is to help developers quickly build responsive, modern web apps using prebuilt blocks with minimal effort.
13
13
14
14
## Create a new Blazor App
15
-
A Blazor Web App is used for this example. To create a new app, follow the official setup guide [here](https://learn.microsoft.com/en-us/training/modules/build-your-first-blazor-web-app/3-exercise-configure-environment?pivots=vscode). This tutorial then walks through the step-by-step process of adding a simple sign-in block to the newly created app, named **MyBlazorApp**.
15
+
A Blazor Web App is used for this example. To create a new app, follow the Microsoft setup guide [here](https://learn.microsoft.com/training/modules/build-your-first-blazor-web-app/3-exercise-configure-environment?pivots=vscode). This tutorial then walks through adding a simple Sign in block to the newly created app named **MyBlazorApp**.
16
16
17
17
> This tutorial focuses on using Blazor Server rendering mode rather than Blazor WebAssembly.
18
18
19
19

20
20
21
-
## Setting up Tailwind CSS or Bootstrap 5.3 theme in the app
21
+
## Set up Tailwind CSS or Bootstrap 5.3 theme
22
22
23
23
After creating the new Blazor app named **MyBlazorApp**, open it in Visual Studio Code (which will be used throughout this walkthrough). The next step is to choose a theme, either Tailwind CSS or Bootstrap 5.3, in either light or dark mode, and configure the app accordingly.
24
24
25
25
### Tailwind CSS configuration
26
26
27
-
If you choose **Tailwind CSS** theme, follow these steps to configure it.
27
+
If the **Tailwind CSS** theme is selected, follow these steps to configure it.
28
28
29
29
1. In **Components -> App.razor** file, add the following code for light mode (`class="light"`) and dark mode (`class="dark"`) in the `<html>` tag.
30
30
@@ -40,7 +40,7 @@ If you choose **Tailwind CSS** theme, follow these steps to configure it.
40
40
<htmllang="en"class="dark">
41
41
```
42
42
43
-
2. In **Components -> App.razor** file, add the following scripts in the `<head>` tag. The main purpose of these scripts is to dynamically generate the appropriate Tailwind CSS classes at runtime based on the styles used in the application, and to replace the primary (highlight) color in the CSS with a custom indigo color palette.
43
+
2. In the **Components -> App.razor** file, add the following scripts in the `<head>` tag. These scripts generate Tailwind CSS classes at runtime based on the styles used in the application and replace the primary color with a custom indigo palette. This CDN approach is suitable for demos; for production builds, integrate Tailwind via a build pipeline.
@@ -70,9 +70,9 @@ If you choose **Tailwind CSS** theme, follow these steps to configure it.
70
70
}
71
71
</script>
72
72
```
73
-
> The Syncfusion<supstyle="font-size:70%">®</sup> Blazor components uses **Indigo** for light mode and **Cyan** for dark mode. To maintain a uniform appearance, change the primary color accordingly.
73
+
> Syncfusion<supstyle="font-size:70%">®</sup> Blazor components use **Indigo** for light mode and **Cyan** for dark mode. To maintain a uniform appearance, adjust the primary color accordingly.
74
74
75
-
3. In **Components -> App.razor** file, add the style oriented CDN link for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components in the `<head>` tag.
75
+
3. In the **Components -> App.razor** file, add the theme stylesheet CDN link for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components in the `<head>` tag.
76
76
77
77
- For **light mode**:
78
78
@@ -86,7 +86,7 @@ If you choose **Tailwind CSS** theme, follow these steps to configure it.
@@ -100,7 +100,7 @@ Now that the **Tailwind CSS** theme is configured for either light or dark mode
100
100
101
101
### Bootstrap 5.3 configuration
102
102
103
-
If you choose **Bootstrap 5.3** theme, follow these steps to configure it.
103
+
If the **Bootstrap 5.3** theme is selected, follow these steps to configure it.
104
104
105
105
1. In **Components -> App.razor** file, add the following code for light mode (`data-bs-theme="light"`) and dark mode (`data-bs-theme="dark"`) in the `<html>` tag.
106
106
@@ -116,13 +116,13 @@ If you choose **Bootstrap 5.3** theme, follow these steps to configure it.
116
116
<htmllang="en"data-bs-theme="dark">
117
117
```
118
118
119
-
2. In **Components -> App.razor** file, add the style oriented CDN link for **Bootstrap 5.3** theme in the `<head>` tag.
119
+
2. In the **Components -> App.razor** file, add the CDN link for the **Bootstrap 5.3** theme stylesheet in the `<head>` tag.
3. In **Components -> App.razor** file, add the style oriented CDN link for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components in the `<head>` tag.
125
+
3. In the **Components -> App.razor** file, add the theme stylesheet CDN link for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components in the `<head>` tag.
126
126
127
127
- For **light mode**:
128
128
@@ -136,7 +136,7 @@ If you choose **Bootstrap 5.3** theme, follow these steps to configure it.
@@ -154,26 +154,25 @@ Now that **MyBlazorApp** is set up with the desired theme configuration, the nex
154
154
155
155
### Steps to explore and copy block code snippets from the online demo
156
156
157
-
1. In the [online demo](https://blazor.syncfusion.com/essential-ui-kit), navigate to the **Authentication** category and select the **Sign In** block. This will direct you to the appropriate demo page.
157
+
1. In the [online demo](https://blazor.syncfusion.com/essential-ui-kit), navigate to the **Authentication** category and select the **Sign in** block. This opens the corresponding demo page.
158
158
159
159

160
160
161
-
2. On the demo page, go to the first demo, which showcases a simple sign-in block. Choose the desired theme, then switch from the **Preview** tab to the **Code** tab.
161
+
2. On the demo page, open the first demo, which showcases a simple Sign in block. Choose the desired theme, then switch from the **Preview** tab to the **Code** tab.
162
162
163
163

164
164
165
-
3. In the **Code** tab, copy the Razor (HTML) code using the **Copy to Clipboard** option and paste it into the **Components -> Pages -> Home.razor** file, replacing its content with the provided "Hello, world!" example.
165
+
3. In the **Code** tab, copy the Razor (HTML) code using the **Copy to Clipboard** option and paste it into the **Components -> Pages -> Home.razor** file, replacing the default "Hello, world!" content.
166
166
167
167

168
168
169
169
> Ensure that you do not remove the `@page` directive and `<PageTitle>` element while replacing the content. These are essential for routing and setting the page title.
170
170
171
-
172
-
4. If CSS is provided, copy the CSS code, create a new file **Components -> Pages -> Home.razor.css**, and paste the code into it. Similarly, if a C# code is provided, create a new file **Components -> Pages -> Home.razor.cs** and paste the C# code into it. Otherwise, you can ignore this step.
171
+
4. If CSS is provided, copy the CSS code, create a new file **Components -> Pages -> Home.razor.css**, and paste the code into it. If C# code is provided, create a new file **Components -> Pages -> Home.razor.cs** and paste the code into it. Otherwise, ignore this step.
173
172
174
173
### Steps to explore and copy block code snippets from the GitHub source
175
174
176
-
1. On [downloading](https://github.com/syncfusion/essential-ui-kit-for-blazor) and opening the GitHub source in Visual Studio Code, navigate to the following folder: **Components -> Pages -> BlocksSection**.
175
+
1. After [downloading](https://github.com/syncfusion/essential-ui-kit-for-blazor) and opening the source in Visual Studio Code, navigate to **Components -> Pages -> BlocksSection**.
177
176
178
177

179
178
@@ -189,38 +188,38 @@ Now that **MyBlazorApp** is set up with the desired theme configuration, the nex
189
188
190
189
## Steps to install and configure Syncfusion<supstyle="font-size:70%">®</sup> Blazor components
191
190
192
-
While copying and pasting the Razor (HTML) code, you'll notice that Syncfusion<supstyle="font-size:70%">®</sup> Blazor components are used. To incorporate them into **MyBlazorApp**, install the necessary packages and import the corresponding namespaces to the **Components -> _Imports.razor** file for the app to run.
191
+
While copying and pasting the Razor code, note that Syncfusion<supstyle="font-size:70%">®</sup> Blazor components are used. To incorporate them into **MyBlazorApp**, install the necessary packages and import the corresponding namespaces in **Components -> _Imports.razor** so the app can compile and run.
193
192
194
193
In the simple sign-in block, components such as textbox, checkbox and button are used. After copying and pasting Razor (HTML) code into the Razor file, open the **MyBlazorApp.csproj** file and add the required nuget packages: `Syncfusion.Blazor.Buttons` and `Syncfusion.Blazor.Inputs`. For more details about other Syncfusion<supstyle="font-size:70%">®</sup> Blazor component packages, refer to this [link](https://www.nuget.org/packages?q=Syncfusion.Blazor)
195
194
196
195

197
196
198
-
Once the necessary packages are added, run the following command via the terminal to install those packages.
197
+
After the packages are added, run the following command in the terminal to install them.
199
198
200
199
```bash
201
200
dotnet restore
202
201
```
203
202
204
-
After restoring the packages, import the required namespaces `Syncfusion.Blazor.Buttons` and `Syncfusion.Blazor.Inputs` in the _Imports.razor file to enable Syncfusion<supstyle="font-size:70%">®</sup> components in the application.
203
+
After restoring the packages, import the required namespaces `Syncfusion.Blazor.Buttons` and `Syncfusion.Blazor.Inputs` in **Components -> _Imports.razor** to enable Syncfusion<supstyle="font-size:70%">®</sup> components in the application.
Finally, again check the [online demo](https://blazor.syncfusion.com/essential-ui-kit) or the [GitHub repository](https://github.com/syncfusion/essential-ui-kit-for-blazor) and copy the required Razor (HTML) code for the simple sign-in block into your app as outlined in the previous topic.
207
+
Finally, revisit the [online demo](https://blazor.syncfusion.com/essential-ui-kit) or the [GitHub repository](https://github.com/syncfusion/essential-ui-kit-for-blazor) and copy the required Razor (HTML) code for the simple Sign in block into your app as outlined above.
209
208
210
209
## Steps to download and add assets to the app
211
210
212
-
If you want to view and experience the images used in our design, you can download the **assets** folder from the following [GitHub repository](https://github.com/syncfusion/essential-ui-kit-for-blazor/tree/master/UI_Blocks/wwwroot/assets), place it inside the **wwwroot** folder of **MyBlazorApp**, and modify the image URLs in the Razor (HTML) if necessary.
211
+
To use the images from the design, download the **assets** folder from the [GitHub repository](https://github.com/syncfusion/essential-ui-kit-for-blazor/tree/master/UI_Blocks/wwwroot/assets), place it inside the **wwwroot** folder of **MyBlazorApp**, and update image URLs in the Razor (HTML) file if necessary.
213
212
214
213
## Steps to run the app
215
214
216
-
Now that everything is set up in **MyBlazorApp**— including the Razor (HTML), CSS (if applicable), C# (if applicable), and assets (optional) — you are ready to build and launch the app. Type the following command in the terminal, and you will see a localhost URL provided by the Blazor development server.
215
+
With **MyBlazorApp**set up—including Razor markup, CSS (if applicable), C# (if applicable), and and assets (optional) — you can build and run the app. Run the following command in the terminal; a localhost URL will be provided by the Blazor development server.
217
216
218
217
```bash
219
218
dotnet run
220
219
```
221
220
222
221

223
222
224
-
To view the app in your browser, simply **Ctrl + Click** (or **Cmd + Click** on macOS) on the localhost URL displayed in the terminal. This will open the app in your default browser, allowing you to view and experience the simple sign-in block.
223
+
To view the app in a browser, **Ctrl+click** (or **Cmd+click** on macOS) the localhost URL displayed in the terminal. This opens the app in the default browserand displays the simple Sign in block.
225
224
226
225

0 commit comments