Radio
Radio buttons can be used to allow users to select only one of a predefined set of mutually exclusive options. Halfmoon comes with a custom radio button design which works across browsers.
Commenting
|
New message!
Jane Doe just sent you a new message.
|
Radio buttons can be used to allow users to select only one of a predefined set of mutually exclusive options. Halfmoon comes with a custom radio button design which works across browsers.
<!-- First radio button -->
<div class="custom-radio">
<input type="radio" name="radio-set-1" id="radio-1" value="radio-1">
<label for="radio-1">Radio 1</label>
</div>
<!-- Second radio button (checked by default) -->
<div class="custom-radio">
<input type="radio" name="radio-set-1" id="radio-2" checked="checked" value="radio-2">
<label for="radio-2">Radio 2</label>
</div>
The following things should be kept in mind when using radio buttons in Halfmoon:
By default, the containers with the class .custom-radio have the display: block property. However, they can be stacked horizontally by adding the .d-inline-block utility class to them.
<!-- Horizontally stacked radio buttons -->
<div class="custom-radio d-inline-block mr-10"> <!-- d-inline-block = display: inline-block, mr-10 = margin-right: 1rem (10px) -->
<input type="radio" name="radio-set-2" id="radio-3" value="radio-3">
<label for="radio-3">Radio 3</label>
</div>
<div class="custom-radio d-inline-block">
<input type="radio" name="radio-set-2" id="radio-4" value="radio-4">
<label for="radio-4">Radio 4</label>
</div>
Radio buttons can be disabled by adding the disabled="..." attribute to them.
<!-- Disabled radio buttons -->
<div class="custom-radio">
<input type="radio" name="radio-set-3" id="radio-5" disabled="disabled" value="radio-5">
<label for="radio-5">Radio 5 (disabled)</label>
</div>
<div class="custom-radio">
<input type="radio" name="radio-set-3" id="radio-6" checked="checked" disabled="disabled" value="radio-6">
<label for="radio-6">Radio 6 (disabled)</label>
</div>
As mentioned above, the <label> element is a requirement. When creating radio buttons 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 radio button with an empty label inside an input group.
<!-- Input group with radio button -->
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<!-- Radio button with empty label -->
<div class="custom-radio">
<input type="radio" name="radio-set-4" id="radio-7" value="">
<label for="radio-7" class="blank"></label>
</div>
</div>
</div>
<input type="text" class="form-control" placeholder="Input group with radio button">
</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 .