Navigated to /docs/ui/components/form-label

FormLabel

Low-level standalone label for manually composed form layouts.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { FormLabel } from "@tavojs/ui/form-label";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/form-label.

When to use

Use it when

Use FormLabel when a custom form composition needs an explicit label element and you will wire its for value to the control ID yourself.

Choose something else when

Prefer Field for common inputs because Field generates label, message, required-state, and ARIA wiring together.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

FormLabel example

TSXCreate: src/components/examples/FormLabelExample1.tsx
tsximport { FormLabel } from "@tavojs/ui/form-label";
import { TextInput } from "@tavojs/ui";

export function FormLabelExample1() {
  return (
    <>
      <FormLabel for="project-name">Project name</FormLabel>
      <TextInput id="project-name" name="projectName" />
    </>
  );
}

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
sizeSize

md

Control scale: sm, md, or lg when supported. Applies to FormLabel.
disabledboolean

false

Disables the control when supported. Applies to FormLabel.
aria-*unknown

ARIA attributes are passed through for accessible labeling and state. Applies to FormLabel.

Complete TypeScript API

Import from @tavojs/ui/form-label. Published exports: FormLabel, FormLabelProps.

FormLabelProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by FormLabel.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by FormLabel.

idstring

No

Inherited id attribute accepted by FormLabel.

rolestring

No

Inherited role attribute accepted by FormLabel.

styleRecord<string, unknown>

No

Inherited style attribute accepted by FormLabel.

titlestring

No

Inherited title attribute accepted by FormLabel.

tabIndexnumber

No

Inherited tabIndex attribute accepted by FormLabel.

hiddenboolean

No

Inherited hidden attribute accepted by FormLabel.

disabledboolean

No

Disables the control when supported. Applies to FormLabel.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by FormLabel.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by FormLabel.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by FormLabel.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by FormLabel.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by FormLabel.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by FormLabel.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Prefer Field for common inputs because Field generates label, message, required-state, and ARIA wiring together.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/form-label
Explicit CSS import@tavojs/ui/css/form-label
PreviewInteractive preview available on this page