网页
综合
更新时间 2026-11-13 15:36:19
Install Bootstrap · Bootstrap v6.0
自动蜘蛛
getbootstrap.com
正文约 4143 字
Add Bootstrap to your project with CDN, package manager, or source files.
Pull in Bootstrap’s source files into nearly any project with a package manager. Package installs don‘t include documentation or complete build scripts. You can also use any demo from our Examples repo to quickly jumpstart Bootstrap projects.
After installing, head to our npm guide for a full setup guide.
Use the Bootstrap npm starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
Using import * as bootstrap from 'bootstrap' will load all of Bootstrap’s plugins onto a bootstrap object. You can also import plugins individually for automatic tree shaking:
You can also import plugins directly by loading the /js/dist/*.js files under the package’s top-level directory.
Bootstrap’s package.json contains some additional metadata under the following keys:
Additionally, Bootstrap ships a .browserslistrc file at the package root, which defines browser targets for tools like Browserslist and Autoprefixer. See Browsers & devices for the full support policy.
Yarn 2+ (aka Yarn Berry) doesn’t support the node_modules directory by default, so our Sass & JS example needs some adjustments:
Other package-managed installs are available as well for Bootstrap as well.
We recommend installing Bootstrap in your Ruby apps using Bundler, but you can also use RubyGems. See the gem’s README for further details.
If you develop in .NET Framework, you can also install and manage Bootstrap’s CSS or Sass and JavaScript using NuGet. Newer projects should use libman or another method as NuGet is designed for compiled code, not frontend assets.
Include Bootstrap’s CSS and JavaScript files via CDN. CDNs (Content Delivery Networks) are services that provides copies of libraries for your website. Instead of installing Bootstrap via a package manager, you link to CDN-hosted files in your website.
Here are our primary CDN links for CSS and JavaScript:
If you prefer to include Floating UI and Vanilla Calendar Pro separately instead of using the bundle, use an import map to resolve the bare module specifiers:
You can also use the CDN to fetch any of our additional builds.
When using CDN links, be sure to use the integrity attribute to verify the correct files and versions. These hashes are unique to each file and version of Bootstrap, so when you update to a new version, be sure the integrity attribute is also updated.
We also include a crossorigin="anonymous" attribute to prevent CORS errors.
We recommend jsDelivr and use it ourselves in our documentation. However, in some cases—like in some specific countries or environments—you may need to use other CDN providers like cdnjs or unpkg.
You’ll find the same files on these CDN providers, albeit with different URLs. With cdnjs, you can use this direct Bootstrap package link to copy and paste ready-to-use HTML snippets for each dist file from any version of Bootstrap.
Security warning — If the SRI hashes differ for a given file, you shouldn’t use the files from that CDN, because it means that the file was modified by someone else.
Note that you should compare same length hashes, e.g. sha384 with sha384, otherwise it’s expected for them to be different. As such, you can use an online tool like SRI Hash Generator to make sure that the hashes are the same for a given file. Alternatively, assuming you have OpenSSL installed, you can achieve the same from the CLI, for example:
You can also do the old fashioned thing and download Bootstrap manually. Choose between compiled dist (distribution) files or source files. The latter requires some additional tooling to compiled and use Bootstrap in your project.
Should you require our full set of build tools, they are included for developing Bootstrap and its docs, but they’re likely unsuitable for your own purposes.
Bootstrap’s documentation is available in a machine-readable format, and we ship agent skills for AI-powered coding tools. See AI for our llms.txt files and the full list of skills.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。