Skip to content

Commit 906ed69

Browse files
Merge pull request #4672 from syncfusion-content/BLAZ-895343-Hot
895343: Replaced Blazor TextBox code instead of CSS component
2 parents 3dd1baf + 4f675d4 commit 906ed69

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

blazor/textbox/getting-started-webapp.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,33 @@ N> [View Sample in GitHub](https://github.com/SyncfusionExamples/Blazor-Getting-
112112

113113
## Adding icons to the Blazor TextBox
114114

115-
A TextBox can be created with icon as a group by creating the parent `div` element with the class `e-input-group` and add the icon element as span with the class `e-input-group-icon`.
115+
You can add an icon to the TextBox component using the [AddIconAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfTextBox.html#Syncfusion_Blazor_Inputs_SfTextBox_AddIconAsync_System_String_System_String_System_Collections_Generic_Dictionary_System_String_System_Object__) method. Below is an example of how to implement this in your Blazor application:
116116

117-
{% tabs %}
118-
{% highlight razor %}
117+
```cshtml
118+
@using Syncfusion.Blazor.Inputs
119119
120-
<div class='e-input-group'>
121-
<input class='e-input' Placeholder='Date of Birth' type='text'>
122-
<span class='e-input-group-icon e-input-calendar'></span>
120+
<div id="sample" style="margin:130px auto;width:300px">
121+
<SfTextBox @ref=@TextBoxDropDownObj
122+
Created="@AddDateIcon"
123+
Placeholder="Enter Date"
124+
FloatLabelType="@FloatLabelType.Auto">
125+
</SfTextBox>
123126
</div>
124127
125-
<style>
126-
.e-input-group-icon:before {
127-
font-family: e-icons;
128-
}
129128
130-
.e-input-group .e-input-group-icon.e-input-calendar {
131-
font-size: 16px;
132-
}
129+
@code {
130+
SfTextBox TextBoxDropDownObj { get; set; }
133131
134-
.e-input-group-icon.e-input-calendar:before {
135-
content: "\e75e";
132+
private async void AddDateIcon()
133+
{
134+
if (TextBoxDropDownObj != null)
135+
{
136+
//Add icon to the TextBox
137+
await TextBoxDropDownObj.AddIconAsync("append", "e-icons e-date-icon");
136138
}
137-
</style>
138-
139-
{% endhighlight %}
140-
{% endtabs %}
139+
}
140+
}
141+
```
141142

142143
{% previewsample "https://blazorplayground.syncfusion.com/embed/hDhzZCKNfeoflPrc?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Blazor TextBox with Icon](./images/blazor-textbox-icons.png)" %}
143144

blazor/textbox/getting-started.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,33 @@ Add the Syncfusion Blazor TextBox component in the **~/Pages/Index.razor** file.
128128

129129
## Adding icons to the Blazor TextBox
130130

131-
A TextBox can be created with icon as a group by creating the parent `div` element with the class `e-input-group` and add the icon element as span with the class `e-input-group-icon`.
131+
You can add an icon to the TextBox component using the [AddIconAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfTextBox.html#Syncfusion_Blazor_Inputs_SfTextBox_AddIconAsync_System_String_System_String_System_Collections_Generic_Dictionary_System_String_System_Object__) method. Below is an example of how to implement this in your Blazor application:
132132

133-
{% tabs %}
134-
{% highlight razor %}
133+
```cshtml
134+
@using Syncfusion.Blazor.Inputs
135135
136-
<div class='e-input-group'>
137-
<input class='e-input' Placeholder='Date of Birth' type='text'>
138-
<span class='e-input-group-icon e-input-calendar'></span>
136+
<div id="sample" style="margin:130px auto;width:300px">
137+
<SfTextBox @ref=@TextBoxDropDownObj
138+
Created="@AddDateIcon"
139+
Placeholder="Enter Date"
140+
FloatLabelType="@FloatLabelType.Auto">
141+
</SfTextBox>
139142
</div>
140143
141-
<style>
142-
.e-input-group-icon:before {
143-
font-family: e-icons;
144-
}
145144
146-
.e-input-group .e-input-group-icon.e-input-calendar {
147-
font-size: 16px;
148-
}
145+
@code {
146+
SfTextBox TextBoxDropDownObj { get; set; }
149147
150-
.e-input-group-icon.e-input-calendar:before {
151-
content: "\e75e";
148+
private async void AddDateIcon()
149+
{
150+
if (TextBoxDropDownObj != null)
151+
{
152+
//Add icon to the TextBox
153+
await TextBoxDropDownObj.AddIconAsync("append", "e-icons e-date-icon");
152154
}
153-
</style>
154-
155-
{% endhighlight %}
156-
{% endtabs %}
155+
}
156+
}
157+
```
157158

158159
{% previewsample "https://blazorplayground.syncfusion.com/embed/hDhzZCKNfeoflPrc?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Blazor TextBox with Icon](./images/blazor-textbox-icons.png)" %}
159160

0 commit comments

Comments
 (0)