Skip to main content

Checkbox

A basic widget for getting the user input, used for selecting multiple values from several options.

import { Checkbox } from "rizzui";

Default

The default style of Checkbox component.

import { Checkbox } from "rizzui";

export default function App() {
return <Checkbox label="Remember me" />;
}

Variants

You can change the style of Checkbox using variant property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<>
<Checkbox className="m-2" label="Outline" variant="outline" />
<Checkbox className="m-2" label="Flat" variant="flat" />
</>
);
}

Sizes

You can change the sizes of Checkbox using size property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<>
<Checkbox className="m-2" label="Small" size="sm" />
<Checkbox className="m-2" label="Default" size="md" />
<Checkbox className="m-2" label="Large" size="lg" />
<Checkbox className="m-2" label="Extra Large" size="xl" />
</>
);
}

Rounded

You can change the border radius of Checkbox using rounded property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<>
<Checkbox className="m-2" label="Rounded Small" rounded="sm" />
<Checkbox className="m-2" label="Rounded Default" />
<Checkbox className="m-2" label="Rounded Large" rounded="lg" />
<Checkbox className="m-2" label="Rounded None" rounded="none" />
<Checkbox className="m-2" label="Rounded Circle" rounded="full" />
</>
);
}

Label Placement

You can set label on the two diffrient side using labelPlacement property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<>
<Checkbox className="m-2" label="Left Placement" labelPlacement="left" />
<Checkbox
className="m-2"
label="Right Placement"
labelPlacement="right"
/>
</>
);
}

Disabled

The disabled style of the Checkbox component.

import { Checkbox } from "rizzui";

export default function App() {
return <Checkbox className="m-2" label="Left Placement" disabled />;
}

With Helper Text

You can add helper text to Checkbox using helperText property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<Checkbox
className="m-2"
label="John"
value="john"
helperText="Hi! My name is John Doe."
/>
);
}

With Error Message

You can show the validation error message using error property.

import { Checkbox } from "rizzui";

export default function App() {
return (
<Checkbox
className="m-2"
label="Yes"
value="yes"
error="This field is required"
/>
);
}

API Reference


Checkbox Props

Here is the API documentation of the Checkbox component. And the rest of the props of Checkbox are the same as the original html input field.

PropsTypeDescriptionDefault
labelReactNodeSet field label__
labelWeightLabelWeightSet label font weight"medium"
labelPlacementleft rightChange label direction"right"
variantCheckboxVariantsThe variants of the component are:"outline"
sizeCheckboxSizesThe size of the component.
"sm" is equivalent to the dense input styling.
"md"
roundedCheckboxRoundedThe rounded variants are:"md"
disabledbooleanWhether the input is disabled or not__
errorstringShow error message using this prop__
helperTextReactNodeAdd helper text. It could be string or a React component__
iconClassNamestringUse iconClassName prop to apply some additonal style for check mark icon__
labelClassNamestringUse labelClassName prop to apply some addition style for the field label__
inputClassNamestringAdd custom classes for the input filed extra style__
helperClassNamestringThis prop allows you to customize the helper message style__
errorClassNamestringThis prop allows you to customize the error message style__
classNamestringAdd custom classes to the root of the component__
refRef<HTMLInputElement>__
...InputHTMLAttributesnative props like value, onChange, onFocus, onBlur ...__

Checkbox Variants

type CheckboxVariants = "outline" | "flat";

Label Weight

type LabelWeight = "normal" | "medium" | "semibold" | "bold";

Checkbox Sizes

type CheckboxSizes = "sm" | "md" | "lg" | "xl";

Checkbox Rounded

type CheckboxRounded = "sm" | "md" | "lg" | "full" | "none";