Components
- 手风琴
- 提示
- 警告对话框
- 宽高比
- 头像
- 徽章
- 面包屑导航
- 按钮
- 按钮组
- 日历 Calendar
- 卡片
- Carousel
- 图表 Chart
- 复选框
- 折叠面板
- 组合框
- 命令
- 上下文菜单
- 数据表格 Data Table
- 日期选择器 Date Picker
- 对话框 Dialog
- 抽屉
- 下拉菜单
- Empty
- 字段
- 悬停卡片
- 输入
- 输入组
- 输入 OTP
- 项目
- Kbd
- 标签
- 菜单栏
- 原生选择框
- 导航菜单 Navigation Menu
- 分页
- 弹出框
- 进度 Progress
- 单选框组
- 可调整大小
- 滚动区域 Scroll Area
- 选择框
- 分隔符 Separator
- 侧边栏 Sheet
- 侧边栏 Sidebar
- 骨架屏
- 滑块
- Sonner
- 加载指示器 Spinner
- 开关
- 表格
- 标签页 Tabs
- 文本域
- 吐司
- 切换按钮 Toggle
- 切换组
- 提示 Tooltip
- 排版
Your API key is encrypted and stored securely.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
安装
pnpm dlx shadcn@latest add input
使用方法
import { Input } from "@/components/ui/input"<Input />示例
基础
import { Input } from "@/components/ui/input"
export function InputBasic() {字段
使用 Field、FieldLabel 和 FieldDescription 创建带有标签和描述的输入框。
Choose a unique username for your account.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
字段组
使用 FieldGroup 显示多个 Field 块并构建表单。
We'll send updates to this address.
import { Button } from "@/components/ui/button"
import {
Field,禁用
使用 disabled 属性禁用输入框。要为禁用状态添加样式,请向 Field 组件添加 data-disabled 属性。
This field is currently disabled.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
无效
使用 aria-invalid 属性标记输入为无效。要为无效状态添加样式,请向 Field 组件添加 data-invalid 属性。
This field contains validation errors.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
文件
使用 type="file" 属性创建文件输入。
Select a picture to upload.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
行内
使用带有 orientation="horizontal" 的 Field 创建行内输入。配合 Button 创建带按钮的搜索输入。
import { Button } from "@/components/ui/button"
import { Field } from "@/components/ui/field"
import { Input } from "@/components/ui/input"网格
使用网格布局将多个输入并排放置。
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
必填
使用 required 属性表示必填输入。
This field must be filled out.
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
徽章
在标签中使用 Badge 来突出显示推荐字段。
import { Badge } from "@/components/ui/badge"
import { Field, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"输入组
要在输入框内部添加图标、文本或按钮,请使用 InputGroup 组件。更多示例请参见 输入组 组件。
https://
import { Field, FieldLabel } from "@/components/ui/field"
import {
InputGroup,按钮组
要为输入框添加按钮,请使用 ButtonGroup 组件。更多示例请参见 按钮组 组件。
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { Field, FieldLabel } from "@/components/ui/field"表单
包含多个输入、选择框和按钮的完整表单示例。
import { Button } from "@/components/ui/button"
import {
Field,