Skip to content

Commit 8970da9

Browse files
Merge pull request #16 from holaplex/anshul/radio-customization
Enable custom radio button using tailwind peer
2 parents 8c6a4ee + 47cc174 commit 8970da9

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

packages/@holaplexui-playground/pages/form.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,33 @@ export default function App() {
223223
<Form.RadioGroup.Radio value='Mango' name='fruits' />
224224
</Form.Label>
225225
</Form.RadioGroup>
226+
227+
<Form.RadioGroup className='mt-5'>
228+
<Form.Label
229+
name='Red'
230+
htmlFor='red'
231+
peerClassName='peer-checked:text-red-500'
232+
>
233+
<Form.RadioGroup.Radio
234+
id='red'
235+
value='red'
236+
name='color'
237+
className='peer hidden'
238+
/>
239+
</Form.Label>
240+
<Form.Label
241+
name='Green'
242+
htmlFor='green'
243+
peerClassName='peer-checked:text-green-500'
244+
>
245+
<Form.RadioGroup.Radio
246+
id='green'
247+
value='green'
248+
name='color'
249+
className='peer hidden'
250+
/>
251+
</Form.Label>
252+
</Form.RadioGroup>
226253
</Form>
227254
</div>
228255
);

packages/@holaplexui-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@holaplex/ui-library-react",
33
"author": "Holaplex Inc.",
4-
"version": "0.16.0",
4+
"version": "0.17.0",
55
"description": "Holaplex react ui library components",
66
"private": false,
77
"files": [

packages/@holaplexui-react/src/components/Form.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ interface FormLabelProps
3232
extends DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {
3333
name: string;
3434
placement?: Placement;
35+
peerClassName?: string;
3536
asideComponent?: JSX.Element;
3637
}
3738

3839
function FormLabel({
3940
name,
4041
placement = Placement.Top,
4142
asideComponent,
43+
peerClassName,
4244
className,
4345
children,
4446
...props
@@ -48,21 +50,21 @@ function FormLabel({
4850
className={clsx(
4951
'flex',
5052
{
51-
'flex-col': placement === Placement.Top,
52-
'flex-col-reverse': placement === Placement.Bottom,
53-
'flex-row-reverse items-center': placement === Placement.Right,
54-
'flex-row items-center': placement === Placement.Left,
53+
'flex-col': placement === Placement.Bottom,
54+
'flex-col-reverse': placement === Placement.Top,
55+
'flex-row-reverse items-center': placement === Placement.Left,
56+
'flex-row items-center': placement === Placement.Right,
5557
},
5658
'form-label',
5759
className
5860
)}
5961
{...props}
6062
>
61-
<div className="flex w-full justify-between items-center">
63+
{children}
64+
<div className={clsx('flex w-full justify-between items-center', peerClassName)}>
6265
<span className="form-label-text">{name}</span>
6366
{asideComponent}
6467
</div>
65-
{children}
6668
</label>
6769
);
6870
}

0 commit comments

Comments
 (0)