Skip to content
Browse documentation
whisk/ui

Label

Associate visible text with a form control.

Overview

Label is a styled native label for a control you wire yourself when no Field description, error, or shared state is needed.

Use when

A single form control needs a visible programmatic label.

Use instead

Use Field when the control also needs help text, validation feedback, or required state.

Usage

import { Label, Stack, TextInput } from "@smoothie-framework/whisk-react";

<Stack gap={2}>
  <Label htmlFor="project-slug">Project slug</Label>
  <TextInput id="project-slug" placeholder="atlas" />
</Stack>

Examples

With a checkbox

Use a control's label prop when it owns the label and any description. Use Label when a separate layout needs the control first; clicking this Label still toggles the Checkbox.

import { Checkbox, Label, StackRow } from "@smoothie-framework/whisk-react";

<StackRow align="center" gap={2}>
  <Checkbox id="release-notes" />
  <Label htmlFor="release-notes">Send me release notes</Label>
</StackRow>

Disabled

Label does not reflect a disabled control. Use Field with disabled when the label and a supported Whisk/UI control need to share disabled state.

import { Field, Label, Stack, TextInput } from "@smoothie-framework/whisk-react";

<Stack gap={4}>
  <Stack gap={2}>
    <Label htmlFor="archived-slug">Archived project slug</Label>
    <TextInput id="archived-slug" defaultValue="atlas" disabled />
  </Stack>

  <Field disabled label="Workspace name">
    <TextInput defaultValue="Atlas" />
  </Field>
</Stack>

Sizes and weights

Use size and weight to match the surrounding form hierarchy without changing the label's native association.

import { Label, Stack, TextInput } from "@smoothie-framework/whisk-react";

<Stack gap={3}>
  <Stack gap={1}>
    <Label htmlFor="small-label" size="xs" weight="normal">Small label</Label>
    <TextInput id="small-label" size="sm" />
  </Stack>
  <Stack gap={1}>
    <Label htmlFor="default-label">Default label</Label>
    <TextInput id="default-label" />
  </Stack>
  <Stack gap={1}>
    <Label htmlFor="strong-label" size="lg" weight="semibold">Strong label</Label>
    <TextInput id="strong-label" size="lg" />
  </Stack>
</Stack>

No visible label

When the design cannot show a visible label, use aria-label. A placeholder describes expected input; it does not name the control.

import { TextInput } from "@smoothie-framework/whisk-react";

<TextInput
  type="search"
  aria-label="Search documentation"
  placeholder="Search documentation"
/>

Props

Component props

PropTypeDefaultDescription
htmlForstringnoneReference the native input ID that this label names.
size2xs | xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl | 7xl | 8xl | 9xlsmSet the label's text size without changing its association.
weightthin | light | normal | medium | semibold | bold | extraboldmediumSet the label's font weight without changing its association.

Shared props

PropSupportedNotes
as / asChildNoLabel always renders its native label host.
Style propsNoLabel exposes size and weight instead of the shared style-prop surface. See Style props.
className / styleYesApplied to the native label host.
refYesForwards to the native label host.
Native HTML attributesYesNative label attributes are forwarded.

Accessibility

Every editable control needs a programmatic name. Use Label with htmlFor for a simple native association; in Octane the attribute is also named htmlFor. Do not use Label inside Field: Field renders its own label. Use Field when a control also needs a description, validation message, or shared state propagation.

Content guidance

Use a short noun phrase such as Project name. Do not use a placeholder as the label or add a trailing colon.