Label

Name an input, mark it as required, and connect the label to its field.

Live preview
Interact with the component to see results here.
View code
HTML
<div style="display:grid;gap:16px;width:100%">
  <sy-label
    value="Email"
    requiredposition="right"
    valueposition="left"
    width="100px"
    required
    for="field"
  ></sy-label>
  <sy-input
    placeholder="name@example.com"
    required
    id="field"
    aria-label="Email"
  ></sy-input>
</div>

Usage guide

#

Keep an always-visible explanation of the expected value beside the field.

  1. Connect to an input

    Set for to the input element's id. Clicking the Label focuses the connected input.

  2. Arrange to fit the form

    Use valuePosition and width for placement and width, and requiredPosition for the required marker.

Feature examples

#

Choose a feature from 6 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · For

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Required

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Width

See how settings change appearance and behavior.

View code
HTML
Loading the example.

API reference

#

Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.

<sy-label>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseStyle the label as disabled. Also set disabled on the associated input.
booleanfalseAdd a required marker. Set required on the input component for actual validation.
'left' | 'right''right'Place the required marker on the left or right of the label.
string''id of the associated input element.
string''Current value or item identifier.
'left' | 'right' | 'center''left'Text alignment within the label area.
string''Label area width, as a CSS length.

Slots

SlotDescription
Component body or child items.