跳转到正文

组件

字段

将控件与其标签、说明和错误信息组合在一起。

用法

基础

We only use this for receipts.
HTML
<bs:bsui-field>
  <bs:bsui-field-label text="Email address" />
  <bs:bsui-input type="email" placeholder="you@example.com" />
  <bs:bsui-field-description text="We only use this for receipts." />
</bs:bsui-field>

无效状态

将字段标记为无效后,控件会改变颜色,并在下方显示消息。

Enter an address with a domain, like ada@example.com.
HTML
<bs:bsui-field invalid="true">
  <bs:bsui-field-label text="Work email" />
  <bs:bsui-input type="email" defaultValue="ada@example" />
  <bs:bsui-field-error text="Enter an address with a domain, like ada@example.com." />
</bs:bsui-field>

必填

要求写在帮助文本中,因此标签可以保持简短。

Required. This name appears on every invoice.
HTML
<bs:bsui-field>
  <bs:bsui-field-label text="Workspace name" />
  <bs:bsui-input placeholder="Acme Production" required="true" />
  <bs:bsui-field-description text="Required. This name appears on every invoice." />
</bs:bsui-field>

已禁用

禁用字段及其内部控件,让整行呈现锁定状态。

The URL is fixed once the workspace is created.
HTML
<bs:bsui-field disabled="true">
  <bs:bsui-field-label text="Workspace URL" />
  <bs:bsui-input defaultValue="acme.blockstudio.dev" disabled="true" />
  <bs:bsui-field-description text="The URL is fixed once the workspace is created." />
</bs:bsui-field>

选择字段

字段可以像包裹单个输入框一样包裹一组控件。

Pick a target before deploying.
HTML
<bs:bsui-field invalid="true">
  <bs:bsui-field-label text="Deploy target" />
  <bs:bsui-radio-group orientation="horizontal">
    <bs:bsui-radio value="staging" label="Staging" />
    <bs:bsui-radio value="production" label="Production" />
  </bs:bsui-radio-group>
  <bs:bsui-field-error text="Pick a target before deploying." />
</bs:bsui-field>

结构

字段由以下区块组成。每个区块都是独立的区块,只会在其父级内部渲染。

  • bsui/field
  • bsui/field-description
  • bsui/field-error
  • bsui/field-label

属性

属性类型默认
name text —
invalid toggle false
disabled toggle false

bsui/field-description

属性类型默认
text richtext —

bsui/field-error

属性类型默认
text richtext —

bsui/field-label

属性类型默认
text richtext —