A11Y-按钮列表是否应该是小型列表或作为按钮列表?

发布于 2025-01-31 21:30:56 字数 446 浏览 6 评论 0原文

我有一个按钮列表,可以过滤Spa应用中的目录。结构看起来像这样:

<div>
  <button>filter 1</button>
  <button>filter 2</button>
  <button>filter 3</button>
</div>
<div>
   {results}
</div>

单击每个按钮会导致从服务器获取新结果,然后在区域{rescem)中进行更新。

我们拥有一位可访问性专家,坚持认为我们将上述结构更改为一名表演者,但是我看不出它将如何工作,从我的理解中,小报需要选项卡和相应的TABPANEL。按钮可能是标签,但是TabPanel是什么?我没有预先存在的数据,在单击按钮时必须将其获取。

我将如何更新以上以使其符合可访问性?

I've got a list of buttons that filter a catalog in a SPA app. The structure looks like this:

<div>
  <button>filter 1</button>
  <button>filter 2</button>
  <button>filter 3</button>
</div>
<div>
   {results}
</div>

Clicking each of button causes new results to be fetched from a server and then updated in the area {results}.

We've got an accessibility expert that is insisting that we change the above structure to be a tablist, but I don't see how it would work, as from my understanding, a tablist needs tabs and a corresponding tabpanel. The buttons could be the tabs, but what of the tabpanel? I don't have the data pre-existing, it must be fetched when the buttons are clicked.

How would I update the above to make it comply with accessibility?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一花一树开 2025-02-07 21:30:56

感觉就像是一个小报,因为单击按钮本质上会改变您的视图,但是没有可访问的原因,您必须使用

我同意您会将其“强迫”到模式中,因为您只有一个更新的面板,而不是三个单独的面板。

一组3个按钮都可以更新相同的容器,并且 使用小报是完全可以的。

对于非远见用户而言,他们有3个按钮可供选择吗?如果不是这样,最好将它们包含在列表中。您可以使用真实的&lt; ul&gt;,并关闭子弹点样式或使用role =“ list” and rowa =“ listItem” 。

<div role="list">
  <span role="listitem">
    <button>filter 1</button>
  </span>
  <span role="listitem">
    <button>filter 2</button>
  </span>
  <span role="listitem">
    <button>filter 3</button>
  </span>
</div>

我使用&lt; span&gt;用于按钮的容器来保留原始示例的内联性。

接下来,对于非远见用户而言,该页面选择按钮时已更新该页面是显而易见的吗?这可能很简单,就像说“选择按钮将更新结果”,或者从按钮标签中显而易见。取决于您的情况, aria-live 可能需要。但这超出了您最初的问题的扩展。

It kind of feels like a tablist because clicking on the buttons essentially changes your view but there is not an accessibility reason that you have to use the tablist design pattern.

I agree that you'd sort of be "forcing" it into the pattern since you only have one panel that updates rather than three separate panels.

It's perfectly fine to have a group of 3 buttons all update the same container and not use a tablist.

Is it obvious to the non-sighted user that they have 3 buttons to choose from? If not, it might be nice to have them contained in a list. You can use a real <ul> and turn off the bullet point styling or use role="list" and role="listitem".

<div role="list">
  <span role="listitem">
    <button>filter 1</button>
  </span>
  <span role="listitem">
    <button>filter 2</button>
  </span>
  <span role="listitem">
    <button>filter 3</button>
  </span>
</div>

I used <span> containers for the buttons to keep the inline nature of your original example.

Next, is it obvious to the non-sighted user that the page has updated when the button was selected? It might be as simple as saying "selecting a button will update the results" or it might be obvious from the button labels. Depending on your situation, aria-live might be needed. But that's going beyond the extend of your original question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文