Back to Tuist

Checkbox

noora/docs/components/checkbox.md

4.204.02.9 KB
Original Source
<!-- Generated by scripts/generate-web-components.js. Do not edit directly. -->

Checkbox

Lets a user select one or more independent options.

html
<noora-checkbox label="Send notifications" name="notifications"></noora-checkbox>

Attributes

AttributeType or allowed valuesDefaultDescription
labelstring""Sets the visible label.
descriptionstringNoneSets supporting text.
checkedbooleanfalseControls the checked state.
indeterminatebooleanfalseControls the mixed state.
disabledbooleanfalseDisables interaction.
namestring""Sets the submitted field name.
valuestring"on"Sets the submitted field value.
requiredbooleanfalseMarks the field as required.

Read-only properties

PropertyTypeDescription
controlHTMLInputElement | nullThe native checkbox input.
formHTMLFormElement | nullThe associated form.

Events

EventTypeDescription
inputInputEventEmitted while the checked state changes.
changeEventEmitted after the checked state changes.

Styling parts

PartDescription
rootThe checkbox label.
controlThe visual checkbox control.
labelThe label text.

The component emits standard input and change events.

Basic states

Checkboxes support unchecked, checked, and indeterminate states.

html
<noora-checkbox label="Enable notifications"></noora-checkbox>
<noora-checkbox checked label="Email alerts"></noora-checkbox>
<noora-checkbox indeterminate label="Select all items"></noora-checkbox>

Disabled states

Every selection state has a disabled presentation.

html
<noora-checkbox disabled label="Disabled unchecked"></noora-checkbox>
<noora-checkbox disabled checked label="Disabled checked"></noora-checkbox>
<noora-checkbox disabled indeterminate label="Disabled indeterminate"></noora-checkbox>

Descriptions

Add supporting context below the label.

html
<noora-checkbox label="Marketing emails" description="Receive updates about new features and promotions"></noora-checkbox>
<noora-checkbox checked label="Remember my preferences" description="Save your settings for future visits"></noora-checkbox>

Practical examples

Use checkboxes for agreements, subscriptions, and optional settings.

html
<noora-checkbox required label="I agree to the Terms of Service" description="By checking this box, you agree to our terms and conditions"></noora-checkbox>
<noora-checkbox label="Subscribe to our newsletter" description="Get weekly updates delivered to your inbox"></noora-checkbox>
<noora-checkbox checked label="Enable dark mode" description="Switch to a darker color scheme"></noora-checkbox>