6.3 KiB
templateEngineOverride, layout, title, description, toc
| templateEngineOverride | layout | title | description | toc | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| njk | layouts/page.njk | Checkbox | A control that allows the user to toggle between checked and not checked. |
|
{% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %}
{% set code %}
Usage
Add the input class to your <input type="checkbox"> elements. Pair it with Field and a native <label> for proper layout and labeling.
{% set code %}{% endset %} {{ code_block(code) }}
Checked state
Use native HTML attributes for state. Add checked for an initially checked checkbox, or read and update the element's checked property in JavaScript.
{% set code %}{% endset %} {{ code_block(code) }}
Invalid state
Set aria-invalid="true" on the checkbox and, when using field, set data-invalid="true" on the field wrapper.
{% set code %}
You must accept the terms to continue.
Examples
Basic
{% set code %}
Description
{% set code %}
By clicking this checkbox, you agree to the terms and conditions.
Disabled
{% set code %}
Group
{% set code %}
SidebarSelect the items you want to display in the sidebar.
Table
{% set code %}
| Status | ||
|---|---|---|
| Active | olivia@example.com | |
| Inactive | noah@example.com |
RTL
Checkbox layout uses document direction and logical spacing. Set dir="rtl" on a parent to render right-to-left.
{% set code %}
يمكنك تغيير هذا الخيار في أي وقت.