Components › Components
Demos show your theme.
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 #
- On the root:
class,style,id,aria-*anddata-*written on the tag land on its root element;classandstylemerge with its own. - Selectors:
data-partnamesform-label. - Your rules win: every rule here has zero specificity (
:where()) and sits in@layer components, so your own CSS and Tailwind utilities override it.
Needs #
- theme.css, once per project