Kotak centang native dengan label dan deskripsi opsional, tampilan kustom tanpa JavaScript.
You agree to our terms of service.
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.
<x-markas.checkbox label="Accept terms and conditions" /><x-markas.checkbox label="Accept terms and conditions" disabled /><x-markas.checkbox label="Accept terms and conditions" description="You agree to our terms of service." /><x-markas.checkbox label="Accept terms and conditions" description="You agree to our terms of service." disabled />import { Checkbox } from "@/components/markas/Checkbox";
<Checkbox label="Accept terms and conditions" />import { Checkbox } from "@/components/markas/Checkbox";
<Checkbox label="Accept terms and conditions" disabled />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";
<Checkbox label="Accept terms and conditions" description="You agree to our terms of service." disabled />import Checkbox from "@/components/markas/Checkbox.vue";
<Checkbox label="Accept terms and conditions" />import Checkbox from "@/components/markas/Checkbox.vue";
<Checkbox label="Accept terms and conditions" disabled />import Checkbox from "@/components/markas/Checkbox.vue";
<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." disabled />Contoh
Daftar dengan deskripsi
<fieldset class="min-w-0">
<legend class="mb-3 text-sm font-medium text-ink">Email me when</legend>
<div class="grid gap-4">
<x-markas.checkbox name="comments" label="Someone comments" description="Replies to your posts and threads you follow." checked />
<x-markas.checkbox name="mentions" label="Someone mentions me" description="Any message that includes your username." checked />
<x-markas.checkbox name="invites" label="I am invited to a project" description="Includes invitations from outside your workspace." />
</div>
</fieldset>Kartu
Status
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.
<div class="grid gap-4">
<x-markas.checkbox name="line_numbers" label="Show line numbers" />
<x-markas.checkbox name="wrap" label="Wrap long lines" checked />
<x-markas.checkbox name="format" label="Format on save" disabled />
<x-markas.checkbox name="autosave" label="Auto save" checked disabled />
<p class="text-sm text-muted">Editor defaults are managed by your organization.</p>
</div>Horizontal
<fieldset class="min-w-0">
<legend class="mb-3 text-sm font-medium text-ink">Notify me by</legend>
<div class="flex flex-wrap gap-x-6 gap-y-3">
<x-markas.checkbox name="channels[]" value="email" label="Email" checked />
<x-markas.checkbox name="channels[]" value="sms" label="SMS" />
<x-markas.checkbox name="channels[]" value="push" label="Push" checked />
<x-markas.checkbox name="channels[]" value="slack" label="Slack" />
</div>
</fieldset>Instalasi
npx markasui@latest add checkboxpnpm dlx markasui@latest add checkboxyarn dlx markasui@latest add checkboxbunx --bun markasui@latest add checkbox- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
resources/views/components/markas/checkbox.blade.php.
- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Checkbox.tsx.
- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Checkbox.vue.
- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/lib/components/markas/Checkbox.svelte.
- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Checkbox.astro.
- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/app/markas/checkbox.component.ts.
Pemakaian
<x-markas.checkbox name="syarat" label="Saya setuju dengan syarat layanan" required />
<x-markas.checkbox name="kabar" label="Kirimi saya kabar terbaru" description="Paling banyak satu email per bulan." :checked="old('kabar')" />import { Checkbox } from "@/components/markas/Checkbox";
<Checkbox name="syarat" label="Saya setuju dengan syarat layanan" required />
<Checkbox
name="kabar"
label="Kirimi saya kabar terbaru"
description="Paling banyak satu email per bulan."
defaultChecked
/><script setup lang="ts">
import { ref } from "vue";
import Checkbox from "@/components/markas/Checkbox.vue";
const kabar = ref(false);
</script>
<template>
<Checkbox
v-model="kabar"
name="kabar"
label="Kirimi saya kabar terbaru"
description="Paling banyak satu email per bulan."
/>
</template><script lang="ts">
import Checkbox from "$lib/components/markas/Checkbox.svelte";
let updates = $state(false);
</script>
<Checkbox
bind:checked={updates}
name="updates"
label="Kirimi saya kabar produk"
description="Paling banyak satu email per bulan."
/>---
import Checkbox from "@/components/markas/Checkbox.astro";
---
<Checkbox name="terms" label="Saya setuju dengan ketentuan layanan" required />
<Checkbox name="updates" label="Kirimi saya kabar produk" description="Paling banyak satu email per bulan." checked />Tanpa script klien: checkbox-nya input native.
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="Kirimi saya kabar produk"
description="Paling banyak satu email per bulan."
/>
`,
})
export class Preferences {
readonly updates = signal(false);
}- Atribut tambahan (
name,value,required,class) diteruskan ke elemen<input>. - Tampilan tercentang memakai CSS
:checked(varianchecked:danpeer-checked:), bukandata-state, sehingga tetap benar tanpa JavaScript. - Komponen ini tidak punya teks bawaan. Cukup isi
labeldandescriptiondalam Bahasa Indonesia.
Props
| Nama | Tipe | Default | Keterangan |
|---|---|---|---|
label | string | - | Teks label di samping kotak, terhubung lewat for/id. |
description | string | - | Teks penjelas di bawah label, dihubungkan lewat aria-describedby. |
checked / defaultChecked / v-model / bind:checked | boolean | false | Status centang. Blade dan Astro memakai atribut checked, React checked atau defaultChecked, Vue v-model, Svelte bind:checked, Angular checked atau [(checked)]. |
disabled | boolean | false | Menonaktifkan checkbox dan meredupkan label. |
id | string | auto | Id input. Dibuat otomatis kalau kosong. |
checkedChange | output<boolean> | - | Khusus Angular. Memancarkan status baru setiap kali checkbox berubah. |
Aksesibilitas
- Memakai input type checkbox native, jadi Spasi mencentang dan status dibacakan screen reader.
- Label terhubung lewat for dan id sehingga mengklik label ikut mencentang.
- Ikon centang hanya dekorasi (aria-hidden), status visual mengikuti :checked.
Komponen terkait
Komponen form lain dengan class yang sama di setiap framework.
- ButtonTombol dengan varian primary, secondary, ghost, dan danger.
- ComboboxInput teks dengan daftar saran terfilter di popover, mengikuti pola WAI-ARIA Combobox dengan autocomplete list.
- InputKolom teks dengan label, petunjuk, dan pesan error yang terhubung lewat ARIA.
- Input OTPInput kode sekali pakai yang dipecah menjadi kotak satu digit, dengan maju otomatis, dukungan tempel, dan satu input tersembunyi untuk submit form.
- LabelLabel form dengan gaya konsisten serta penanda wajib atau opsional yang dibacakan screen reader dengan benar.
- Radio GroupKelompok radio native dalam fieldset dan legend untuk memilih satu dari beberapa opsi.