Skip to content

Input

新粗野主义风格的文本输入框,支持变体、尺寸和 v-model 双向绑定。

预览

安装

pnpm dlx brutx@latest add input

用法

vue
<script setup>
import { ref } from 'vue'
import Input from '@/components/ui/Input.vue'

const value = ref('')
</script>

<template>
    <Input v-model="value" placeholder="Enter your name..." />
</template>

变体

变体说明
default标准边框
error错误边框,聚焦时使用 Primary 阴影
success成功边框,聚焦时使用 Secondary 阴影

尺寸

尺寸高度内边距字体大小
smh-9px-3 py-1text-sm
defaulth-11px-4 py-2text-base
lgh-14px-5 py-3text-lg

搭配 Label

vue
<script setup>
import { ref } from 'vue'
import Input from '@/components/ui/Input.vue'
import Label from '@/components/ui/Label.vue'

const email = ref('')
</script>

<template>
    <div class="space-y-2">
        <Label for="email">Email</Label>
        <Input id="email" v-model="email" type="email" placeholder="you@example.com" />
    </div>
</template>

禁用状态

vue
<script setup>
import Input from '@/components/ui/Input.vue'
</script>

<template>
    <Input disabled placeholder="Disabled input" />
</template>

Props

属性类型默认值
typestring'text'
modelValuestring | number
variant'default' | 'error' | 'success''default'
inputSize'sm' | 'default' | 'lg''default'
disabledbooleanfalse
placeholderstring
classstring

事件

事件载荷
update:modelValuestring | number