Glin UI
Primitive / Atom

Label

Form label primitive with shared glass-aware variants.

Edit on GitHub

Invite a teammate

Labels name a control for everyone, including screen readers.

Installation

Install from
pnpm dlx @glinui/cli@latest add label

Prefer the package?

Usage

Variants

Glass is opt-in and needs a backdrop behind it.

import { Label } from "@glinui/ui"
export function Demo() {
return (
<div className="flex flex-wrap items-center gap-3">
<Label>Default</Label>
<Label variant="solid">solid</Label>
<Label variant="soft">soft</Label>
<Label variant="outline">outline</Label>
<Label variant="ghost">ghost</Label>
<Label variant="glass">glass</Label>
</div>
)
}

Variants

import { Label } from "@glinui/ui"

export function LabelVariantDemo() {
  return (
    <div className="flex flex-col gap-2">
      <Label variant="default">Default label</Label>
      <Label variant="glass">Glass label</Label>
      <Label variant="outline">Outline label</Label>
      <Label variant="ghost">Ghost label</Label>
    </div>
  )
}

Sizes

import { Label } from "@glinui/ui"

export function LabelSizeDemo() {
  return (
    <div className="flex flex-col gap-2">
      <Label size="sm">Small label</Label>
      <Label size="md">Medium label</Label>
      <Label size="lg">Large label</Label>
    </div>
  )
}

With Checkbox

import { Label, Checkbox } from "@glinui/ui"

export function LabelCheckboxDemo() {
  return (
    <div className="flex items-center gap-2">
      <Checkbox id="terms" />
      <Label htmlFor="terms">I agree to the terms and conditions</Label>
    </div>
  )
}

Required Pattern

Use an asterisk span inside `Label` to signal required fields. Pair with `aria-required` on the control.

import { Label, Input } from "@glinui/ui"

export function LabelRequiredDemo() {
  return (
    <div className="flex flex-col gap-1.5">
      <Label htmlFor="username">
        Username
        <span className="ml-1 text-red-500" aria-hidden="true">*</span>
      </Label>
      <Input id="username" aria-required="true" placeholder="johndoe" />
    </div>
  )
}

Accessibility

  • Uses semantic `<label>` for screen reader form-field association.
  • Always provide `htmlFor` to associate the label with its form control, clicking the label should move focus to the input.
  • Do not use `Label` as decorative text; prefer `Text` or plain `<span>` elements for non-form contexts.
  • When marking required fields, include both the visual asterisk and an `aria-required="true"` attribute on the control.

ARIA Attributes

  • `htmlFor` should match form control `id`

Reduced Motion

No motion-dependent behavior.

`Label` is a static element with no animation. It is unaffected by `prefers-reduced-motion`.

API Reference

PropTypeRequiredDefaultDescription
htmlForstring--Associates label with a form control id.
variant"default" | "glinr" | "plain" | "solid" | "soft" | "outline" | "ghost" | "glass" | "gradient" | "frosted"Noambient (plain text)Plain text by default. solid, soft, outline, ghost and glass render a chip around the label. Glass is opt-in.
size"sm" | "md" | "lg"NomdFont-size scale.

Source

Import directly from the package or browse the source on GitHub. Click any file to view it.

Import

import { Label } from "@glinui/ui"

Source Files

Dependencies

@glinui/ui

Generated API Snapshot

Beta

Auto-extracted from TypeScript source in packages/ui/src/components/label.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.

Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata

Primary Props Type

LabelProps

LabelProps

PropTypeRequiredDefaultDescription
size"sm" | "md" | "lg"No"md"Variant option from labelVariants.
variant"default" | "glinr" | "plain" | "solid" | "soft" | "outline" | "ghost" | "glass" | "gradient" | "frosted"No-Chip treatment. Omit (or glinr, plain, default) for a plain text label that adapts to any ambient style. Also: solid, soft, outline, ghost, glass (opt-in).