Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53af7e1

Browse files
authored
feat: add shadcn radio-group component (#17264)
Based on the Figma designs:https://www.figma.com/design/WfqIgsTFXN2BscBSSyXWF8/Coder-kit?node-id=1786-4794&t=EAs4E89RAJLhivNj-1<img width="127" alt="Screenshot 2025-04-04 at 16 38 14"src="https://github.com/user-attachments/assets/e4c72fa9-0491-4674-aeb8-ed0ca4a58649"/>
1 parentb000a7a commit53af7e1

File tree

4 files changed

+192
-0
lines changed

4 files changed

+192
-0
lines changed

‎site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@radix-ui/react-dropdown-menu":"2.1.4",
5858
"@radix-ui/react-label":"2.1.0",
5959
"@radix-ui/react-popover":"1.1.5",
60+
"@radix-ui/react-radio-group":"1.2.3",
6061
"@radix-ui/react-scroll-area":"1.2.3",
6162
"@radix-ui/react-select":"2.1.4",
6263
"@radix-ui/react-slider":"1.2.2",

‎site/pnpm-lock.yaml

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
importtype{Meta,StoryObj}from"@storybook/react";
2+
import{RadioGroup,RadioGroupItem}from"./RadioGroup";
3+
4+
constmeta:Meta<typeofRadioGroup>={
5+
title:"components/RadioGroup",
6+
component:RadioGroup,
7+
args:{},
8+
};
9+
10+
exportdefaultmeta;
11+
typeStory=StoryObj<typeofRadioGroup>;
12+
13+
exportconstDefault:Story={
14+
render:()=>(
15+
<RadioGroupdefaultValue="option-1">
16+
<divclassName="flex items-center space-x-2">
17+
<RadioGroupItemvalue="option-1"id="option-1"tabIndex={0}/>
18+
<labelhtmlFor="option-1"className="text-content-primary text-sm">
19+
Option 1
20+
</label>
21+
</div>
22+
<divclassName="flex items-center space-x-2">
23+
<RadioGroupItemvalue="option-2"id="option-2"tabIndex={0}/>
24+
<labelhtmlFor="option-2"className="text-content-primary text-sm">
25+
Option 2
26+
</label>
27+
</div>
28+
<divclassName="flex items-center space-x-2">
29+
<RadioGroupItemvalue="option-3"id="option-3"tabIndex={0}/>
30+
<labelhtmlFor="option-3"className="text-content-primary text-sm">
31+
Option 3
32+
</label>
33+
</div>
34+
</RadioGroup>
35+
),
36+
};
37+
38+
exportconstWithDisabledOptions:Story={
39+
render:()=>(
40+
<RadioGroupdefaultValue="option-1">
41+
<divclassName="flex items-center space-x-2">
42+
<RadioGroupItemvalue="option-1"id="disabled-1"disabled/>
43+
<labelhtmlFor="disabled-1"className="text-content-disabled text-sm">
44+
Disabled Selected Option
45+
</label>
46+
</div>
47+
<divclassName="flex items-center space-x-2">
48+
<RadioGroupItemvalue="option-2"id="disabled-2"disabled/>
49+
<labelhtmlFor="disabled-2"className="text-content-disabled text-sm">
50+
Disabled Not Selected Option
51+
</label>
52+
</div>
53+
</RadioGroup>
54+
),
55+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copied from shadc/ui on 04/04/2025
3+
*@see {@link https://ui.shadcn.com/docs/components/radio-group}
4+
*/
5+
import*asRadioGroupPrimitivefrom"@radix-ui/react-radio-group";
6+
import{Circle}from"lucide-react";
7+
import*asReactfrom"react";
8+
9+
import{cn}from"utils/cn";
10+
11+
exportconstRadioGroup=React.forwardRef<
12+
React.ElementRef<typeofRadioGroupPrimitive.Root>,
13+
React.ComponentPropsWithoutRef<typeofRadioGroupPrimitive.Root>
14+
>(({ className, ...props},ref)=>{
15+
return(
16+
<RadioGroupPrimitive.Root
17+
className={cn("grid gap-2",className)}
18+
{...props}
19+
ref={ref}
20+
/>
21+
);
22+
});
23+
RadioGroup.displayName=RadioGroupPrimitive.Root.displayName;
24+
25+
exportconstRadioGroupItem=React.forwardRef<
26+
React.ElementRef<typeofRadioGroupPrimitive.Item>,
27+
React.ComponentPropsWithoutRef<typeofRadioGroupPrimitive.Item>
28+
>(({ className, ...props},ref)=>{
29+
return(
30+
<RadioGroupPrimitive.Item
31+
ref={ref}
32+
className={cn(
33+
`aspect-square h-4 w-4 rounded-full border border-solid border-border text-content-primary bg-surface-primary
34+
focus:outline-none focus-visible:ring-2 focus-visible:ring-content-link
35+
focus-visible:ring-offset-4 focus-visible:ring-offset-surface-primary
36+
disabled:cursor-not-allowed disabled:opacity-25 disabled:border-surface-invert-primary
37+
hover:border-border-hover`,
38+
className,
39+
)}
40+
{...props}
41+
>
42+
<RadioGroupPrimitive.IndicatorclassName="flex items-center justify-center">
43+
<CircleclassName="absolute h-2.5 w-2.5 fill-surface-invert-primary"/>
44+
</RadioGroupPrimitive.Indicator>
45+
</RadioGroupPrimitive.Item>
46+
);
47+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp