Checkbox

Select one or more options. Supports color variants, custom icons, animations, descriptions, a bordered container, groups, and disabled states.

Usage Example
@checkbox.Checkbox(checkbox.Config{
    ID:      "notifications",
    Label:   "Notifications",
    Checked: true,
})

Color Variants

Set Variant: Primary, Secondary, Info, Success, Warning, or Danger.

Color Variants
@checkbox.Checkbox(checkbox.Config{ID: "success", Label: "Success", Variant: checkbox.Success, Checked: true})

Custom Icons

Swap the check glyph with Icon: checkbox.IconXmark, IconMinus, or IconPlus.

Custom Icons
@checkbox.Checkbox(checkbox.Config{ID: "iconPlus", Label: "Plus", Icon: checkbox.IconPlus, Checked: true})

Animations

Set Animation: checkbox.AnimationSlideUp, AnimationScaleUp, or AnimationSlideDown for an animated check transition.

Animations
@checkbox.Checkbox(checkbox.Config{ID: "anim", Label: "Slide Up", Animation: checkbox.AnimationSlideUp, Checked: true})

With Description

Add HelperText (and HelperTextID for aria-describedby) for helper text under the label.

You only gonna get good news, promise.
With Description
@checkbox.Checkbox(checkbox.Config{
    ID:            "email",
    Label:         "Email Updates",
    HelperText:   "You only gonna get good news, promise.",
    HelperTextID: "emailDesc",
    Checked:       true,
})

With Container

Container: true wraps the checkbox and label in a bordered, justify-between container.

With Container
@checkbox.Checkbox(checkbox.Config{
    ID:        "containerCheck",
    Label:     "Notifications",
    Container: true,
    Checked:   true,
})

Checkbox Group

checkbox.CheckboxGroup renders a titled set of related checkboxes.

Notifications

Checkbox Group
@checkbox.CheckboxGroup(checkbox.GroupConfig{
    Title: "Notifications",
    Items: []checkbox.Config{
        {ID: "email", Label: "Email notifications", Value: "email", Checked: true},
        {ID: "push", Label: "Push notifications", Value: "push"},
        {ID: "sms", Label: "SMS alerts", Value: "sms", Checked: true},
    },
})

Disabled

Disabled: true blocks interaction in both the checked and unchecked states.

Disabled
@checkbox.Checkbox(checkbox.Config{ID: "off", Label: "Disabled unchecked", Disabled: true})
@checkbox.Checkbox(checkbox.Config{ID: "on", Label: "Disabled checked", Disabled: true, Checked: true})

API Reference

PropTypeDefaultDescription
IDstring""Unique id for the input (and label's for target).
Namestring""Form field name.
Valuestring""Form field value when checked.
Labelstring""Label text beside the box.
CheckedboolfalseInitial checked state.
DisabledboolfalseDisable interaction.
VariantVariantPrimaryColor: "primary", "secondary", "info", "success", "warning", "danger".
IconIconIconCheckCheck glyph: "check", "xmark", "minus", "plus".
AnimationAnimationAnimationNoneCheck transition: "", "slide-up", "scale-up", "slide-down".
HelperTextstring""Helper text below the label.
HelperTextIDstring""ID of the description for aria-describedby.
ContainerboolfalseWrap in a bordered container.