FormCheck
FormCheckBoolean choice A small control for a clear decision. Native checkbox behavior with a visible label and a reactive boolean.
Forms & inputNotification preferences
Toggle each independent preference. The required security setting demonstrates a checked, disabled state.
Toggle the preferences and lock the controls to compare available and disabled states.
<RegorApp id="form-check-demo" src="./playground.ts"/> import {
defineFlexComponents,
defineFormComponents,
} from '@purestack/ts-components'
import { createApp, defineComponent, html, type Ref, ref } from 'regor'
import { mountFormAppearanceGalleries } from '../appearance'
export interface FormCheckExample {
emailUpdates: Ref<boolean>
productUpdates: Ref<boolean>
}
const formCheckExampleTemplate = html`<Flex direction="column">
<fieldset class="p-3 m-0">
<legend>Notification preferences</legend>
<Flex direction="column" align="start">
<FormCheck
id="check-email"
name="updates"
value="email"
label="Email summaries"
:checked="emailUpdates"/>
<FormCheck
id="check-product"
name="updates"
value="product"
label="Product updates"
:checked="productUpdates"/>
<FormCheck
id="check-security"
label="Security alerts · required"
:checked="true"
:disabled="true"/>
</Flex>
</fieldset>
<FormStatus>
Email summaries: {{ emailUpdates ? 'On' : 'Off' }} · Product updates:
{{
productUpdates ? 'On' : 'Off' }}
</FormStatus>
</Flex>`
function createFormCheckExample(): FormCheckExample {
return { emailUpdates: ref(true), productUpdates: ref(false) }
}
const component = defineComponent<FormCheckExample>(formCheckExampleTemplate, {
context: createFormCheckExample,
})
createApp(
{
components: {
FormCheckExample: component,
...defineFlexComponents(),
...defineFormComponents(),
},
},
{ selector: 'app#form-check-demo', template: html`<FormCheckExample/>` },
)
mountFormAppearanceGalleries() A compact labelled checkbox
A checkbox without visible label text still needs an accessible name.
<Flex align="center">
<FormCheck id="check-compact" aria-label="Select this example row" tone="accent" />
<span>Example row</span>
</Flex> All semantic tones
All ten tones are visible at once. The control’s label and content explain the intent independently of color.
neutral accent feature secondary custom ghost info success warning danger Each sample is interactive and keeps its own local state. Switch the site theme to compare both palettes.
Every checkbox state
FormCheck has a tone prop and a fixed checkbox treatment; it has no variant prop. Native name and value contribute to form data when checked.
Unchecked Checked Disabled unchecked Disabled checked Accessible compact control Compare all values together. Use the live examples for application state and event handling.
Behavior and accessibility
Press Space while focused to toggle. Group related choices in fieldset with a legend. Unchecked and disabled checkboxes are omitted from native form data. Supply checked as a writable boolean ref for two-way state.
API reference
FormCheck contract
Props below are the public template API. RefOrValue accepts a literal or a reactive ref; bind refs with a colon-prefixed attribute. Native attributes and events can be passed through the component root.
id
string - Default
generated
Unique control ID. Supply an explicit value when help text or another element needs to reference this control.
label
RefOrValue<string> - Default
not set
Visible label. Use language that describes the control or value in its surrounding context.
name
RefOrValue<string> - Default
not set
Native form field name used during FormData serialization.
value
RefOrValue<string> - Default
browser default: on
Submitted value when checked. This is independent of the checked boolean.
checked
Ref<boolean> - Default
ref(false)
Writable boolean ref. Literal initial values are normalized into an internal ref.
disabled
RefOrValue<boolean> - Default
false
Disables interaction. Use a bound boolean, for example :disabled="isLocked".
tone
RefOrValue<SemanticTone> - Default
inherited
Semantic intent: neutral, accent, secondary, info, success, warning, danger, feature, custom or ghost. The active skin supplies the colors.
rootClass
RefOrValue<string> - Default
not set
Additional classes for the outer label, while inherited native attributes target the checkbox input.
Composition
No slots. label provides visible text. Register defineFormComponents or register FormCheck with defineFormCheckComponent.