shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Checkbox

A control that allows the user to toggle between checked and not checked.

By clicking this checkbox, you agree to the terms.

package examples import (

Installation

shadcn-templ add checkbox

Usage

import "github.com/axadrn/shadcn-templ/v2/components/checkbox"
@checkbox.Checkbox()

Checked State

Use the Checked prop to render the checkbox checked initially.

@checkbox.Checkbox(checkbox.Props{Checked: true})

Invalid State

Set aria-invalid on the checkbox and data-invalid on the field wrapper to show the invalid styles.

package examples import (

Basic

Pair the checkbox with field.Field and field.Label for proper layout and labeling.

package examples import (

Description

Use field.Content and field.Description for helper text.

By clicking this checkbox, you agree to the terms and conditions.

package examples import (

Disabled

Use the Disabled prop to prevent interaction and add the data-disabled attribute to the field.Field component for disabled styles.

package examples import (

Group

Use multiple fields to create a checkbox list.

Show these items on the desktop:

Select the items you want to show on the desktop.

package examples import (

Table

Name Email Role
Sarah Chen [email protected] Admin
Marcus Rodriguez [email protected] User
Priya Patel [email protected] User
David Kim [email protected] Editor
package examples import (

API Reference

Checkbox

The Checkbox component is a control that toggles between checked and not checked.

Prop Type Default
Name string -
Value string -
Checked bool false
Disabled bool false
Form string -
Class string -