Label
Renders an accessible label associated with controls.
import Checkbox from '@dinui/react/checkbox'import Label from '@dinui/react/label'
export default function LabelDemo() { return ( <div> <div className="flex items-center space-x-2"> <Checkbox id="terms" /> <Label htmlFor="terms">Accept terms and conditions</Label> </div> </div> )}Disabled
import Checkbox from '@dinui/react/checkbox'import Label from '@dinui/react/label'
export default function LabelDisabledDemo() { return ( <div> <div className="flex items-center space-x-2"> <Checkbox id="terms-disabled" disabled className="peer" /> <Label htmlFor="terms-disabled">Accept terms and conditions</Label> </div> </div> )}Installation
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Run the following command in your project
Terminal window npx @dinui/cli@latest add labelTerminal window yarn dlx @dinui/cli@latest add labelTerminal window pnpm dlx @dinui/cli@latest add labelTerminal window bunx @dinui/cli@latest add label -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.
-
Follow Installation Guide
To enable DinUI functionality in your project, you will need to properly set up Tailwind and install the necessary dependencies. -
Install dependencies
Terminal window npm install @radix-ui/react-label tailwind-variantsTerminal window yarn add @radix-ui/react-label tailwind-variantsTerminal window pnpm add @radix-ui/react-label tailwind-variantsTerminal window bun add @radix-ui/react-label tailwind-variants -
Copy and paste the following code into your project
'use client'import * as LabelPrimitive from '@radix-ui/react-label'import { forwardRef } from 'react'import { tv, type VariantProps } from 'tailwind-variants'const label = tv({slots: {root: 'text-sm font-medium leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70',},variants: {variant: {default: null,danger: {root: 'text-fg-danger',},},},defaultVariants: {variant: 'default',},})const Label = forwardRef<React.ElementRef<typeof LabelPrimitive.Root>,React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof label>>(({ variant, ...props }, ref) => {const { root } = label({ variant })return (<LabelPrimitive.Root {...props} ref={ref} className={root({ className: props.className })} />)})Label.displayName = LabelPrimitive.Root.displayNameexport default Labelexport { label, LabelPrimitive } -
Update the import paths to match your project setup
-
All done
You now can start using this component in your project.