Quiet / 文档

组件

表单

字段从上到下排成一列,相距 24px。输入框没有边框,只有一层浅灰的底色,和行内代码是同一种灰。

字段 .q-field

标签在上,输入框在中间,说明在下面。标签是 16px 中等字重,说明是 14px 的三级灰。

<label class="q-field">
  <span class="q-field-label">邮箱</span>
  <input class="q-input" type="email" placeholder="you@example.com" />
  <span class="q-field-hint">用于登录和接收每周摘要。</span>
</label>

输入框 40px 高、8px 圆角。点进去会出现一圈 2px 的主色描边。

出错

给输入框加 aria-invalid="true",描边变成红色,下面用 .q-field-error 写明原因。

<label class="q-field">
  <span class="q-field-label">名称</span>
  <input class="q-input" type="text" aria-invalid="true" />
  <span class="q-field-error">名称不能为空。</span>
</label>

多行文字和下拉框

<div class="q-form">
  <label class="q-field">
    <span class="q-field-label">简介</span>
    <textarea class="q-textarea" placeholder="一两句话介绍自己"></textarea>
  </label>
  <label class="q-field">
    <span class="q-field-label">语言</span>
    <select class="q-select">
      <option>简体中文</option>
      <option>繁體中文</option>
      <option>English</option>
    </select>
  </label>
</div>

单选和多选 .q-check

用浏览器自带的控件,只把颜色改成主文字色。几个选项用 .q-checks 横着排。

<div class="q-checks">
  <label class="q-check"><input type="radio" name="demo-theme" checked />跟随系统</label>
  <label class="q-check"><input type="radio" name="demo-theme" />浅色</label>
  <label class="q-check"><input type="radio" name="demo-theme" />深色</label>
</div>
<div class="q-checks">
  <label class="q-check"><input type="checkbox" checked />评论</label>
  <label class="q-check"><input type="checkbox" />提及</label>
</div>

开关 .q-switch

36×20px。关着是浅灰,开着是主文字色。通常放在列表行的行尾,见列表。

<div class="q-checks">
  <input class="q-switch" type="checkbox" aria-label="开着的开关" checked />
  <input class="q-switch" type="checkbox" aria-label="关着的开关" />
</div>

整个表单 .q-form

把字段包在 .q-form 里,最后是一排按钮。保存用主按钮。完整的例子见设置页。

<form class="q-form">
  <label class="q-field">…</label>
  <label class="q-field">…</label>
  <div class="q-actions">
    <button class="q-button q-button--primary" type="submit">保存修改</button>
  </div>
</form>
  • 一个字段占一行,不把两个字段并排。
  • 字段多了就用分组标签分成几组,每组之间 64px。
  • 输入框里的字不小于 16px,手机上点进去才不会自动放大页面。