@acusti/dropdown 中文文档教程

发布于 3年前 浏览 11 项目主页 更新于 3年前

@acusti/dropdown

最新版本依赖状态捆绑包大小downloads per month

Dropdown 是一个 React 组件,它呈现一个带有触发器的类似菜单的 UI 用户单击以显示位于触发器下方的下拉菜单。 下拉列表的主体可以包含任何 DOM,并且可以是许多下拉列表 组合成一个多项目菜单,就像顶部工具栏中的系统菜单 macOS 的。

该组件存在的三个主要设计目标:

  1. Best-in-class UX (inspired by macOS native menus) with excellent keyboard support
  2. Best-in-class DX with the simplest possible API:
    1. To create a dropdown with a <button> trigger, pass in a single child element with the body of the dropdown
    2. To create a dropdown with a custom trigger, pass in exactly two child elements; the first is the trigger, the second is the body of the dropdown
    3. To create a dropdown with a list of items as the body, use the data-ukt-item boolean to mark dropdown items, or use data-ukt-value="foo" to specify that an element is a dropdown item and the value of that item at the same time (otherwise, the value is the text content of the dropdown item element)
    4. To style your dropdowns, use CSS; there are a collection of CSS variables used internally to style them if that works best for you, or just override the minimal default CSS as appropriate
  3. Lightweight bundle size with the bare minimum of dependencies (see minzipped size above)

@acusti/dropdown

latest versiondependencies statusbundle sizedownloads per month

Dropdown is a React component that renders a menu-like UI with a trigger that the user clicks to disclose a dropdown positioned below the trigger. The body of the dropdown can include any DOM, and many dropdowns can be combined to form a multi-item menu, like the system menu in the top toolbar of macOS.

The three primary design goals for the existence of this component:

  1. Best-in-class UX (inspired by macOS native menus) with excellent keyboard support
  2. Best-in-class DX with the simplest possible API:
    1. To create a dropdown with a <button> trigger, pass in a single child element with the body of the dropdown
    2. To create a dropdown with a custom trigger, pass in exactly two child elements; the first is the trigger, the second is the body of the dropdown
    3. To create a dropdown with a list of items as the body, use the data-ukt-item boolean to mark dropdown items, or use data-ukt-value="foo" to specify that an element is a dropdown item and the value of that item at the same time (otherwise, the value is the text content of the dropdown item element)
    4. To style your dropdowns, use CSS; there are a collection of CSS variables used internally to style them if that works best for you, or just override the minimal default CSS as appropriate
  3. Lightweight bundle size with the bare minimum of dependencies (see minzipped size above)
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文