Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add enable selection prop to FormLabel component (#40554)

Joshen Lim0d1fac493b54
diff --git a/packages/ui-patterns/src/Dialogs/TextConfirmModal.tsx b/packages/ui-patterns/src/Dialogs/TextConfirmModal.tsx
index a35b603deba..a9e6547d870 100644
--- a/packages/ui-patterns/src/Dialogs/TextConfirmModal.tsx
+++ b/packages/ui-patterns/src/Dialogs/TextConfirmModal.tsx
@@ -161,13 +161,13 @@ export const TextConfirmModal = forwardRef<
name="confirmValue"
render={({ field }) => (
<FormItem_Shadcn_ className="flex flex-col gap-y-2">
- <span className="text-sm text-foreground-lighter">
+ <FormLabel_Shadcn_ {...label} enableSelection>
Type{' '}
<span className="text-foreground break-all whitespace-pre">
{confirmString}
</span>{' '}
to confirm.
- </span>
+ </FormLabel_Shadcn_>
<FormControl_Shadcn_>
<Input_Shadcn_
autoComplete="off"
diff --git a/packages/ui/src/components/shadcn/ui/form.tsx b/packages/ui/src/components/shadcn/ui/form.tsx
index 37271f4d3b2..840e9ff40af 100644
--- a/packages/ui/src/components/shadcn/ui/form.tsx
+++ b/packages/ui/src/components/shadcn/ui/form.tsx
@@ -13,9 +13,9 @@ import {
useWatch,
} from 'react-hook-form'
+import { AnimatePresence, motion } from 'framer-motion'
import { cn } from '../../../lib/utils/cn'
import { Label } from './label'
-import { motion, AnimatePresence } from 'framer-motion'
const Form = FormProvider
@@ -88,15 +88,17 @@ FormItem.displayName = 'FormItem'
const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
->(({ className, ...props }, ref) => {
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & { enableSelection?: boolean }
+>(({ className, enableSelection = false, ...props }, ref) => {
const { error, formItemId } = useFormField()
+ const Comp = enableSelection ? 'label' : Label
+
return (
- <Label
+ <Comp
ref={ref}
className={cn(
- 'text-foreground-light',
+ 'text-foreground-light text-sm',
'transition-colors',
error && '!text-destructive',
className,