Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Checkbox

    Native checkbox with an optional label and description, custom styled without JavaScript.

    You agree to our terms of service.

    You agree to our terms of service.

    You agree to our terms of service.

    At most one email per month.

    At most one email per month.

    Checkbox

    <x-markas.checkbox label="Accept terms and conditions" description="You agree to our terms of service." />
    import { Checkbox } from "@/components/markas/Checkbox";
    
    <Checkbox label="Accept terms and conditions" description="You agree to our terms of service." />
    import Checkbox from "@/components/markas/Checkbox.vue";
    
    <Checkbox label="Accept terms and conditions" description="You agree to our terms of service." />
    <script lang="ts">
      import Checkbox from "$lib/components/markas/Checkbox.svelte";
    </script>
    
    <div class="grid gap-4">
      <Checkbox name="terms" label="I agree to the terms of service" checked />
      <Checkbox
        name="updates"
        label="Send me product updates"
        description="At most one email per month."
      />
      <Checkbox name="archive" label="Archive automatically" disabled />
    </div>
    ---
    import Checkbox from "@/components/markas/Checkbox.astro";
    ---
    
    <div class="grid gap-4">
      <Checkbox name="terms" label="I agree to the terms of service" checked />
      <Checkbox
        name="updates"
        label="Send me product updates"
        description="At most one email per month."
      />
      <Checkbox name="archive" label="Archive automatically" disabled />
    </div>
    import { Component } from "@angular/core";
    import { Checkbox } from "./markas/checkbox.component";
    
    @Component({
      selector: "markas-example",
      imports: [Checkbox],
      template: `
        <div class="grid gap-4">
          <markas-checkbox
            name="terms"
            label="I agree to the terms of service"
            checked
          />
          <markas-checkbox
            name="updates"
            label="Send me product updates"
            description="At most one email per month."
          />
          <markas-checkbox name="archive" label="Archive automatically" disabled />
        </div>
      `,
    })
    export default class CheckboxExample {}

    Examples

    List with descriptions

    Email me when

    Replies to your posts and threads you follow.

    Any message that includes your username.

    Includes invitations from outside your workspace.

    Email me when

    Replies to your posts and threads you follow.

    Any message that includes your username.

    Includes invitations from outside your workspace.

    Email me when

    Replies to your posts and threads you follow.

    Any message that includes your username.

    Includes invitations from outside your workspace.

    Email me when

    Replies to your posts and threads you follow.

    Any message that includes your username.

    Includes invitations from outside your workspace.

    Email me when

    Replies to your posts and threads you follow.

    Any message that includes your username.

    Includes invitations from outside your workspace.

    Cards

    Add-ons

    Keep 30 days of snapshots. $5 per month.

    Replies within 4 hours on business days. $20 per month.

    Serve your site from your own domain. Free.

    Add-ons

    Keep 30 days of snapshots. $5 per month.

    Replies within 4 hours on business days. $20 per month.

    Serve your site from your own domain. Free.

    Add-ons

    Keep 30 days of snapshots. $5 per month.

    Replies within 4 hours on business days. $20 per month.

    Serve your site from your own domain. Free.

    Add-ons

    Keep 30 days of snapshots. $5 per month.

    Replies within 4 hours on business days. $20 per month.

    Serve your site from your own domain. Free.

    Add-ons

    Keep 30 days of snapshots. $5 per month.

    Replies within 4 hours on business days. $20 per month.

    Serve your site from your own domain. Free.

    States

    Editor defaults are managed by your organization.

    Editor defaults are managed by your organization.

    Editor defaults are managed by your organization.

    Editor defaults are managed by your organization.

    Editor defaults are managed by your organization.

    Horizontal

    Notify me by
    Notify me by
    Notify me by
    Notify me by
    Notify me by

    Installation

    npx markasui@latest add checkbox

    Usage

    <x-markas.checkbox name="terms" label="I agree to the terms of service" required />
    <x-markas.checkbox name="updates" label="Send me product updates" description="At most one email per month." :checked="old('updates')" />
    import { Checkbox } from "@/components/markas/Checkbox";
    
    <Checkbox name="terms" label="I agree to the terms of service" required />
    <Checkbox
      name="updates"
      label="Send me product updates"
      description="At most one email per month."
      defaultChecked
    />
    <script setup lang="ts">
    import { ref } from "vue";
    import Checkbox from "@/components/markas/Checkbox.vue";
    
    const updates = ref(false);
    </script>
    
    <template>
      <Checkbox
        v-model="updates"
        name="updates"
        label="Send me product updates"
        description="At most one email per month."
      />
    </template>
    <script lang="ts">
      import Checkbox from "$lib/components/markas/Checkbox.svelte";
    
      let updates = $state(false);
    </script>
    
    <Checkbox
      bind:checked={updates}
      name="updates"
      label="Send me product updates"
      description="At most one email per month."
    />
    ---
    import Checkbox from "@/components/markas/Checkbox.astro";
    ---
    
    <Checkbox name="terms" label="I agree to the terms of service" required />
    <Checkbox name="updates" label="Send me product updates" description="At most one email per month." checked />

    No client script: the checkbox is a native input.

    import { Component, signal } from "@angular/core";
    import { Checkbox } from "./markas/checkbox.component";
    
    @Component({
      selector: "app-preferences",
      imports: [Checkbox],
      template: `
        <markas-checkbox
          [(checked)]="updates"
          name="updates"
          label="Send me product updates"
          description="At most one email per month."
        />
      `,
    })
    export class Preferences {
      readonly updates = signal(false);
    }
    • Extra attributes (name, value, required, class) go to the <input> element.
    • The checked look uses CSS :checked (the checked: and peer-checked: variants), not data-state, so it stays correct without JavaScript.
    • The component has no built-in text. Translate label and description directly.

    Props

    NameTypeDefaultDescription
    labelstring-Label text next to the box, linked through for/id.
    descriptionstring-Supporting text below the label, linked through aria-describedby.
    checked / defaultChecked / v-model / bind:checkedbooleanfalseChecked state. Blade and Astro use the checked attribute, React checked or defaultChecked, Vue v-model, Svelte bind:checked, Angular checked or [(checked)].
    disabledbooleanfalseDisables the checkbox and dims the label.
    idstringautoInput id. Generated when empty.
    checkedChangeoutput<boolean>-Angular only. Emits the new state every time the checkbox changes.

    Accessibility

    • Uses a native checkbox input, so Space toggles it and screen readers announce its state.
    • The label is linked through for and id, so clicking the label toggles the box too.
    • The check icon is decorative (aria-hidden), the visual state follows :checked.

    Related components

    More form components with the same classes in every framework.