跳到内容
栏目
Fiesta

list-bar-search

列表页 通用列表页:标题、工具栏和行,桌面和移动端都适用。

只做搜索的列表使用的独立搜索表单。一个普通的 method="get" 表单。

每个示例都能真实操作,但其中的链接不会跳转到任何地方。 HTML 显示可复制的标记。

已有查询

这个 ✕ 是一个链接,指向去掉查询后的同一屏幕。状态筛选放在隐藏输入里,因此会保留下来。

预览

把这段放进 <div rst-list> 里。

<search>
  <form rst-search method="get" action="/comments">
    <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
    <input type="search" name="q" value="spam" placeholder="搜索评论" aria-label="搜索评论">
    <a rst-search-clear href="/comments?status=held" aria-label="清除搜索">
      <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
    </a>
    <input type="hidden" name="status" value="held">
    <button class="rst-sr-only" type="submit">搜索</button>
  </form>
</search>

在应用里,这会到达 /comments, /comments?status=held。在这里,它的链接和表单哪儿也不去。

已有查询,第 4 页

页码放在隐藏输入里,所以新的搜索会把 page=4 带进一个已经不足四页的结果集。✕ 链接会去掉它:把它指向列表的第一页。

预览

把这段放进 <div rst-list> 里。

<search>
  <form rst-search method="get" action="/comments">
    <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
    <input type="search" name="q" value="spam" placeholder="搜索评论" aria-label="搜索评论">
    <a rst-search-clear href="/comments" aria-label="清除搜索">
      <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
    </a>
    <input type="hidden" name="page" value="4">
    <button class="rst-sr-only" type="submit">搜索</button>
  </form>
</search>

在应用里,这会到达 /comments。在这里,它的链接和表单哪儿也不去。

空,可访问名称取自目录

没有 placeholder。输入框的可访问名称是它的 aria-label,由应用用页面的语言来写。

预览

把这段放进 <div rst-list> 里。

<search>
  <form rst-search method="get" action="/comments">
    <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
    <input type="search" name="q" aria-label="搜索">
    <button class="rst-sr-only" type="submit">搜索</button>
  </form>
</search>

在应用里,这会到达 /comments。在这里,它的链接和表单哪儿也不去。