Bootstrap 5 components built with React for modern web applications
npx @tessl/cli install tessl/npm-react-bootstrap@2.10.0React Bootstrap is a comprehensive component library that provides Bootstrap 5 components built specifically for React applications. It offers a complete set of responsive UI components including layout, navigation, forms, buttons, overlays, and interactive elements, all implemented with modern React patterns and TypeScript support.
npm install react-bootstrap bootstrapimport { Button, Container, Row, Col, Nav, Navbar } from "react-bootstrap";For CommonJS:
const { Button, Container, Row, Col, Nav, Navbar } = require("react-bootstrap");import React from 'react';
import { Container, Row, Col, Button, Alert } from "react-bootstrap";
function App() {
return (
<Container>
<Row>
<Col>
<Alert variant="success">
Welcome to React Bootstrap!
</Alert>
<Button variant="primary" size="lg">
Get Started
</Button>
</Col>
</Row>
</Container>
);
}React Bootstrap is built around several key architectural patterns:
variant prop system for styling (primary, secondary, success, etc.)Foundation layout components for responsive grid systems and content organization.
interface ContainerProps {
fluid?: boolean | string;
as?: React.ElementType;
}
interface RowProps {
xs?: number | "auto";
sm?: number | "auto";
md?: number | "auto";
lg?: number | "auto";
xl?: number | "auto";
xxl?: number | "auto";
}
interface ColProps {
xs?: number | "auto";
sm?: number | "auto";
md?: number | "auto";
lg?: number | "auto";
xl?: number | "auto";
xxl?: number | "auto";
}Navigation components for menus, breadcrumbs, tabs and navigation bars.
interface NavbarProps {
variant?: "light" | "dark";
expand?: boolean | "sm" | "md" | "lg" | "xl" | "xxl";
fixed?: "top" | "bottom";
sticky?: "top" | "bottom";
}
interface NavProps {
variant?: "tabs" | "pills" | "underline";
fill?: boolean;
justify?: boolean;
}Comprehensive form controls with validation support and accessibility features.
interface FormControlProps {
type?: string;
size?: "sm" | "lg";
isValid?: boolean;
isInvalid?: boolean;
placeholder?: string;
value?: string;
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
}
interface FormCheckProps {
type?: "checkbox" | "radio" | "switch";
id?: string;
label?: React.ReactNode;
checked?: boolean;
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
}Button components and button groups with multiple variants and states.
interface ButtonProps {
variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "link" | "outline-primary" | "outline-secondary" | "outline-success" | "outline-danger" | "outline-warning" | "outline-info" | "outline-light" | "outline-dark";
size?: "sm" | "lg";
disabled?: boolean;
active?: boolean;
type?: "button" | "submit" | "reset";
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
}Modal dialogs, tooltips, popovers and off-canvas components for layered interfaces.
interface ModalProps {
show?: boolean;
onHide?: () => void;
size?: "sm" | "lg" | "xl";
fullscreen?: boolean | "sm-down" | "md-down" | "lg-down" | "xl-down" | "xxl-down";
centered?: boolean;
backdrop?: boolean | "static";
keyboard?: boolean;
}
interface TooltipProps {
id: string;
children: React.ReactNode;
placement?: "auto" | "top" | "bottom" | "left" | "right";
}Dynamic components like carousels, accordions, dropdowns and collapsible content.
interface AccordionProps {
defaultActiveKey?: string | string[];
activeKey?: string | string[];
onSelect?: (eventKey: string | null) => void;
flush?: boolean;
}
interface CarouselProps {
activeIndex?: number;
onSelect?: (selectedIndex: number, e?: any) => void;
controls?: boolean;
indicators?: boolean;
interval?: number | null;
pause?: "hover" | false;
}Content display components for cards, tables, alerts, badges and media content.
interface AlertProps {
variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
dismissible?: boolean;
onClose?: () => void;
}
interface CardProps {
border?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
text?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark" | "white" | "muted";
bg?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
}Provider components and utility elements for theming, SSR support, loading states, and layout utilities.
interface ThemeProviderProps {
prefixes?: Record<string, string>;
dir?: "ltr" | "rtl";
}
interface SSRProviderProps {
children?: React.ReactNode;
}
interface SpinnerProps {
animation?: "border" | "grow";
size?: "sm";
variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
role?: string;
children?: React.ReactNode;
}
interface PlaceholderProps {
animation?: "glow" | "wave";
bg?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
size?: "xs" | "sm" | "lg";
xs?: number;
sm?: number;
md?: number;
lg?: number;
xl?: number;
xxl?: number;
}
interface RatioProps {
aspectRatio?: "1x1" | "4x3" | "16x9" | "21x9" | string;
}Usage Examples:
import { ThemeProvider, SSRProvider, Spinner, Placeholder, Ratio } from "react-bootstrap";
// Theme provider for custom prefixes
<ThemeProvider prefixes={{ btn: 'my-btn' }}>
<App />
</ThemeProvider>
// SSR provider for server-side rendering
<SSRProvider>
<App />
</SSRProvider>
// Loading spinners
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
<Spinner animation="grow" variant="primary" />
// Placeholder content
<Placeholder xs={6} />
<Placeholder className="w-75" />
<Placeholder animation="glow">
<Placeholder xs={12} />
</Placeholder>
// Aspect ratio container
<Ratio aspectRatio="16x9">
<iframe src="https://www.youtube.com/embed/..." title="YouTube video"></iframe>
</Ratio>Custom hook for creating accordion toggle functionality.
/**
* Hook for creating accordion toggle functionality
* @param eventKey - Key to identify accordion item
* @param onClick - Optional click handler
* @returns Click handler and aria props for accordion button
*/
function useAccordionButton(
eventKey: string,
onClick?: (event: React.MouseEvent) => void
): (event: React.MouseEvent) => void;Bootstrap theme integration hooks from ThemeProvider.
/**
* Gets component CSS class prefix from theme
* @param prefix - Component prefix override
* @param defaultPrefix - Default prefix if none set
* @returns Resolved CSS class prefix
*/
function useBootstrapPrefix(prefix?: string, defaultPrefix?: string): string;
/**
* Gets responsive breakpoints array from theme
* @returns Array of breakpoint names
*/
function useBootstrapBreakpoints(): string[];
/**
* Gets minimum breakpoint name from theme
* @returns Minimum breakpoint name
*/
function useBootstrapMinBreakpoint(): string;
/**
* Checks if text direction is right-to-left
* @returns True if RTL direction
*/
function useIsRTL(): boolean;type Variant = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
type Size = "sm" | "lg";
type Placement = "auto" | "top" | "bottom" | "left" | "right";
interface BsPrefixProps {
bsPrefix?: string;
}
interface AsProps {
as?: React.ElementType;
}
interface ResponsiveUtilityValue<T> {
xs?: T;
sm?: T;
md?: T;
lg?: T;
xl?: T;
xxl?: T;
}
interface BootstrapBreakpoint {
span?: number | "auto";
offset?: number;
order?: number;
}