Components › Components

On this page

Label

A native label for a field.

Usage #

tscl
@import uiLabel from './label.tscl'

<div class="demo">
  <uiLabel control="demo-name">Name</uiLabel>
  <input id="demo-name" />
  <uiLabel><input type="checkbox" /> Remember me</uiLabel>
</div>

<style scoped>
  :scope {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-bg);
    color: var(--ui-fg);
  }
</style>

Source #

Copy it into your components folder (next to the others) as label.tscl.

tscl
{{-- Label: a native <label>. control is the id of the field it names (its for); or put the field inside it. --}}
@input control: string = ''

<label [for]="control || null" data-part="form-label"><slot /></label>

<style scoped>
  @layer theme, base, components, utilities;
  @layer components {
    :where(:scope) {
      color: var(--ui-fg);
      font: 500 var(--ui-font-size)/1.4 var(--ui-font);
    }
  }
</style>

Styling #

Needs #