Presets

Blocks

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.

Upgrade
JoinLogin
Presets
Monochrome
Overview
  • Introduction
  • Components
  • Installation
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • CalendarNEW
  • Card
  • CarouselNEW
  • Checkbox
  • Collapsible
  • Dialog
  • Dropdown Menu
  • Empty
  • Field
  • Input
  • Input Group
  • Item
  • Kbd
  • Label
  • Native Select
  • Scroll Area
  • SelectNEW
  • Separator
  • SwitchNEW
  • Table
  • Tabs
  • Textarea
  • TooltipNEW

Label

PreviousNext

Renders an accessible label associated with controls.

1import { Checkbox } from "@/components/ui/checkbox";2import { Label } from "@/components/ui/label";34export default function Preview() {

Installation

pnpm dlx sprawlify@latest add label
npx sprawlify@latest add label
yarn sprawlify@latest add label
bunx --bun sprawlify@latest add label

Install the following dependencies:

pnpm add @sprawlify/primitives @sprawlify/react
npm install @sprawlify/primitives @sprawlify/react
yarn add @sprawlify/primitives @sprawlify/react
bun add @sprawlify/primitives @sprawlify/react

Add the following files to your project:

label.tsx
1"use client";23import * as React from "react";4import { cn } from "@/lib/utils";5import { sprawlify } from "@sprawlify/react";67function Label({ className, ...props }: React.ComponentProps<typeof sprawlify.label>) {8  return (9    <sprawlify.label10      data-scope="label"11      data-part="root"12      data-slot="label"13      className={cn(14        "gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed",15        className,16      )}17      {...props}18    />19  );20}2122export { Label };23

Update the import paths to match your project setup.

Usage

1import { Label } from "@/components/ui/label"
1<Label htmlFor="email">Your email address</Label>

Examples

Field

For form fields, use the Field component which includes built-in FieldLabel, FieldDescription, and FieldError components.

1import { Button } from "@/components/ui/button";2import { Checkbox } from "@/components/ui/checkbox";3import {4  Field,

On This Page

InstallationUsageExamplesField

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.