Command palette

@yasinsensoy/web

Web · Components

Checkbox

Checkbox.

2 exports

Live example

Preview

Code

import { Checkbox } from "@yasinsensoy/web";

<Checkbox label="I accept the terms" description="I've read the privacy policy." tooltip="Press and hold on mobile" onCheckedChange={setChecked} />

Events

  1. Events appear here when you interact with the preview.

Import

import { Checkbox } from "@yasinsensoy/web";

Checkbox

componentClient component

Checkbox. Built on a real <input type="checkbox">, so it works with forms, FormData, the keyboard and screen readers even before JavaScript loads. Can be used controlled (checked) or uncontrolled (defaultChecked).

On touch screens the touch area is extended to 44×44 px without changing the look.

Checkbox({ indeterminate, onCheckedChange, onChange, label, description, tooltip, effect, className, "aria-describedby": describedByProp, ref, ...props }: CheckboxProps): ReactNode

Examples

<Checkbox name="terms" required label="I accept the terms" />
<Checkbox name="newsletter" label="Newsletter" description="One email a month." />

<Checkbox checked={all} indeterminate={some} onCheckedChange={setAll} />

CheckboxProps

interface

Props of the Checkbox component.

Extends: Omit<ComponentProps<"input">, "type">

NameTypeDescription
indeterminate?booleanIndeterminate (neither checked nor unchecked) look. Used for "Select all" while only some children are selected.
onCheckedChange?(checked: boolean) => voidCalled with the new value when the check state changes. A shortcut for onChange.
label?ReactNodeLabel next to the box; all of it is clickable. When given, className is applied to the label itself.
description?ReactNodeDescription below the label; screen readers read it with the box.
tooltip?TooltipPropTooltip shown on hover, keyboard focus or long press on touch screens. It opens from the whole label and screen readers read it with the box. See TooltipProp.
effect?EffectPropEffect or effects of the box (e.g. "pulse", "bounce"). Defaults to UIProvider appearance.defaults.checkbox.effect. See BuiltinEffect.