import { Checkbox } from '@/components/ui/checkbox'; import { Text } from '@/components/ui/text'; import { View } from '@/components/ui/view'; import React, { useState } from 'react'; export function CheckboxGroup() { const [selectedItems, setSelectedItems] = useState([]); const items = [ { id: 'notifications', label: 'Email notifications' }, { id: 'marketing', label: 'Marketing emails' }, { id: 'updates', label: 'Product updates' }, { id: 'newsletter', label: 'Weekly newsletter' }, ]; const handleItemChange = (itemId: string, checked: boolean) => { if (checked) { setSelectedItems((prev) => [...prev, itemId]); } else { setSelectedItems((prev) => prev.filter((id) => id !== itemId)); } }; return ( Subscription Preferences {items.map((item) => ( handleItemChange(item.id, checked)} label={item.label} /> ))} Selected: {selectedItems.length} item(s) ); }