Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♻️ Migrate Label to native label element (#2563)

Luke Vella205e72da9c82
diff --git a/packages/ui/package.json b/packages/ui/package.json
index cc3102278..1be2d4b3c 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -24,7 +24,6 @@
"@radix-ui/react-collapsible": "^1.1.3",
"@radix-ui/react-dialog": "^1.1.11",
"@radix-ui/react-dropdown-menu": "^2.0.4",
- "@radix-ui/react-label": "^2.0.1",
"@radix-ui/react-popover": "^1.0.5",
"@radix-ui/react-portal": "^1.1.6",
"@radix-ui/react-progress": "^1.1.2",
diff --git a/packages/ui/src/form.tsx b/packages/ui/src/form.tsx
index 350b4a32e..28ed8afc4 100644
--- a/packages/ui/src/form.tsx
+++ b/packages/ui/src/form.tsx
@@ -1,4 +1,3 @@
-import type * as LabelPrimitive from "@radix-ui/react-label";
import { Slot } from "@radix-ui/react-slot";
import * as React from "react";
import type { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
@@ -79,8 +78,8 @@ const FormItem = React.forwardRef<
FormItem.displayName = "FormItem";
const FormLabel = React.forwardRef<
- React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
+ HTMLLabelElement,
+ React.ComponentPropsWithoutRef<typeof Label>
>(({ className, ...props }, ref) => {
const { formItemId } = useFormField();
diff --git a/packages/ui/src/label.tsx b/packages/ui/src/label.tsx
index a273fcba6..da88823e6 100644
--- a/packages/ui/src/label.tsx
+++ b/packages/ui/src/label.tsx
@@ -1,9 +1,8 @@
"use client";
-import * as LabelPrimitive from "@radix-ui/react-label";
import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
-import * as React from "react";
+import type * as React from "react";
import { cn } from "./lib/utils";
@@ -11,17 +10,18 @@ const labelVariants = cva(
"text-foreground text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);
-const Label = React.forwardRef<
- React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
- VariantProps<typeof labelVariants>
->(({ className, ...props }, ref) => (
- <LabelPrimitive.Root
- ref={ref}
- className={cn(labelVariants(), className)}
- {...props}
- />
-));
-Label.displayName = LabelPrimitive.Root.displayName;
+function Label({
+ className,
+ ...props
+}: React.ComponentProps<"label"> & VariantProps<typeof labelVariants>) {
+ return (
+ // biome-ignore lint/a11y/noLabelWithoutControl: htmlFor and children arrive via props
+ <label
+ data-slot="label"
+ className={cn(labelVariants(), className)}
+ {...props}
+ />
+ );
+}
export { Label };
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4a088d7b2..c19ca501b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -782,9 +782,6 @@ importers:
'@radix-ui/react-dropdown-menu':
specifier: ^2.0.4
- '@radix-ui/react-label':
- specifier: ^2.0.1
'@radix-ui/react-popover':
specifier: ^1.0.5
@@ -3703,19 +3700,6 @@ packages:
'@types/react':
optional: true
- '@radix-ui/[email protected]':
- resolution: {integrity: sha512-FmXs37I6hSBVDlO4y764TNz1rLgKwjJMQ0EGte6F3Cb3f4bIuHB/iLa/8I9VKkmOy+gNHq8rql3j686ACVV21A==}
- 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/[email protected]':
resolution: {integrity: sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==}
peerDependencies:
@@ -15094,15 +15078,6 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.13
- dependencies:
- react: 19.2.6
- react-dom: 19.2.6([email protected])
- optionalDependencies:
- '@types/react': 19.2.13
- '@types/react-dom': 19.2.3(@types/[email protected])
-
dependencies:
'@radix-ui/primitive': 1.1.3