首页/新闻资讯/正文详情

Flowbite 搜索输入框组件完全指南:从基础搜索栏到语音搜索与高级筛选

发布时间:2026/9/25 4:59:53 来源:云帆数科 栏目:资讯中心
Flowbite 搜索输入框组件完全指南:从基础搜索栏到语音搜索与高级筛选
UI组件前端【免费下载链接】flowbiteOpen-source UI component library and front-end development framework based on Tailwind CSS项目地址https://gitcode.com/gh_mirrors/fl/flowbite点击查看免费下载搜索框是每个站点的“入口级”交互组件。本篇基于 Flowbite 开源组件库基于 Tailwind CSS 构建的 UI 组件库中官方文档 content/forms/search-input.md 的完整内容系统讲解搜索输入框的 6 种实战形态基础搜索栏、分类下拉搜索、极简搜索、位置搜索、语音搜索与多条件高级搜索并结合仓库源码深入剖析下拉菜单的数据属性体系、设计令牌与表单基础样式。读完本文你将能够直接复制可运行的 HTML 代码并理解每一个 class 与 data 属性背后的实现原理将其灵活集成进自己的 Tailwind 项目。开始之前引入 Flowbite 运行时本页所有示例均构建在 Flowbite 的 Tailwind 插件与 JavaScript 运行时之上。其中带下拉菜单的示例依赖data-dropdown-toggle属性驱动必须加载 Flowbite 的 JavaScript 文件否则下拉面板将始终处于hidden状态。完整安装步骤见 快速上手指南核心三步如下通过 NPM 安装依赖npm install flowbite在input.css中引入主题变量以默认主题为例import flowbite/src/themes/default;在 CSS 中挂载插件并在页面中引入构建产物flowbite.min.js官方文档站的做法是直接在示例预览 iframe 中注入script srcflowbite.min.js参见 layouts/_shortcodes/example.html。提示下拉搜索示例还需要项目中注册 Flowbite 的 Tailwind 插件。仓库自身的 tailwind.config.js 正是通过require(./plugin)({ forms: true, ... })的方式启用的。基础搜索栏Search bar example最常用的形态搜索图标绝对定位在输入框内部左侧提交按钮绝对定位在输入框内部右侧右下角整体只有一个输入框的视觉尺寸。form classmax-w-md mx-auto label forsearch classblock mb-2.5 text-sm font-medium text-heading sr-only Search/label div classrelative div classabsolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none svg classw-4 h-4 text-body aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-width2 dm21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z//svg /div input typesearch idsearch classblock w-full p-3 ps-9 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand shadow-xs placeholder:text-body placeholderSearch required / button typebutton classabsolute end-1.5 bottom-1.5 text-white bg-brand hover:bg-brand-strong box-border border border-transparent focus:ring-4 focus:ring-brand-medium shadow-xs font-medium leading-5 rounded text-xs px-3 py-1.5 focus:outline-noneSearch/button /div /form要点拆解图标层absolute inset-y-0 start-0让图标容器在垂直方向铺满输入框、水平方向贴左ps-3提供 12px 内边距pointer-events-none保证点击穿透不会遮挡输入框光标。文字留白输入框使用ps-936px 左内边距为左侧图标腾出空间内部按钮使用end-1.5 bottom-1.5定位在右下角天然形成“框内按钮”的视觉效果。输入类型使用typesearch在主流浏览器中会自带清除按钮配合required约束表单提交。输入框本体使用typesearch后插件会对其应用统一的基础表单样式见下文“表单基础样式”一节。此示例由官方文档站通过{{ example ... }}短代码渲染为可交互预览支持明暗模式切换交互本身不依赖额外 JavaScript因此仅附带“Requires Flowbite JS”提示性徽标实际无需额外初始化。带分类下拉的搜索Search with dropdown在搜索框左侧拼接一个“全部分类All categories”下拉按钮用户先选择搜索范围如 Shopping、Images、News、Finance再输入关键词这是电商、内容站最常见的搜索形态。form classmax-w-2xl mx-auto div classflex shadow-xs rounded-base -space-x-0.5 label forsearch-dropdown classblock mb-2.5 text-sm font-medium text-heading sr-only Your Email/label button iddropdown-button>form classflex items-center max-w-sm mx-auto space-x-2 label forsimple-search classsr-onlySearch/label div classrelative w-full div classabsolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none svg classw-4 h-4 text-body aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-linejoinround stroke-width2 dM8 8v8m0-8a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm8-8a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0 0a4 4 0 0 1-4 4h-1a3 3 0 0 0-3 3//svg /div input typetext idsimple-search classpx-3 py-2.5 bg-neutral-secondary-medium border border-default-medium rounded-base ps-9 text-heading text-sm focus:ring-brand focus:border-brand block w-full placeholder:text-body placeholderSearch branch name... required / /div button typesubmit classinline-flex items-center justify-center shrink-0 text-white bg-brand hover:bg-brand-strong focus:ring-4 focus:ring-brand-medium shadow-xs rounded-base w-10 h-10 focus:outline-none svg classw-5 h-5 aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-width2 dm21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z//svg span classsr-onlyIcon description/span /button /form实现说明左侧图标层沿用了“绝对定位 ps-9留白”的手法按钮采用w-10 h-10正方形尺寸并rounded-base12px 圆角图标本身w-5 h-5略大于输入框内图标。按钮内部的纯图标没有文本因此用span classsr-only提供屏幕阅读器可读的隐藏描述这是本组件库贯彻的无障碍实践。输入框此处用的是typetext与typesearch相比不会出现浏览器自带清除按钮——两种类型按需取舍。位置搜索Location search将“分类下拉”升级为“国家/地区下拉”在搜索城市或地址前先选定国家USA、Australia、United Kingdom、France、Canada下拉菜单项带国旗图标。form classmax-w-lg mx-auto div classflex shadow-xs rounded-base -space-x-0.5 label forsearch-dropdown-location classblock mb-2.5 text-sm font-medium text-heading sr-only Choose city/label button iddropdown-button-location>form classflex items-center max-w-lg mx-auto space-x-2 label forvoice-search classsr-onlySearch/label div classrelative w-full div classabsolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none svg classw-4 h-4 text-body aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-linejoinround stroke-width2 dM12 7h.01m3.486 1.513h.01m-6.978 0h.01M6.99 12H7m9 4h2.706a1.957 1.957 0 0 0 1.883-1.325A9 9 0 1 0 3.043 12.89 9.1 9.1 0 0 0 8.2 20.1a8.62 8.62 0 0 0 3.769.9 2.013 2.013 0 0 0 2.03-2v-.857A2.036 2.036 0 0 1 16 16Z//svg /div input typetext idvoice-search classblock w-full ps-9 pe-3 py-2.5 bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base focus:ring-brand focus:border-brand shadow-xs placeholder:text-body placeholderSearch Mockups, Logos, Templates... required / button typebutton classabsolute inset-y-0 end-0 flex items-center pe-3 svg classw-4 h-4 text-body hover:text-heading aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-linejoinround stroke-width2 dM19 9v3a5.006 5.006 0 0 1-5 5h-4a5.006 5.006 0 0 1-5-5V9m7 9v3m-3 0h6M11 3h2a3 3 0 0 1 3 3v5a3 3 0 0 1-3 3h-2a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3Z//svg /button /div button typesubmit classinline-flex items-center text-white bg-brand hover:bg-brand-strong box-border border border-transparent focus:ring-4 focus:ring-brand-medium shadow-xs font-medium leading-5 rounded-base text-sm px-4 py-2.5 focus:outline-none svg classw-4 h-4 me-1.5 aria-hiddentrue xmlnshttp://www.w3.org/2000/svg width24 height24 fillnone viewBox0 0 24 24path strokecurrentColor stroke-linecapround stroke-width2 dm21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z//svg Search /button /form实现说明麦克风按钮与左侧搜索图标对称分布inset-y-0 end-0pe-3右侧 12px 内边距图标用text-body hover:text-heading提供悬停变色反馈。输入框需要在右侧预留空间因此除ps-9外再追加pe-3避免文字与麦克风图标重叠。注意该示例仅提供“语音搜索入口”的 UI 结构button未绑定任何事件麦克风点击后的语音识别逻辑如 Web Speech API需由开发者自行接入。高级搜索输入Advanced search input在一行内堆叠多个下拉筛选器适合“域名/URL 检索”这类多维度过滤场景先选协议http / https / http https再选域范围Subdomain / Domain / Top-Level Domain / Root Domain最后输入关键词。form classmax-w-2xl mx-auto div classflex shadow-xs rounded-base -space-x-0.5 label forsearch-dropdown-advanced classblock mb-2.5 text-sm font-medium text-heading sr-only Your Email/label button iddropdown-button-links>赞分享UI组件前端【免费下载链接】flowbiteOpen-source UI component library and front-end development framework based on Tailwind CSS项目地址https://gitcode.com/gh_mirrors/fl/flowbite点击查看免费下载相关推荐Ant Design Input.Search 搜索输入框实战指南从带搜索按钮的输入框到完整搜索场景Ant Design Input.Search 搜索输入框实战指南从带搜索按钮的输入框到完整搜索场景 搜索输入框是企业级应用中最常见的高频交互组件之一。本篇技前端UI组件设计系统OpenProject 全局搜索功能完全指南搜索栏、高级搜索与全文检索实战OpenProject 全局搜索功能完全指南搜索栏、高级搜索与全文检索实战 导读 本文以 OpenProject 官方用户指南中的 Search 章节 htt后端前端项目管理企业应用协同办公如何快速掌握通达信数据分析mootdx完整使用指南如何快速掌握通达信数据分析mootdx完整使用指南 在金融数据分析和量化交易领域获取准确、实时的市场数据是成功的关键。mootdx作为一个强大的Python金融科技数据分析上一篇数据守护者15款开源备份工具深度横评2025版下一篇DETR与边缘计算在资源受限设备上部署目标检测模型创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关推荐

ESP32-C3 当管家:软件模拟 SWD 实现 RP2040 固件下载与日志采集
ESP32-C3 当管家:软件模拟 SWD 实现 RP2040 固件下载与日志采集

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 4:59:52

产线烧录良率排查全攻略:从硬件连接到固件格式的链路诊断
产线烧录良率排查全攻略:从硬件连接到固件格式的链路诊断

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 4:59:52

BLE Mesh抓包实战:nRF52840 Dongle与Wireshark联合调试指南
BLE Mesh抓包实战:nRF52840 Dongle与Wireshark联合调试指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 4:59:45

SSM+微信小程序毕设实战:大学生社团活动管理系统架构与部署
SSM+微信小程序毕设实战:大学生社团活动管理系统架构与部署

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 6:53:57

Locomotive Scroll 文档站构建与部署指南:基于 Docusaurus 的安装、开发与发布全流程
Locomotive Scroll 文档站构建与部署指南:基于 Docusaurus 的安装、开发与发布全流程

【免费下载链接】locomotive-scroll 🛤 Detection of elements in viewport & smooth scrolling with parallax. 项目地址: https://gitcode.com/gh_mirrors/lo/locomotive-scroll 点击查看 免费下载 本文以 packages/docs/README.md 为核心&#x… · 2026/9/25 6:53:44

如何编排自己的机器狗舞蹈:robot-dog-swarm-control 动作序列与节奏灯效定制指南
如何编排自己的机器狗舞蹈:robot-dog-swarm-control 动作序列与节奏灯效定制指南

如何编排自己的机器狗舞蹈:robot-dog-swarm-control 动作序列与节奏灯效定制指南 【免费下载链接】CupCode_robot-dog-swarm-control模块 源师兄扩展项目: 机器狗群控 | 由源师兄组织创建 项目地址: https://gitcode.com/yuanshixiong/robot-dog-swarm-control … · 2026/9/25 6:53:38

金融场景下 Claude Managed Agents API 智能体设计与落地实践
金融场景下 Claude Managed Agents API 智能体设计与落地实践

1. 金融场景下 Managed Agents API 的整体设计思路1.1 为什么金融行业需要“托管型智能体”而不是裸调模型金融业务对智能体的诉求和通用聊天场景完全不是一个量级。通用场景里,模型答错一句话顶多让人笑一下;但在金融场景里,一次错误的账户余… · 2026/9/25 6:53:32

ccgui跨平台构建与部署:macOS/Windows/Linux安装包制作、自动更新与发布全流程指南
ccgui跨平台构建与部署:macOS/Windows/Linux安装包制作、自动更新与发布全流程指南

ccgui跨平台构建与部署:macOS/Windows/Linux安装包制作、自动更新与发布全流程指南 【免费下载链接】desktop-cc-gui Multi-engine AI coding desktop client (Tauri). Claude Code, Codex, Gemini, OpenCode, DeepSeek Harness and more in one GUI. 项目地址: h… · 2026/9/25 6:53:32

ng-zorro-antd Descriptions 组件详解:只读字段分组的表格化渲染与响应式列布局
ng-zorro-antd Descriptions 组件详解:只读字段分组的表格化渲染与响应式列布局

UI组件前端 【免费下载链接】ng-zorro-antd Angular UI Component Library based on Ant Design 项目地址: https://gitcode.com/gh_mirrors/ng/ng-zorro-antd 点击查看 免费下载 本篇指南围绕 NG-ZORRO(ng-zorro-antd)的 Descriptions&… · 2026/9/25 6:53:26

数值优化(Numerical Optimization)学习系列-03-共轭梯度方法(Conjugate Gradient)
数值优化(Numerical Optimization)学习系列-03-共轭梯度方法(Conjugate Gradient)

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 1:00:31

创维E900V22D刷机全攻略:S905L3SB芯片兼容性解析与救砖实战
创维E900V22D刷机全攻略:S905L3SB芯片兼容性解析与救砖实战

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 1:00:31

MQTT协议原理与Broker服务器搭建实战:从Mosquitto到EMQX
MQTT协议原理与Broker服务器搭建实战:从Mosquitto到EMQX

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/25 1:00:37

了解更多?预约专属演示

我们的顾问将为您一对一讲解产品与方案

企业微信二维码