Get Started
Components
Dev Tools
More Guides
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
# Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
labelClassName | string | ' ' | You can customise by passing tailwind classes. |
checkClassName | string | ' ' | You can customise by passing tailwind classes. |
id | string | check | You can pass id to create unique identifier. |
checked | boolean | Required | You can pass checked to set default checkbox state. |
disabled | boolean | false | You can pass disabled to set default checkbox state. |
children | string | ReactNode | Required | You can pass checkbox content as children. |
onChange | (checked: boolean) => void | Required | You can get callback when checkbox state changed. |
# Usage
import { useState } from 'react';
import { NCheck, NLink } from 'nayan';
const Checkbox = () => {
const [checked, setChecked] = useState(true);
return (
<NCheck checked={checked} disabled={false} onChange={checked => setChecked(checked)}>
Sample label for checkbox. accept <NLink> terms</NLink>
</NCheck>
);
};
export default Checkbox;
# Tags