Skip to content

Commit 26f01ce

Browse files
committed
feat(styled kit): add RadioGroup component
1 parent c32af28 commit 26f01ce

File tree

8 files changed

+103
-1
lines changed

8 files changed

+103
-1
lines changed

.changeset/green-ducks-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik-ui/styled': patch
3+
---
4+
5+
feat(styled kit): add RadioGroup component

apps/website/src/_state/component-statuses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const statusByComponent: ComponentKitsStatuses = {
2323
Modal: ComponentStatus.Draft,
2424
Pagination: ComponentStatus.Draft,
2525
Popover: ComponentStatus.Draft,
26+
RadioGroup: ComponentStatus.Draft,
2627
Separator: ComponentStatus.Beta,
2728
Skeleton: ComponentStatus.Beta,
2829
Tabs: ComponentStatus.Beta,

apps/website/src/routes/docs/styled/menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Label](/docs/styled/label)
2020
- [Modal](/docs/styled/modal)
2121
- [Popover](/docs/styled/popover)
22+
- [RadioGroup](/docs/styled/radio-group)
2223
- [Separator](/docs/styled/separator)
2324
- [Skeleton](/docs/styled/skeleton)
2425
- [Tabs](/docs/styled/tabs)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { Label, RadioGroup, RadioGroupItem } from '@qwik-ui/styled';
3+
4+
export default component$(() => {
5+
return (
6+
<RadioGroup>
7+
<div class="flex items-center space-x-2">
8+
<RadioGroupItem name="size" value="default" id="r1" />
9+
<Label for="r1">Default</Label>
10+
</div>
11+
<div class="flex items-center space-x-2">
12+
<RadioGroupItem name="size" value="comfortable" id="r2" />
13+
<Label for="r2">Comfortable</Label>
14+
</div>
15+
<div class="flex items-center space-x-2">
16+
<RadioGroupItem name="size" value="compact" id="r3" />
17+
<Label for="r3">Compact</Label>
18+
</div>
19+
</RadioGroup>
20+
);
21+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Qwik UI | Styled Radio Group Component
3+
---
4+
5+
import { statusByComponent } from '~/_state/component-statuses';
6+
7+
<StatusBanner status={statusByComponent.styled.RadioGroup} />
8+
9+
# Popover
10+
11+
Visually or semantically separates content.
12+
13+
> The current implementation of the styled radio-group uses the native html `<input type="radio" />` element. We intend to introduce a headless radio-group with better support for colors, animations, etc. In the meantime, this native element is still better than nothing 🙃. You can remove the accent-primary class from the RadioGroupItem component if you prefer the default blue color.
14+
15+
<br />
16+
17+
<Showcase name="hero" />
18+
19+
## Installation
20+
21+
```sh
22+
qwik-ui add radio-group
23+
```
24+
25+
## Usage
26+
27+
```tsx
28+
import { Label, RadioGroup, RadioGroupItem } from '@qwik-ui/styled';
29+
```
30+
31+
```tsx
32+
<RadioGroup>
33+
<div class="flex items-center space-x-2">
34+
<RadioGroupItem name="size" value="default" id="r1" />
35+
<Label for="r1">Default</Label>
36+
</div>
37+
<div class="flex items-center space-x-2">
38+
<RadioGroupItem name="size" value="comfortable" id="r2" />
39+
<Label for="r2">Comfortable</Label>
40+
</div>
41+
<div class="flex items-center space-x-2">
42+
<RadioGroupItem name="size" value="compact" id="r3" />
43+
<Label for="r3">Compact</Label>
44+
</div>
45+
</RadioGroup>
46+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
2+
import { cn } from '@qwik-ui/utils';
3+
4+
const RadioGroup = component$<PropsOf<'div'>>(({ ...props }) => {
5+
return (
6+
<div class={cn('grid gap-2', props.class)} {...props}>
7+
<Slot />
8+
</div>
9+
);
10+
});
11+
12+
const RadioGroupItem = component$<PropsOf<'input'>>(({ ...props }) => {
13+
return (
14+
<input
15+
type="radio"
16+
{...props}
17+
class={cn(
18+
'accent-primary h-4 w-4 disabled:cursor-not-allowed disabled:opacity-50',
19+
props.class,
20+
)}
21+
/>
22+
);
23+
});
24+
25+
export { RadioGroup, RadioGroupItem };

packages/kit-styled/src/components/skeleton/skeleton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ import { QwikIntrinsicElements, component$ } from '@builder.io/qwik';
22
import { cn } from '@qwik-ui/utils';
33

44
export const Skeleton = component$<QwikIntrinsicElements['div']>(({ ...props }) => {
5-
return <div {...props} class={cn('bg-accent animate-pulse rounded', props.class)} />;
5+
return (
6+
<div {...props} class={cn('bg-foreground/10 animate-pulse rounded', props.class)} />
7+
);
68
});

packages/kit-styled/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from './components/input/input';
99
export * from './components/label/label';
1010
export * from './components/modal/modal';
1111
export * from './components/popover/popover';
12+
export * from './components/radio-group/radio-group';
1213
export * from './components/separator/separator';
1314
export * from './components/skeleton/skeleton';
1415
export * from './components/tabs/tabs';

0 commit comments

Comments
 (0)