`:
+
+```razor
+
+
+
+```
+
+## HTML Output
+
+The CheckBox component renders different HTML depending on whether text is provided:
+
+**With Text (TextAlign=Right, default):**
+```html
+
+
+ Label text
+
+```
+
+**With Text (TextAlign=Left):**
+```html
+
+ Label text
+
+
+```
+
+**Without Text:**
+```html
+
+```
+
+## Migration Notes
+
+When migrating from Web Forms to Blazor:
+
+1. Remove the `asp:` prefix and `runat="server"` attribute
+2. Replace `AutoPostBack="true"` with the `OnCheckedChanged` event handler
+3. Use `@bind-Checked` for two-way data binding instead of reading `Checked` in code-behind
+4. The `ID` property is obsolete in Blazor; use `@ref` to get a reference to the component instance
+
+### Before (Web Forms):
+```html
+
+```
+
+### After (Blazor):
+```razor
+
+```
+
+## Live Sample
+
+See the CheckBox component in action on the [live samples site](https://blazorwebformscomponents.azurewebsites.net/ControlSamples/CheckBox).
diff --git a/mkdocs.yml b/mkdocs.yml
index 70f0adaae..9bcece49c 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -65,6 +65,7 @@ nav:
- Editor Controls:
- AdRotator: EditorControls/AdRotator.md
- Button: EditorControls/Button.md
+ - CheckBox: EditorControls/CheckBox.md
- HiddenField: EditorControls/HiddenField.md
- HyperLink: EditorControls/HyperLink.md
- Image: EditorControls/Image.md
diff --git a/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Events.razor b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Events.razor
new file mode 100644
index 000000000..07aef23e3
--- /dev/null
+++ b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Events.razor
@@ -0,0 +1,56 @@
+@page "/ControlSamples/CheckBox/Events"
+
+CheckBox Event Samples
+
+
+
+OnCheckedChanged Event
+
+Last event time: @lastEventTime
+
+Two-way Binding
+
+
+
+Selected options:
+ @if (option1) { Option 1 }
+ @if (option2) { Option 2 }
+ @if (option3) { Option 3 }
+ @if (!option1 && !option2 && !option3) { None }
+
+
+Form Submission
+
+
+
+
+
+
+
+Submission result: @submitResult
+
+@code {
+ private string lastEventTime = "Never";
+ private bool option1 = false;
+ private bool option2 = false;
+ private bool option3 = false;
+
+ private FormData formData = new FormData();
+ private string submitResult = "";
+
+ private void HandleEvent(ChangeEventArgs e)
+ {
+ lastEventTime = DateTime.Now.ToString("HH:mm:ss");
+ }
+
+ private void HandleSubmit()
+ {
+ submitResult = $"Terms: {formData.AcceptTerms}, Newsletter: {formData.Subscribe}";
+ }
+
+ private class FormData
+ {
+ public bool AcceptTerms { get; set; }
+ public bool Subscribe { get; set; }
+ }
+}
diff --git a/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Index.razor b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Index.razor
new file mode 100644
index 000000000..27102ce22
--- /dev/null
+++ b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Index.razor
@@ -0,0 +1,48 @@
+@page "/ControlSamples/CheckBox"
+@using BlazorWebFormsComponents.Enums
+@using static BlazorWebFormsComponents.WebColor
+
+CheckBox Component Samples
+
+
+
+Basic CheckBox
+
+Agreed: @agreed
+
+Pre-checked CheckBox
+
+
+Text Alignment
+
+
+
+
+Disabled CheckBox
+
+
+
+
+CheckBox without Text
+
+Value: @noTextValue
+
+Styled CheckBox
+
+
+
+
+Event Handling
+
+Event fired: @eventCount times
+
+@code {
+ private bool agreed = false;
+ private bool noTextValue = false;
+ private int eventCount = 0;
+
+ private void HandleCheckedChanged(ChangeEventArgs e)
+ {
+ eventCount++;
+ }
+}
diff --git a/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Nav.razor b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Nav.razor
new file mode 100644
index 000000000..9e9a6c0b8
--- /dev/null
+++ b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Nav.razor
@@ -0,0 +1,5 @@
+
diff --git a/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Style.razor b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Style.razor
new file mode 100644
index 000000000..1e1ee947b
--- /dev/null
+++ b/samples/AfterBlazorServerSide/Components/Pages/ControlSamples/CheckBox/Style.razor
@@ -0,0 +1,24 @@
+@page "/ControlSamples/CheckBox/Style"
+@using BlazorWebFormsComponents.Enums
+@using static BlazorWebFormsComponents.WebColor
+
+CheckBox Style Samples
+
+
+
+CSS Classes
+
+
+
+
+Colors
+
+
+
+
+Width and Height
+
+
+@code {
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Checked.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Checked.razor
new file mode 100644
index 000000000..14586852d
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Checked.razor
@@ -0,0 +1,54 @@
+@code {
+
+ [Fact]
+ public void CheckBox_DefaultState_IsUnchecked()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input[type='checkbox']");
+ input.HasAttribute("checked").ShouldBeFalse();
+ }
+
+ [Fact]
+ public void CheckBox_WithCheckedTrue_RendersCheckedAttribute()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input[type='checkbox']");
+ input.HasAttribute("checked").ShouldBeTrue();
+ }
+
+ [Fact]
+ public void CheckBox_Click_TogglesCheckedState()
+ {
+ // Arrange
+ bool checkedValue = false;
+ var cut = Render(@ );
+
+ // Act
+ cut.Find("input").Change(true);
+
+ // Assert
+ checkedValue.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void CheckBox_ClickTwice_TogglesBackToUnchecked()
+ {
+ // Arrange
+ bool checkedValue = false;
+ var cut = Render(@ );
+
+ // Act
+ cut.Find("input").Change(true);
+ cut.Find("input").Change(false);
+
+ // Assert
+ checkedValue.ShouldBeFalse();
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Enabled.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Enabled.razor
new file mode 100644
index 000000000..b3d3a9c33
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Enabled.razor
@@ -0,0 +1,36 @@
+@code {
+
+ [Fact]
+ public void CheckBox_EnabledFalse_RendersDisabledAttribute()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ input.HasAttribute("disabled").ShouldBeTrue();
+ }
+
+ [Fact]
+ public void CheckBox_EnabledTrue_DoesNotRenderDisabledAttribute()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ input.HasAttribute("disabled").ShouldBeFalse();
+ }
+
+ [Fact]
+ public void CheckBox_DefaultEnabled_IsTrue()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ input.HasAttribute("disabled").ShouldBeFalse();
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Events.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Events.razor
new file mode 100644
index 000000000..b62dbdbb0
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Events.razor
@@ -0,0 +1,41 @@
+@code {
+
+ private int eventCallCount = 0;
+ private bool lastCheckedValue = false;
+
+ private void HandleCheckedChanged(ChangeEventArgs e)
+ {
+ eventCallCount++;
+ lastCheckedValue = (bool)e.Value;
+ }
+
+ [Fact]
+ public void CheckBox_OnCheckedChanged_FiresWhenClicked()
+ {
+ // Arrange
+ eventCallCount = 0;
+ var cut = Render(@ );
+
+ // Act
+ cut.Find("input").Change(true);
+
+ // Assert
+ eventCallCount.ShouldBe(1);
+ lastCheckedValue.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void CheckBox_CheckedChanged_FiresWithTwoWayBinding()
+ {
+ // Arrange
+ bool checkedValue = false;
+ var cut = Render(@ );
+
+ // Act
+ cut.Find("input").Change(true);
+
+ // Assert
+ checkedValue.ShouldBeTrue();
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/NoText.razor b/src/BlazorWebFormsComponents.Test/CheckBox/NoText.razor
new file mode 100644
index 000000000..d2dcbfd28
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/NoText.razor
@@ -0,0 +1,26 @@
+@code {
+
+ [Fact]
+ public void CheckBox_NoText_RendersInputOnly()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ cut.Find("input[type='checkbox']").ShouldNotBeNull();
+ Should.Throw(() => cut.Find("span"));
+ Should.Throw(() => cut.Find("label"));
+ }
+
+ [Fact]
+ public void CheckBox_NoText_AppliesStylesDirectlyToInput()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ input.ClassList.ShouldContain("my-checkbox");
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Style.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Style.razor
new file mode 100644
index 000000000..4dcf999e2
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Style.razor
@@ -0,0 +1,47 @@
+@using static BlazorWebFormsComponents.WebColor
+@using static BlazorWebFormsComponents.Enums.BorderStyle
+
+@code {
+
+ [Fact]
+ public void CheckBox_WithCssClass_AppliesClassToSpan()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var span = cut.Find("span");
+ span.ClassList.ShouldContain("custom-check");
+ }
+
+ [Fact]
+ public void CheckBox_WithBackColorAndForeColor_AppliesStyleToSpan()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var span = cut.Find("span");
+ span.HasAttribute("style").ShouldBeTrue();
+ var style = span.GetAttribute("style");
+
+ style.ShouldNotBeNull();
+ style.ShouldContain("background-color:LightBlue");
+ style.ShouldContain("color:Navy");
+ }
+
+ [Fact]
+ public void CheckBox_NoText_AppliesStylesToInput()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ input.ClassList.ShouldContain("custom-input");
+ input.HasAttribute("style").ShouldBeTrue();
+ var style = input.GetAttribute("style");
+ style.ShouldContain("background-color:Yellow");
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Text.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Text.razor
new file mode 100644
index 000000000..442ec4fe2
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Text.razor
@@ -0,0 +1,31 @@
+@code {
+
+ [Fact]
+ public void CheckBox_WithText_RendersSpanWithInputAndLabel()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ cut.Find("span").ShouldNotBeNull();
+ cut.Find("input[type='checkbox']").ShouldNotBeNull();
+ cut.Find("label").TextContent.ShouldBe("Accept terms");
+ }
+
+ [Fact]
+ public void CheckBox_WithText_LabelHasForAttribute()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var input = cut.Find("input");
+ var label = cut.Find("label");
+ var inputId = input.GetAttribute("id");
+ var labelFor = label.GetAttribute("for");
+
+ inputId.ShouldNotBeNullOrEmpty();
+ labelFor.ShouldBe(inputId);
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/TextAlign.razor b/src/BlazorWebFormsComponents.Test/CheckBox/TextAlign.razor
new file mode 100644
index 000000000..e932c3cec
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/TextAlign.razor
@@ -0,0 +1,41 @@
+@using BlazorWebFormsComponents.Enums
+
+@code {
+
+ [Fact]
+ public void CheckBox_TextAlignRight_RendersInputBeforeLabel()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var span = cut.Find("span");
+ span.FirstElementChild.TagName.ShouldBe("INPUT");
+ span.LastElementChild.TagName.ShouldBe("LABEL");
+ }
+
+ [Fact]
+ public void CheckBox_TextAlignLeft_RendersLabelBeforeInput()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var span = cut.Find("span");
+ span.FirstElementChild.TagName.ShouldBe("LABEL");
+ span.LastElementChild.TagName.ShouldBe("INPUT");
+ }
+
+ [Fact]
+ public void CheckBox_DefaultTextAlign_IsRight()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ var span = cut.Find("span");
+ span.FirstElementChild.TagName.ShouldBe("INPUT");
+ span.LastElementChild.TagName.ShouldBe("LABEL");
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents.Test/CheckBox/Visible.razor b/src/BlazorWebFormsComponents.Test/CheckBox/Visible.razor
new file mode 100644
index 000000000..38b29c153
--- /dev/null
+++ b/src/BlazorWebFormsComponents.Test/CheckBox/Visible.razor
@@ -0,0 +1,23 @@
+@code {
+
+ [Fact]
+ public void CheckBox_VisibleTrue_RendersCheckBox()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ cut.Find("span").ShouldNotBeNull();
+ }
+
+ [Fact]
+ public void CheckBox_VisibleFalse_DoesNotRender()
+ {
+ // Arrange & Act
+ var cut = Render(@ );
+
+ // Assert
+ cut.Markup.ShouldBeEmpty();
+ }
+
+}
diff --git a/src/BlazorWebFormsComponents/CheckBox.razor b/src/BlazorWebFormsComponents/CheckBox.razor
new file mode 100644
index 000000000..5472710a2
--- /dev/null
+++ b/src/BlazorWebFormsComponents/CheckBox.razor
@@ -0,0 +1,24 @@
+@inherits BaseStyledComponent
+
+@if (Visible)
+{
+ @if (!string.IsNullOrEmpty(Text))
+ {
+
+ @if (TextAlign == Enums.TextAlign.Left)
+ {
+ @Text
+
+ }
+ else
+ {
+
+ @Text
+ }
+
+ }
+ else
+ {
+
+ }
+}
diff --git a/src/BlazorWebFormsComponents/CheckBox.razor.cs b/src/BlazorWebFormsComponents/CheckBox.razor.cs
new file mode 100644
index 000000000..403dda4af
--- /dev/null
+++ b/src/BlazorWebFormsComponents/CheckBox.razor.cs
@@ -0,0 +1,37 @@
+using BlazorWebFormsComponents.Enums;
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Threading.Tasks;
+
+namespace BlazorWebFormsComponents
+{
+ public partial class CheckBox : BaseStyledComponent
+ {
+ private string _inputId = Guid.NewGuid().ToString("N");
+
+ [Parameter]
+ public bool Checked { get; set; }
+
+ [Parameter]
+ public EventCallback CheckedChanged { get; set; }
+
+ [Parameter]
+ public string Text { get; set; }
+
+ [Parameter]
+ public TextAlign TextAlign { get; set; } = TextAlign.Right;
+
+ [Parameter]
+ public EventCallback OnCheckedChanged { get; set; }
+
+ [Parameter, Obsolete("AutoPostBack is not supported in Blazor. Use OnCheckedChanged event instead.")]
+ public bool AutoPostBack { get; set; }
+
+ private async Task HandleChange(ChangeEventArgs e)
+ {
+ Checked = (bool)e.Value;
+ await CheckedChanged.InvokeAsync(Checked);
+ await OnCheckedChanged.InvokeAsync(e);
+ }
+ }
+}
diff --git a/src/BlazorWebFormsComponents/Enums/TextAlign.cs b/src/BlazorWebFormsComponents/Enums/TextAlign.cs
new file mode 100644
index 000000000..bed23c23f
--- /dev/null
+++ b/src/BlazorWebFormsComponents/Enums/TextAlign.cs
@@ -0,0 +1,8 @@
+namespace BlazorWebFormsComponents.Enums
+{
+ public enum TextAlign
+ {
+ Left,
+ Right
+ }
+}