Checkbox
Checkboxes can be used to allow users to select single values for submission in a form (or not). Halfmoon comes with a custom checkbox design which works across browsers.
Commenting
|
New message!
Jane Doe just sent you a new message.
|
Checkboxes can be used to allow users to select single values for submission in a form (or not). Halfmoon comes with a custom checkbox design which works across browsers.
<!-- First checkbox -->
<div class="custom-checkbox">
<input type="checkbox" id="checkbox-1" value="">
<label for="checkbox-1">Checkbox 1</label>
</div>
<!-- Second checkbox (checked by default) -->
<div class="custom-checkbox">
<input type="checkbox" id="checkbox-2" value="" checked="checked">
<label for="checkbox-2">Checkbox 2</label>
</div>
The following things should be kept in mind when using checkboxes in Halfmoon:
By default, the containers with the class .custom-checkbox have the display: block property. However, they can be stacked horizontally by adding the .d-inline-block utility class to them.
<!-- Horizontally stacked checkboxes -->
<div class="custom-checkbox d-inline-block mr-10"> <!-- d-inline-block = display: inline-block, mr-10 = margin-right: 1rem (10px) -->
<input type="checkbox" id="checkbox-3" value="">
<label for="checkbox-3">Checkbox 3</label>
</div>
<div class="custom-checkbox d-inline-block">
<input type="checkbox" id="checkbox-4" value="">
<label for="checkbox-4">Checkbox 4</label>
</div>
Checkboxes can be disabled by adding the disabled="..." attribute to them.
<!-- Disabled checkboxes -->
<div class="custom-checkbox">
<input type="checkbox" id="checkbox-5" value="" disabled="disabled">
<label for="checkbox-5">Checkbox 5 (disabled)</label>
</div>
<div class="custom-checkbox">
<input type="checkbox" id="checkbox-6" value="" checked="checked" disabled="disabled">
<label for="checkbox-6">Checkbox 6 (disabled)</label>
</div>
As mentioned above, the <label> element is a requirement. When creating checkboxes with empty labels, the contents of the label should be kept empty, but the element should still be there. Also, the class .blank should be added to the label. This will remove the extra margin. The next example shows a checkbox with an empty label inside an input group.
<!-- Input group with checkbox -->
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<!-- Checkbox with empty label -->
<div class="custom-checkbox">
<input type="checkbox" id="checkbox-7" value="">
<label for="checkbox-7" class="blank"></label>
</div>
</div>
</div>
<input type="text" class="form-control" placeholder="Input group with checkbox">
</div>
Our goal is to make Halfmoon the go-to framework for building dashboards and tools on the web. We are already working on things like a form validator, number input, datepicker, multi-select (think Select2 without jQuery), tabs component, JSX docs, and so much more. You can learn more in the project roadmap.
However, we need your help to grow. So if you truly believe in our goal, please consider supporting us through Patreon.
The following is the highest tier, with a maximum of 1 sponsor.
(Also seen at the top of the page)
The following is the normal tier, with a maximum of 10 sponsors.
AYCD
Automation Done Right
Sponsor (9 available)
Halfmoon needs your support! Become a sponsor to place an image and description of your product here. Click here
The following people have generously decided to support Halfmoon.
Become a backer on Patreon .