是否可以在React-Bootstrap-typeahead中自定义清除按钮的内容?

发布于 2025-01-28 13:23:29 字数 610 浏览 3 评论 0 原文

使用 react-bootstrap-typeahead 是否有可能更改清除按钮的内容?

我需要包含一个Fontawesome图标和“清晰”文本以匹配设计。

查看演示我可以看到 clearButton 组件,但是我看不到如何自定义。我尝试更改 label prop,但这没有效果:

< clearbutton onClick = {onClear} label =“ clear”/>

可以添加:

  1. 标签文本
  2. 通用图标?

清除按钮的

Using react-bootstrap-typeahead is it possible to change the contents of the Clear button?

I need to include a FontAwesome icon and "CLEAR" text to match a design.

Looking at the [RBT] Custom Aux Components demo I can see the ClearButton component, but I can't see how to customize this. I tried changing the label prop but this had no effect:

<ClearButton onClick={onClear} label="CLEAR" />

Is it possible to add:

  1. label text
  2. a FontAwesome icon

to the Clear button?

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

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

发布评论

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

评论(1

甩你一脸翔 2025-02-04 13:23:29

您无法自定义 clearButton 本身,但是您可以按照链接到链接的示例并使用自己的清除/关闭按钮组件:

<Typeahead ... >
  {({ onClear, selected }) => (
    <div className="rbt-aux">
      {!!selected.length && <MyCloseButton onClick={onClear} />}
    </div>
  )}
</Typeahead>

请注意, clear> clearbutton 并不是什么特别的东西;它只是封装了Bootstrap的关闭按钮到组件中。随时使用自己的按钮!

You can't customize ClearButton itself, but you can follow the example you linked to and use your own clear/close button component:

<Typeahead ... >
  {({ onClear, selected }) => (
    <div className="rbt-aux">
      {!!selected.length && <MyCloseButton onClick={onClear} />}
    </div>
  )}
</Typeahead>

Note that ClearButton isn't really anything special; it just encapsulates the markup and classnames for Bootstrap's Close Button into a component. Feel free to use your own button!

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