| Crates.io | dioxus-bootstrap |
| lib.rs | dioxus-bootstrap |
| version | 0.2.0 |
| created_at | 2025-01-02 19:10:48.166619+00 |
| updated_at | 2025-08-07 22:52:58.829379+00 |
| description | A set of Bootstrap-based components for Dioxus. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1501788 |
| size | 245,748 |
An unofficial Bootstrap 5.3 component library for Dioxus applications, providing a comprehensive set of responsive, accessible UI components with automatic light/dark mode switching.
⚠ This is very early work in progress. I am publishing it in case it is useful to anyone else, but please understand that it is expected to be wildly unstable for a while. ⚠
dioxus-routerTo add this to your dioxus project, you can just run the following:
cargo add dioxus-bootstrap
Then you will need to ensure that the Bootstrap CSS and Javascript are loaded. The Bootstrap CSS does a lot of styling that may interfere with your existing style, so be prepared to change how you're doing CSS when you do this.
There are a couple of ways to do this:
There is a GlobalTheme component that will enable light or dark mode, and automatic switching (by default). It will also load the Bootstrap assets via CDN by default. If you want to load the assets manually or from somewhere else, you will need to disable this.
# Additional CSS style files
style = [
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
]
# Additional JavaScript files
script = [
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
]
Within your App component, add this:
rsx!{
document::Link {
rel: "stylesheet",
href: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css",
integrity: "sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH",
crossorigin: "anonymous"
}
document::Script {
src: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js",
integrity: "sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz",
crossorigin: "anonymous"
}
}
Although this library is very early, I think it has several useful purposes. While it may be missing a lot of the ergonomic components that I hope to eventually create, there is nothing special about these components. You can mix and match the crate's components with other Bootstrap elements, which should work as you expect. I'm hoping that eventually, other people will make general-purpose components and contribute them back as well.
One of the more annoying things that I've figured out is automatically switching between dark and light mode based on system settings, which isn't totally obvious in Dioxus. That alone makes it worthwhile for me to use.
This repository includes a comprehensive demo application that showcases all available components and their usage patterns.
# Clone the repository
git clone https://github.com/your-repo/dioxus-bootstrap
cd dioxus-bootstrap
# Run the web demo (recommended)
cd demo && dx serve --platform web
# Or run on desktop
cd demo && dx serve --platform desktop
# Or run on mobile
cd demo && dx serve --platform mobile
The demo application serves as both documentation and a testing environment. It demonstrates:
The demo is organized into several pages:
use dioxus::prelude::*;
use dioxus_bootstrap::prelude::*;
fn App() -> Element {
rsx! {
// Enable Bootstrap assets and theme switching
GlobalTheme { theme: Theme::Auto }
Container {
Row {
Col { md: 6,
Card {
CardHeader { "Welcome" }
CardBody {
"This is a Bootstrap card in Dioxus!"
Button {
variant: ButtonVariant::Primary,
"Click me"
}
}
}
}
}
}
}
}
# Build the library
cargo build
# Run with release optimizations
cargo build --release
src/ - Main library code with component modulesdemo/ - Demo application showcasing component usageassets/ - JavaScript files for theme switching functionalityThis library follows Bootstrap 5.3 specifications and maintains compatibility with standard Bootstrap HTML/CSS. When adding components:
This project is licensed under the same terms as Bootstrap and Dioxus.