export const basicCheckbox=`import { Checkbox } from "@/components/ui/checkbox"; import { Label } from "@/components/ui/label"; const BasicCheckbox = () => { return (
); }; export default BasicCheckbox;` export const colorCheckbox=`import { Checkbox } from "@/components/ui/checkbox"; import { Label } from "@/components/ui/label"; const ColorCheckbox = () => { return (
); }; export default ColorCheckbox;` export const optionsArrayCheckbox=`"use client"; import { Checkbox } from "@/components/ui/checkbox"; import { Label } from "@/components/ui/label"; import { useState } from "react"; interface Option { value: string; label: string; } const OptionArrayCheckbox = () => { const [selected, setSelected] = useState([]); const options: Option[] = [ { value: "orange", label: "Orange", }, { value: "apple", label: "Apple", }, { value: "banana", label: "Banana", }, ]; return (
{options.map((option, i) => (
{ if (selected.includes(option.value)) { setSelected(selected.filter((item) => item !== option.value)); } else { setSelected([...selected, option.value]); } }} id={option.value} >
))}
{selected.length > 0 && (
Selected: [{selected.join(", ")}]
)}
); }; export default OptionArrayCheckbox;`