Skip to content

Label

A form label component. for points to the target control's id, and clicking focuses the control; supports a required asterisk and its position.

Basic usage

Basic label

Name

Required asterisk

required appends a * marker; position places the asterisk before (before) or after (after, default) the text.

Required asterisk

Email

Asterisk before

Phone number

Plain text label

Without for, only text is rendered and clicks don't forward focus; long text wraps instead of overflowing.

Plain text & long text

Plain text label without forThis is an especially long label text, used to demonstrate that long text wraps automatically without overflowing the container boundary. Please be patient while reading.

API

Attributes

AttributeDescriptionTypeDefault
forTarget control id; click forwards to getElementById(for).focus()string
positionPosition of the asterisk relative to the textstringafter
requiredAppend a required * marker (aria-hidden)boolean

Slots

NameDescription
default

Note: for is also synced to the native <label> for attribute; the click behavior is manually forwarded and can focus the target control across Shadow DOM.