表单与按钮
Field交互预览
用法
为单个表单控件关联标签、说明和错误信息。
import { Field, Input } from 'nibferry';
<Field label="工作区名称" hint="显示在侧栏中"><Input name="name" /></Field>参数与交互
label 是可点击的标签。hint 和 error 通过 aria-describedby 关联到控件;有错误时标记 aria-invalid。children 接受一个能转发 id、aria-describedby、aria-invalid 的控件,保留控件已有的说明和 ID。其余属性作用在外层 div。
文本输入框 Input
统一文本输入框的外观并保留原生表单行为。
import { Input } from 'nibferry';
<Input aria-label="搜索项目" type="search" placeholder="搜索项目" />参数与交互
type 支持 text、search、email、password、url 和 tel。支持 value / onChange、defaultValue、表单校验、禁用和 ref。有可见标签时可搭配 Field。
按钮 Button
执行操作或提交表单。
import { Button } from 'nibferry';
<Button type="submit" variant="primary">保存</Button>参数与交互
variant 支持 primary、secondary(默认)、ghost、danger。默认 type="button"。支持原生按钮属性、事件、禁用和 ref。
复制按钮 CopyButton
复制消息或代码后显示勾选反馈。写入失败时提示手动复制。
import { CopyButton } from 'nibferry';
<CopyButton label="复制代码" text={snippet} />参数与交互
text 是要写入剪贴板的原文,label 设置按钮名称和提示,默认「复制」。空文本或 disabled 会禁用按钮。支持原生 button 属性、键盘操作和 ref。按钮使用 PaneButton 的颜色和动效。