apalfrey/select2-bootstrap-5-theme
最新稳定版本:1.3.0
Composer 安装命令:
composer require apalfrey/select2-bootstrap-5-theme
包简介
Select2 theme for Bootstrap 5
README 文档
README
Select2 v4 theme for Bootstrap 5, inspired by select2-bootstrap4-theme
Works with Select2 v4.0 and v4.1
Docs
https://apalfrey.github.io/select2-bootstrap-5-theme/
Installation
CDN
Select2 v4.0
<!-- Styles --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" /> <!-- Or for RTL support --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.rtl.min.css" /> <!-- Scripts --> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.full.min.js"></script>
Select2 v4.1
<!-- Styles --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" /> <!-- Or for RTL support --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.rtl.min.css" /> <!-- Scripts --> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
Package Managers
# npm $ npm install select2-bootstrap-5-theme # yarn $ yarn add select2-bootstrap-5-theme # composer $ composer require apalfrey/select2-bootstrap-5-theme
HTML
<link rel="stylesheet" href="/path/to/select2.css"> <link rel="stylesheet" href="/path/to/select2-bootstrap-5-theme.min.css"> <!-- Or for RTL support --> <link rel="stylesheet" href="/path/to/select2-bootstrap-5-theme.rtl.min.css">
SCSS
@import "node_modules/select2/src/scss/core"; // If you need to import Bootstrap as well: @import "node_modules/select2-bootstrap-5-theme/src/select2-bootstrap-5-theme"; // Or if you have already imported Bootstrap: @import "node_modules/select2-bootstrap-5-theme/src/include-all";
Usage
// Basic $("select").select2({ theme: "bootstrap-5", }); // Small using Select2 properties $("#form-select-sm").select2({ theme: "bootstrap-5", containerCssClass: "select2--small", // For Select2 v4.0 selectionCssClass: "select2--small", // For Select2 v4.1 dropdownCssClass: "select2--small", }); // Small using Bootstrap 5 classes $("#form-select-sm").select2({ theme: "bootstrap-5", dropdownParent: $("#form-select-sm").parent(), // Required for dropdown styling }); // Large using Select2 properties $("select").select2({ theme: "bootstrap-5", containerCssClass: "select2--large", // For Select2 v4.0 selectionCssClass: "select2--large", // For Select2 v4.1 dropdownCssClass: "select2--large", }); // Large using Bootstrap 5 classes $("#form-select-lg").select2({ theme: "bootstrap-5", dropdownParent: $("#form-select-lg").parent(), // Required for dropdown styling });
Build tools
This repo uses Gulp to compile the assets, see below for the included npm scripts and Gulp tasks and what they do;
Contributing
If you have ideas for improvements or changes, feel free to submit an issue, or if you have changes you'd like in the project, feel free to submit a pull request. Make sure you run gulp compile or npm run compile before submitting a pull request to ensure the styles are compiled.
Find out more about contributing here
License
MIT License
Copyright (c) 2022 Andrew Palfrey <apalfrey@apalfrey.me>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
apalfrey/select2-bootstrap-5-theme 适用场景与选型建议
apalfrey/select2-bootstrap-5-theme 是一款 基于 SCSS 开发的 Composer 扩展包,目前已累计 134.87k 次下载、GitHub Stars 达 220, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「css」 「theme」 「bootstrap」 「scss」 「select2」 「bootstrap5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 apalfrey/select2-bootstrap-5-theme 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 apalfrey/select2-bootstrap-5-theme 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 apalfrey/select2-bootstrap-5-theme 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
A Bootstrap 4.x base theme for SilverStripe
Lucency Theme
Define your own css rule-sets for the TYPO3 CMS backend.
统计信息
- 总下载量: 134.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 221
- 点击次数: 44
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04