Components › Components
Demos show your theme.
Input
A native text field, styled, with an invalid state from aria-invalid.
That code has expired.
Usage #
tscl
@import uiInput from './input.tscl'
@import uiLabel from './label.tscl'
<div class="demo">
<uiLabel control="demo-email">Email</uiLabel>
<uiInput id="demo-email" type="email" placeholder="you@example.com" autocomplete="email" />
<uiLabel control="demo-code">Invite code</uiLabel>
<uiInput id="demo-code" value="ABC" aria-invalid="true" aria-describedby="demo-code-error" />
<p id="demo-code-error" class="error">That code has expired.</p>
</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);
}
.error {
margin: 0;
color: var(--ui-danger);
font-size: 13px;
}
</style>Source #
Copy it into your components folder (next to the others) as input.tscl.
tscl
{{-- Input: a native <input>. id, aria-* (aria-invalid, aria-describedby) and data-* you pass land on it. --}}
@input type: string = 'text'
@input name: string = ''
@input value: string = ''
@input placeholder: string = ''
@input autocomplete: string = ''
@input required: boolean = false
@input disabled: boolean = false
<input
[type]="type"
[name]="name || null"
[value]="value || null"
[placeholder]="placeholder || null"
[autocomplete]="autocomplete || null"
[required]="required"
[disabled]="disabled"
data-part="text-input"
/>
<style scoped>
@layer theme, base, components, utilities;
@layer components {
:where(:scope) {
box-sizing: border-box;
width: 100%;
min-height: 36px;
padding: 0 12px;
border: 1px solid var(--ui-input);
border-radius: var(--ui-radius);
background: var(--ui-bg);
color: var(--ui-fg);
font: var(--ui-font-size) var(--ui-font);
}
:where(:scope)::placeholder {
color: var(--ui-muted);
}
:where(:scope:focus-visible) {
outline: 2px solid var(--ui-ring);
outline-offset: 1px;
}
:where(:scope[aria-invalid='true']) {
border-color: var(--ui-danger);
}
:where(:scope:disabled) {
opacity: 0.5;
cursor: not-allowed;
}
}
</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-partnamestext-input. - 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