1.0.0 • Published 3 years ago

@miraidesigns/radio v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Radio Buttons

Radio buttons allow users to select one option from a set of options.


HTML

<div class="mdf-radio">
    <input id="radio" class="mdf-radio__input" type="radio">

    <div class="mdf-radio__circle"></div>
</div>

Sass

// Include default styles without configuration
@forward '@miraidesigns/radio/styles';
// Configure appearance
@use '@miraidesigns/radio' with (
    $variable: value
);

@include radio.styles();

Examples

Some basic examples on how the module can be used.

Labels

To ensure proper alignment, wrap the radio button and label element inside a .mdf-control element.

<div class="mdf-control">
    <div class="mdf-radio">
        <input id="option-1" class="mdf-radio__input" type="radio" name="options">

        <div class="mdf-radio__circle"></div>
    </div>

    <label for="option-1">Option #1</label>
</div>

<div class="mdf-control">
    <div class="mdf-radio">
        <input id="option-2" class="mdf-radio__input" type="radio" name="options">

        <div class="mdf-radio__circle"></div>
    </div>

    <label for="option-2">Option #2</label>
</div>

Implementation

Classes

NameTypeDescription
mdf-controlParentWraps the radio and label element
mdf-radioParentRadio container element
mdf-radio--disabledModifierFades out the element and disabled all interaction
mdf-radio__inputChildInput element, visually hidden. Used to determine the :checked state. Child to .mdf-radio
mdf-radio__circleChildThe circle icon. Child to .mdf-radio