Blue React
React component library based on Bootstrap 5
Blue React
Use Blue React
Create new project with Vite
To quickly getting started, you can use the template with Vite, React, TypeScript and Blue React. You can use degit to create a new project with this command:
npx degit bruegmann/vite-template-blue-react name-of-my-app
Install to existing project
npm i blue-react
blue-react has blue-web and bootstrap as dependencies, so these will be installed automatically.
Breaking changes between v11 and v12
Changes in Layout component
children doesn’t get wrapped around a div.blue-layout-body anymore. Put your page’s content into the page slot instead:
- <Layout><h1>Hello World</h1></Layout>
+ <Layout page={<h1>Hello World</h1>} />
This lets you place other elements, such as the new LayoutSplitter component, in the layout’s main area through children.
Breaking changes between v10 and v11
Fundamental changes in MenuItem
- Removed props
- onClickAttached
- iconClassName
- labelClassName
- caretClassName
- caretStyle
- isHome
- dropdownClassName
- dropdownStyle
- showDropdown
- onShowDropdown
- supportOutside
- outsideIgnoreClasses
- Renamed
- iconForActive -> iconForCurrent
- isActive -> current
- highlighted -> active
- Changed behviour. Menu item no longer has built in styling if
draggable. But since Menu item extends HTML Button or A element, propsdraggable,onDragStartetc. should still work. - Added
- sm
- lg
- iconBefore
- iconAfter
- labelHidden
- busy
- success
- defaultDisplay
- buttonContent
- as
The previous Menu Item with the older API is still available as LegacyMenuItem, but will be removed in a future release. Because of styling changes in Blue Web, it might not behave the same.
Removed deprecated components
- Body
- Page
- SidebarToggler
Implementation
See the whole project: https://github.com/bruegmann/vite-template-blue-react
App (App.tsx)
import { Layout, HeaderTitle, MenuItem, SidebarMenu } from "blue-react";
import { House, HouseFill } from "react-bootstrap-icons";
import HomePage from "./pages/HomePage";
const appLogo = "/favicon.svg";
const appTitle = "My App Title";
export default function App() {
return (
<Layout
header={<HeaderTitle logo={appLogo} appTitle={appTitle} />}
side={
<SidebarMenu>
<MenuItem
href="."
icon={<House />}
iconForCurrent={<HouseFill />}
label="Home"
current
/>
</SidebarMenu>
}
page={<HomePage />}
/>
);
}
Page (pages/HomePage.tsx)
export default function HomePage() {
return (
<div className="container">
<h1 className="page-header mt-4 mb-3">
Yay, your new app is ready! What now?
</h1>
<ol>
<li>
Check the dependencies. Since this is a template, which isn't updated
regularly, you should take a look at the <code>package.json</code>.
You can also try to delete <code>package-lock.json</code> and
reinstall with <code>npm i</code> to force install latest minor and
patch versions. If you use an alternative to NPM like Bun or PNPM, you
maybe don't need that file at all. Install with your package manager
instead.
</li>
<li>
Install Inter font family and embed it in <code>index.html</code>.{" "}
<a href="https://bruegmann.github.io/blue/typography/">
More information.
</a>
</li>
<li>
Remove this placeholder content by editing{" "}
<code>./src/pages/HomePage.tsx</code>.
</li>
<li>
Check out the entry point in <code>./src/App.tsx</code>. If you need
your app to have multiple pages, you should use something like{" "}
<a href="https://reactrouter.com/">React Router</a> or{" "}
<a href="https://tanstack.com/router/latest">TanStack Router</a>.
</li>
<li>
Take a look at the stylesheets in <code>./src/styles</code>.
</li>
<li>
<a href="https://bruegmann.github.io/blue/react/">
Check out the docs
</a>{" "}
to find out more about the components, utilities and classes. You'll
also find many examples there.
</li>
</ol>
</div>
);
}
Styling (styles/main.scss)