Label
Label with thoughtful defaults, semantic styling, and editable source.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/label.jsonUse it
Scroll horizontally for long lines
"use client";
import {Label} from '@/components/jez-ui/ui/label';
export default function Example(){
return <><div className="grid gap-2"><Label htmlFor="example-label">Project name</Label><input id="example-label" className="rounded border border-border p-2" placeholder="Field notes"/></div></>;
}Props & types
Scroll horizontally for long lines
React.LabelHTMLAttributes<HTMLLabelElement>Source
View 2 source files
registry/ui/label.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
export function Label({
className,
...props
}: React.LabelHTMLAttributes<HTMLLabelElement>) {
return <label className={cn("text-sm font-medium", className)} {...props} />;
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
Dependencies
clsx@2.1.1 · tailwind-merge@3.5.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →