diff --git a/.changeset/twenty-baboons-protect.md b/.changeset/twenty-baboons-protect.md new file mode 100644 index 00000000..61b0f1fe --- /dev/null +++ b/.changeset/twenty-baboons-protect.md @@ -0,0 +1,5 @@ +--- +'@tszhong0411/ui': patch +--- + +Add Radio Group diff --git a/apps/docs/src/app/ui/components/radio-group.mdx b/apps/docs/src/app/ui/components/radio-group.mdx new file mode 100644 index 00000000..a8958ab8 --- /dev/null +++ b/apps/docs/src/app/ui/components/radio-group.mdx @@ -0,0 +1,25 @@ +--- +title: Radio Group +description: A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time. +--- + + + +## Usage + +```tsx +import { Label, RadioGroup, RadioGroupItem } from '@tszhong0411/ui' +``` + +```tsx + +
+ + +
+
+ + +
+
+``` diff --git a/apps/docs/src/components/demos/radio-group/radio-group.tsx b/apps/docs/src/components/demos/radio-group/radio-group.tsx new file mode 100644 index 00000000..d7088995 --- /dev/null +++ b/apps/docs/src/components/demos/radio-group/radio-group.tsx @@ -0,0 +1,22 @@ +import { Label, RadioGroup, RadioGroupItem } from '@tszhong0411/ui' + +const RadioGroupDemo = () => { + return ( + +
+ + +
+
+ + +
+
+ + +
+
+ ) +} + +export default RadioGroupDemo diff --git a/apps/docs/src/config/links.ts b/apps/docs/src/config/links.ts index 7de6e8f9..4a99804d 100644 --- a/apps/docs/src/config/links.ts +++ b/apps/docs/src/config/links.ts @@ -150,6 +150,10 @@ const COMPONENT_LINKS = [ href: '/ui/components/progress', text: 'Progress' }, + { + href: '/ui/components/radio-group', + text: 'Radio Group' + }, { href: '/ui/components/resizable', text: 'Resizable' diff --git a/packages/ui/package.json b/packages/ui/package.json index 8d5853a6..79a367ad 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -46,6 +46,7 @@ "@radix-ui/react-navigation-menu": "^1.2.3", "@radix-ui/react-popover": "^1.1.4", "@radix-ui/react-progress": "^1.1.1", + "@radix-ui/react-radio-group": "^1.2.2", "@radix-ui/react-scroll-area": "^1.2.2", "@radix-ui/react-select": "^2.1.4", "@radix-ui/react-separator": "^1.1.1", diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 6d80be76..3bbfbda9 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -33,6 +33,7 @@ export * from './navigation-menu' export * from './pagination' export * from './popover' export * from './progress' +export * from './radio-group' export * from './resizable' export * from './scroll-area' export * from './select' diff --git a/packages/ui/src/radio-group.tsx b/packages/ui/src/radio-group.tsx new file mode 100644 index 00000000..01a2e82d --- /dev/null +++ b/packages/ui/src/radio-group.tsx @@ -0,0 +1,36 @@ +'use client' + +import * as RadioGroupPrimitive from '@radix-ui/react-radio-group' +import { cn } from '@tszhong0411/utils' +import { CircleIcon } from 'lucide-react' + +type RadioGroupProps = React.ComponentProps + +export const RadioGroup = (props: RadioGroupProps) => { + const { className, ...rest } = props + + return +} + +type RadioGroupItemProps = React.ComponentProps + +export const RadioGroupItem = (props: RadioGroupItemProps) => { + const { className, ...rest } = props + + return ( + + + + + + ) +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1474d15..46d09358 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -845,6 +845,9 @@ importers: '@radix-ui/react-progress': specifier: ^1.1.1 version: 1.1.1(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@radix-ui/react-radio-group': + specifier: ^1.2.2 + version: 1.2.2(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@radix-ui/react-scroll-area': specifier: ^1.2.2 version: 1.2.2(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) @@ -4061,6 +4064,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-radio-group@1.2.2': + resolution: {integrity: sha512-E0MLLGfOP0l8P/NxgVzfXJ8w3Ch8cdO6UDzJfDChu4EJDy+/WdO5LqpdY8PYnCErkmZH3gZhDL1K7kQ41fAHuQ==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-roving-focus@1.1.1': resolution: {integrity: sha512-QE1RoxPGJ/Nm8Qmk0PxP8ojmoaS67i0s7hVssS7KuI2FQoc/uzVlZsqKfQvxPE6D8hICCPHJ4D88zNhT3OOmkw==} peerDependencies: @@ -14434,6 +14450,24 @@ snapshots: '@types/react': 19.0.2 '@types/react-dom': 19.0.3(@types/react@19.0.2) + '@radix-ui/react-radio-group@1.2.2(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': + dependencies: + '@radix-ui/primitive': 1.1.1 + '@radix-ui/react-compose-refs': 1.1.1(@types/react@19.0.2)(react@19.0.0) + '@radix-ui/react-context': 1.1.1(@types/react@19.0.2)(react@19.0.0) + '@radix-ui/react-direction': 1.1.0(@types/react@19.0.2)(react@19.0.0) + '@radix-ui/react-presence': 1.1.2(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@radix-ui/react-primitive': 2.0.1(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@radix-ui/react-roving-focus': 1.1.1(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@19.0.2)(react@19.0.0) + '@radix-ui/react-use-previous': 1.1.0(@types/react@19.0.2)(react@19.0.0) + '@radix-ui/react-use-size': 1.1.0(@types/react@19.0.2)(react@19.0.0) + react: 19.0.0 + react-dom: 19.0.0(react@19.0.0) + optionalDependencies: + '@types/react': 19.0.2 + '@types/react-dom': 19.0.3(@types/react@19.0.2) + '@radix-ui/react-roving-focus@1.1.1(@types/react-dom@19.0.3(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@radix-ui/primitive': 1.1.1