11# Checkbox Group
22
3- AdaptUI exports a ` <CheckboxGroup /> ` component to help manage the checked state
4- of its children Checkbox components and conveniently pass a few shared style
5- props to each.
3+ Adapt UI provides two themes for the ` CheckboxGroup ` with three sizes.
64
7- See the [ props ] ( #props ) table at the bottom of this page for a list of the
8- shared props .
5+ These are groups of checkboxes stacked horizontally or vertically.
6+ So any changes made in the checkbox component will reflect here too .
97
10- Also check the Indeterminate case [ here.] ( checkbox.md#indeterminate )
11-
12- #### Preview
13-
14- https://user-images.githubusercontent.com/35562287/175327232-2f1774b7-8110-4f60-8901-e911fe11af74.mp4
8+ ![ simulator_screenshot_5B121795-0688-496F-91CA-26C28FE23E2A] ( https://user-images.githubusercontent.com/35562287/203286255-a6d2be49-2606-4de0-99a9-9cd53105622e.png )
159
1610#### Simple Usage
1711
@@ -34,30 +28,188 @@ export const App = () => {
3428 < CheckboxGroup value= {value} onChange= {setValue}>
3529 < Checkbox value= " apple" label= " Apple" / >
3630 < Checkbox value= " orange" label= " Orange" / >
37- < Checkbox value= " watermelon" label= " Watermelon" / >
38- < Checkbox value= " sapota " label= " Sapota " / >
31+ < Checkbox isDisabled value= " watermelon" label= " Watermelon" / >
32+ < Checkbox value= " strawberry " label= " Strawberry " / >
3933 < Checkbox value= " cherry" label= " Cherry" / >
4034 < / CheckboxGroup>
41- < Box style= {tailwind .style (" mt-2" )}>
42- < Text > Picked fruits< / Text >
43- {value .map ((item , index ) => {
44- return (
45- < Text style= {tailwind .style (" my-1" )} key= {index}>
46- - {item}
47- < / Text >
48- );
49- })}
50- < / Box>
5135 < / Box>
5236 );
5337};
5438
5539```
5640
41+ ## Table of contents
42+
43+ - [ Themes] ( #themes )
44+ - [ Sizes] ( #sizes )
45+ - [ Indeterminate] ( #indeterminate )
46+ - [ Orientation] ( #orientation )
47+
48+
49+ ## Themes
50+
51+ Adapt UI provides two themes for checkbox groups: ` base ` and ` primary ` .
52+ You can use these themed checkbox groups based on your specific scenarios.
53+
54+ ![ simulator_screenshot_5CEC669D-067D-48AB-8B3A-632C2D2A85D0] ( https://user-images.githubusercontent.com/35562287/203289544-5b8e3595-f993-4177-8014-e8cd0b5ee06b.png )
55+
56+ <details >
57+
58+ <summary >
59+ <h3 >Usage</h3 >
60+ </summary >
61+
62+ ``` js
63+ import { CheckboxGroup , useTheme } from " @adaptui/react-native-tailwind"
64+ export default function App () {
65+ const tailwind = useTheme ();
66+ const [value , setValue ] = React .useState < string[]> ([]);
67+
68+ return (
69+ <>
70+ < CheckboxGroup
71+ themeColor= " primary"
72+ value= {value}
73+ onChange= {setValue}
74+ >
75+ < Checkbox value= " artic" label= " Artic" / >
76+ < Checkbox value= " national-parks" label= " National Parks" / >
77+ < Checkbox isDisabled value= " camping" label= " Camping" / >
78+ < Checkbox value= " beaches" label= " Beaches" / >
79+ < Checkbox value= " caves" label= " Caves" / >
80+ < Checkbox value= " farms" label= " Farms" / >
81+ < / CheckboxGroup>
82+ < / >
83+ )
84+ }
85+ ```
86+ </details >
87+
88+ ## Sizes
89+
90+ There are three different sizes for the checkbox group in Adapt UI, ` sm ` , ` md ` and ` lg ` .
91+ Based on the hierarchy, you can switch between different sizes.
92+
93+ ![ simulator_screenshot_982D4B28-85CF-4AC2-99C9-C6EABFA977E4] ( https://user-images.githubusercontent.com/35562287/203288193-64a25b4e-3521-4f84-9ad2-57d19a26d518.png )
94+
95+ <details >
96+
97+ <summary >
98+ <h3 >Usage</h3 >
99+ </summary >
100+
101+ ``` js
102+ import { CheckboxGroup , useTheme } from " @adaptui/react-native-tailwind"
103+ export default function App () {
104+ const tailwind = useTheme ();
105+ const [value , setValue ] = React .useState < string[]> ([]);
106+
107+ return (
108+ <>
109+ < CheckboxGroup
110+ size= " lg"
111+ value= {value}
112+ onChange= {setValue}
113+ >
114+ < Checkbox value= " artic" label= " Artic" / >
115+ < Checkbox value= " national-parks" label= " National Parks" / >
116+ < Checkbox isDisabled value= " camping" label= " Camping" / >
117+ < Checkbox value= " beaches" label= " Beaches" / >
118+ < Checkbox value= " caves" label= " Caves" / >
119+ < Checkbox value= " farms" label= " Farms" / >
120+ < / CheckboxGroup>
121+ < / >
122+ )
123+ }
124+ ```
125+ </details >
126+
127+ ## Indeterminate
128+
129+ This property can make the checkbox group into an indeterminate group where one checkbox will act as a master, which has a set of checkboxes under it.
130+
131+ ![ simulator_screenshot_E202A2A8-A406-4C5A-B3B1-6D1826742D2D] ( https://user-images.githubusercontent.com/35562287/203288537-63c432ad-a14c-44bc-8345-a778da68fccf.png )
132+
133+ <details >
134+
135+ <summary >
136+ <h3 >Usage</h3 >
137+ </summary >
138+
139+ ``` js
140+ import {
141+ Box ,
142+ Checkbox ,
143+ CheckboxGroup ,
144+ useTheme ,
145+ } from " @adaptui/react-native-tailwind" ;
146+
147+ export const App = () => {
148+ const tailwind = useTheme ();
149+ return (
150+ < Box style= {tailwind .style (" h-full justify-center items-center bg-white-900" )}>
151+ < CheckboxGroup>
152+ < Checkbox label= " Fund Category" isIndeterminate / >
153+ < Box style= {tailwind .style (" ml-[25px]" )}>
154+ < Checkbox value= " Equity" label= " Equity" / >
155+ < Checkbox value= " Debt" label= " Debt" / >
156+ < Checkbox value= " Hybrid" label= " Hybrid" / >
157+ < Checkbox value= " International Equity" label= " International Equity" / >
158+ < Checkbox value= " Solution Oriented" label= " Solution Oriented" / >
159+ < / Box>
160+ < / CheckboxGroup>
161+ < / Box>
162+ );
163+ };
164+
165+ ```
166+ </details >
167+
168+ ## Orientation
169+
170+ Stack is the property to describe the layout of the component. Checkbox groups can be stacked horizontally and vertically.
171+
172+ This property helps you to pick one for yourself, defaults to ` vertical ` .
173+
174+ ![ simulator_screenshot_199E5E05-2DF0-4469-8E9C-5A854667F5CB] ( https://user-images.githubusercontent.com/35562287/203289204-882dcc11-bb00-4448-94cf-75fded46be35.png )
175+
176+ <details >
177+
178+ <summary >
179+ <h3 >Usage</h3 >
180+ </summary >
181+
182+ ``` js
183+ import { CheckboxGroup , useTheme } from " @adaptui/react-native-tailwind"
184+ export default function App () {
185+ const tailwind = useTheme ();
186+ const [value , setValue ] = React .useState < string[]> ([]);
187+
188+ return (
189+ <>
190+ < CheckboxGroup
191+ orientation= " horizontal"
192+ value= {value}
193+ onChange= {setValue}
194+ >
195+ < Checkbox value= " artic" label= " Artic" / >
196+ < Checkbox value= " national-parks" label= " National Parks" / >
197+ < Checkbox isDisabled value= " camping" label= " Camping" / >
198+ < Checkbox value= " beaches" label= " Beaches" / >
199+ < Checkbox value= " caves" label= " Caves" / >
200+ < Checkbox value= " farms" label= " Farms" / >
201+ < / CheckboxGroup>
202+ < / >
203+ )
204+ }
205+ ```
206+ </details >
207+
208+
57209## Props
58210
59211| Name | Description | Type | Default |
60- | ------------ | ---------------------------------- | ------------------------- | ---------- |
212+ | -------------- | ------------------------------------ | --------------------------- | ------------ |
61213| orientation | Checkbox Group Orientation | ` vertical ` ` horizontal ` | ` vertical ` |
62214| value | Array of Checkbox Values | string[ ] | |
63215| defaultValue | Default State of Children Checkbox | string[ ] | |
0 commit comments