Skip to content

输入框 ​

文本输入框(默认、material、line、圆角、多种尺寸)、textarea、原生 select、输入组以及浮动标签。

输入框 ​

输入框
vue
<div class="thl-row">
  <div class="thl-col-12 thl-col-md-6">
    <ThlField label="Default" v-slot="{ id }"><ThlInput :id="id" v-model="text" placeholder="Type…" /></ThlField>
    <ThlField label="Small / large"><div class="thl-stack"><ThlInput size="sm" placeholder="sm" /><ThlInput size="lg" placeholder="lg" /></div></ThlField>
    <ThlField label="Rounded"><ThlInput rounded placeholder="rounded" /></ThlField>
    <ThlField label="Native select"><ThlNativeSelect v-model="country" :options="countries" /></ThlField>
  </div>
  <div class="thl-col-12 thl-col-md-6">
    <ThlField label="Material"><ThlInput variant="material" placeholder="Material input" /></ThlField>
    <ThlField label="Line"><ThlInput variant="line" placeholder="Line input" /></ThlField>
    <ThlField label="Textarea"><ThlTextarea placeholder="Message" /></ThlField>
  </div>
</div>
tsx
<Input value={text} onChange={(e) => setText(e.target.value)} placeholder="Type…" />
<Input size="sm" /> <Input variant="material" /> <Input variant="line" /> <Input rounded />
<Textarea placeholder="Message" />
<NativeSelect options={countries} value={country} onChange={(e) => setCountry(e.target.value)} />
html
<input thlInput [(ngModel)]="text" placeholder="Type…" />
<input thlInput size="sm" /> <input thlInput variant="material" /> <input thlInput rounded />
<textarea thlInput placeholder="Message"></textarea>
<select thlInput [(ngModel)]="country">@for (c of countries; track c.value) {<option [value]="c.value">{{ c.label }}</option>}</select>

输入组与浮动标签 ​

输入组与浮动标签
vue
<div class="thl-row">
  <div class="thl-col-12 thl-col-md-6">
    <ThlField label="Username"><ThlInputGroup prepend="@"><ThlInput placeholder="username" /></ThlInputGroup></ThlField>
    <ThlField label="Amount"><ThlInputGroup prepend="$" append=".00"><ThlInput type="number" /></ThlInputGroup></ThlField>
    <ThlField label="Search"><ThlInputGroup><ThlInput placeholder="Search…" /><template #append><ThlButton variant="primary" icon="search">Go</ThlButton></template></ThlInputGroup></ThlField>
  </div>
  <div class="thl-col-12 thl-col-md-6"><div class="thl-stack"><ThlFloatingLabel for="fl1" label="Email"><ThlInput id="fl1" placeholder=" " /></ThlFloatingLabel><ThlFloatingLabel for="fl2" label="Password"><ThlInput id="fl2" variant="material" type="password" placeholder=" " /></ThlFloatingLabel></div></div>
</div>
tsx
<InputGroup prepend="@"><Input placeholder="username" /></InputGroup>
<InputGroup prepend="$" append=".00"><Input type="number" /></InputGroup>
<FloatingLabel htmlFor="fl1" label="Email"><Input id="fl1" placeholder=" " /></FloatingLabel>
html
<thl-input-group prepend="@"><input thlInput placeholder="username" /></thl-input-group>
<thl-input-group prepend="$" append=".00"><input thlInput type="number" /></thl-input-group>

API ​

Input

<ThlInput> · import { ThlInput } from '@thl-ui/vue'

Prop类型默认值
modelValueany—
sizestring—
variantstring—
roundedboolean—
invalidboolean—

事件: update:modelValue

Textarea

<ThlTextarea> · import { ThlTextarea } from '@thl-ui/vue'

Prop类型默认值
modelValuestring—
variantstring—

事件: update:modelValue

NativeSelect

<ThlNativeSelect> · import { ThlNativeSelect } from '@thl-ui/vue'

Prop类型默认值
modelValueany—
optionsarray—
sizestring—

事件: update:modelValue

插槽: default

InputGroup

<ThlInputGroup> · import { ThlInputGroup } from '@thl-ui/vue'

Prop类型默认值
prependstring—
appendstring—

插槽: prependdefaultappend

FloatingLabel

<ThlFloatingLabel> · import { ThlFloatingLabel } from '@thl-ui/vue'

Prop类型默认值
label*string—
for*string—

插槽: default