Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Checkbox for Astro

Native Astro checkboxes for independent choices and form values.

Attach the current review notes when you share this project.

Installation

bunx --bun shadcn@latest add @gnostic/checkbox

Usage

import { Checkbox } from "@/components/ui/checkbox"
<Checkbox />

Notes

  • Pair Checkbox with Label for simple cases, or use Field when you need descriptions, validation, or grouped controls.
  • Use the native disabled attribute to prevent interaction and aria-invalid when the control should display an error state.
  • For multi-line rows, wrap the label and supporting text together so the control stays easy to scan.

API Reference

Read the installed source for the complete prop types.

When to use Checkbox

Pair each Checkbox with a Label using matching id and for values. Give submitted controls a name and value. Use separate checkboxes when several choices can be selected together.

Keyboard and behavior

The rendered input uses native form submission, focus, Space activation, and disabled behavior. Set the DOM indeterminate property from your script for a mixed selection; an HTML attribute alone cannot set that property. A parent “select all” checkbox does not manage child values automatically.

Theme and layout

Checked, invalid, and disabled styles use the shared tokens. The check mark is a CSS mask on the input. Keep a text label visible and use FieldError for an explanation of invalid input.