Checkbox

A Checkbox component is a UI element that allows users to select or deselect one or more options from a list. It typically appears as a small square that can be checked (ticked) or unchecked. Checkboxes are often used in forms, settings, or filters where multiple selections are needed, and they provide a clear, binary choice for users.

Demo

Basic:

Disabled:

Usage

import { useState } from 'react';
import { NCheck, NLink } from '@nayan-ui/react';
const Checkbox = () => {
const [notifications, setNotifications] = useState(true);
const [terms, setTerms] = useState(false);
return (
<div className="space-y-3">
<NCheck checked={notifications} onChange={setNotifications}>
Enable email notifications
</NCheck>
<NCheck checked={terms} onChange={setTerms}>
I agree to the <NLink href="#">Terms of Service</NLink>
</NCheck>
<NCheck checked={false} disabled onChange={() => {}}>
This option is disabled
</NCheck>
</div>
);
};
export default Checkbox;

Attributes

NameTypeDefaultDetails
idstringOptionalYou can pass id to create unique identifier.
classNamestring' 'You can customise by passing tailwind classes.
checkClassNamestring' 'You can customise by passing tailwind classes.
labelClassNamestring' 'You can customise by passing tailwind classes.
disabledbooleanfalseYou can pass disable state.
checkedbooleanRequiredYou can pass checked state.
onChange(checked: boolean) => voidRequiredYou can get callback when checkbox state changes.
childrenReact.ReactNodeRequiredLabel content for the checkbox.
renderLabel(children: React.ReactNode) => React.ReactNodeOptionalCustom render function for label.