AdminKitDocs
Components

Components

The React components of AdminKit for React and their props: modal, offcanvas, dropdown, alert, accordion, collapse, tabs, toasts, tooltips and plugins.

AdminKit for React has no Bootstrap JavaScript and no react-bootstrap. The components in src/components/bootstrap/ render Bootstrap's markup and classes, and React state opens and closes them; Bootstrap's Sass gives them their look and transitions. Floating UI positions dropdowns, tooltips and popovers, and modals and offcanvas sheets keep the focus inside while they are open. Everything else, such as buttons, cards, forms and tables, is plain Bootstrap markup in JSX (className instead of class), as in the AdminKit for Bootstrap docs.

Import them from @/components/bootstrap/<file>. Props not listed below, such as className, id and aria-*, go to the component's root element.

ComponentFileEdition
Alertalert.tsxFree and PRO
CloseButtonclose-button.tsxFree and PRO
Dropdown, DropdownToggle, DropdownMenudropdown.tsxFree and PRO
Modalmodal.tsxFree and PRO
Offcanvasoffcanvas.tsxFree and PRO
Accordion, AccordionItem, AccordionHeader, AccordionBodyaccordion.tsxPRO
Collapsecollapse.tsxPRO
TabContainer, TabLink, TabPanetabs.tsxPRO
Toast, useToasttoast.tsxPRO
Tooltip, Popoveroverlay.tsxPRO

The children are the .modal-content. The parent holds the open state:

import { useState } from "react";
import { CloseButton } from "@/components/bootstrap/close-button";
import { Modal } from "@/components/bootstrap/modal";

export function DeleteProject() {
  const [show, setShow] = useState(false);
  const close = () => setShow(false);

  return (
    <>
      <button type="button" className="btn btn-danger" onClick={() => setShow(true)}>
        Delete project
      </button>
      <Modal show={show} onHide={close} aria-labelledby="delete-title">
        <div className="modal-header">
          <h2 className="modal-title h5" id="delete-title">Delete project</h2>
          <CloseButton onClick={close} />
        </div>
        <div className="modal-body">This cannot be undone.</div>
        <div className="modal-footer">
          <button type="button" className="btn btn-secondary" onClick={close}>Cancel</button>
          <button type="button" className="btn btn-danger" onClick={close}>Delete</button>
        </div>
      </Modal>
    </>
  );
}
PropTypeDefaultDescription
showbooleanWhether the modal is open
onHide() => voidCalled on Escape and on a backdrop click; set show to false here
onExited() => voidCalled once the modal has faded out
backdropboolean | "static"true"static": a click outside shakes the dialog instead of closing it
keyboardbooleantrueEscape closes the modal
dialogClassNamestringClasses for .modal-dialog: modal-lg, modal-dialog-centered, ...
contentClassNamestringClasses for .modal-content
contentAsElementType"div""form" for a dialog that is a form
contentPropsobjectOther props for .modal-content, such as onSubmit

Offcanvas

<Offcanvas show={show} onHide={() => setShow(false)} placement="end" aria-labelledby="filters-title">
  <div className="offcanvas-header">
    <h2 className="offcanvas-title h5" id="filters-title">Filters</h2>
    <CloseButton onClick={() => setShow(false)} />
  </div>
  <div className="offcanvas-body">...</div>
</Offcanvas>
PropTypeDefaultDescription
show, onHideAs for Modal
onShown, onHidden() => voidCalled when the transition has finished
placement"start" | "end" | "top" | "bottom""start"The side it slides in from
responsive"sm" | "md" | "lg" | "xl" | "xxl"An offcanvas only below this breakpoint, part of the page from it up (the sidebar uses "lg")
backdropboolean | "static"true
scrollbooleanfalseKeeps the page scrollable while it is open
keyboardbooleantrueEscape closes it
asElementType"div"The element, such as "nav"
<Dropdown>
  <DropdownToggle as="button" type="button" className="btn btn-primary dropdown-toggle">
    Actions
  </DropdownToggle>
  <DropdownMenu className="dropdown-menu-end">
    <a className="dropdown-item" href="#">Edit</a>
    <a className="dropdown-item" href="#">Archive</a>
  </DropdownMenu>
</Dropdown>
PropTypeDefaultDescription
asElementType"div"The wrapper, such as "li" in a navbar
display"dynamic" | "static""dynamic""static" leaves the menu where the CSS puts it, as in a navbar; "dynamic" positions it and flips it to stay in view
strategy"absolute" | "fixed""absolute""fixed" lets the menu escape containers that clip or scroll
autoCloseboolean | "inside" | "outside"trueWhich clicks close the menu; false leaves it to the toggle
drop"down" | "up" | "start" | "end"from the classThe side the menu opens on; read from dropup, dropend or dropstart

DropdownToggle is a link (href="#") unless as="button". DropdownMenu takes as and align ("start" or "end", read from .dropdown-menu-end).

Alert

<Alert variant="success" dismissible>
  Your changes have been saved.
</Alert>

variant is a theme color ("primary" by default). With dismissible the alert gets a close button and fades out when it is closed; onClose is called after that.

CloseButton is Bootstrap's .btn-close with aria-label="Close"; white gives it the light variant for dark backgrounds.

Accordion

This component is only available in AdminKit PRO. Learn more.

<Accordion defaultActiveKey="shipping">
  <AccordionItem eventKey="shipping">
    <AccordionHeader>Shipping</AccordionHeader>
    <AccordionBody>Orders ship within two days.</AccordionBody>
  </AccordionItem>
  <AccordionItem eventKey="returns">
    <AccordionHeader>Returns</AccordionHeader>
    <AccordionBody>Return an order within a month.</AccordionBody>
  </AccordionItem>
</Accordion>

Accordion takes defaultActiveKey (a key or a list of keys) and alwaysOpen, which keeps items open when another opens. AccordionHeader is an h2 unless as says "h3" to "h6".

Collapse

This component is only available in AdminKit PRO. Learn more.

Collapse shows and hides its content with Bootstrap's height transition:

<button
  type="button"
  className="btn btn-light"
  aria-expanded={open}
  aria-controls="details"
  onClick={() => setOpen(!open)}
>
  Details
</button>
<Collapse in={open} id="details">
  <div className="pt-3">...</div>
</Collapse>

Props: in (shown or not), as (the element, "div" by default), onEntered and onExited.

Tabs

This component is only available in AdminKit PRO. Learn more.

Write the nav and the panes as in Bootstrap; TabLink and TabPane connect them by eventKey:

<TabContainer defaultActiveKey="profile">
  <ul className="nav nav-tabs" role="tablist">
    <li className="nav-item" role="presentation">
      <TabLink eventKey="profile" className="nav-link">Profile</TabLink>
    </li>
    <li className="nav-item" role="presentation">
      <TabLink eventKey="security" className="nav-link">Security</TabLink>
    </li>
  </ul>
  <div className="tab-content">
    <TabPane eventKey="profile">...</TabPane>
    <TabPane eventKey="security">...</TabPane>
  </div>
</TabContainer>

TabContainer takes defaultActiveKey, or activeKey and onSelect to control the tab yourself. TabLink takes as and disabled; TabPane fades in unless fade={false}.

Toasts

This component is only available in AdminKit PRO. Learn more.

useToast() returns a function that shows a toast in a corner of the window. ToastProvider in src/app.tsx renders them.

import { useToast } from "@/components/bootstrap/toast";

export function SaveButton() {
  const showToast = useToast();

  return (
    <button
      type="button"
      className="btn btn-primary"
      onClick={() => showToast({ message: "Saved", type: "success" })}
    >
      Save
    </button>
  );
}
OptionTypeDefaultDescription
messageReactNodeThe text
type"default" | "primary" | "secondary" | "success" | "info" | "warning" | "danger""primary"The color
durationnumber5000Milliseconds before it hides; 0 keeps it until it is closed
dismissiblebooleanAdds a close button
position{ x: "left" | "center" | "right"; y: "top" | "bottom" }top rightThe corner

Toast is a single Bootstrap toast, for toasts you place yourself: show, onClose, autohide and delay (5000).

Tooltip and Popover

These components are only available in AdminKit PRO. Learn more.

Both wrap one element and attach the tooltip or popover to it:

<Tooltip content="Archive the project">
  <button type="button" className="btn btn-light">Archive</button>
</Tooltip>

<Popover title="Billing" content="Invoices are sent on the 1st.">
  <button type="button" className="btn btn-light">Billing</button>
</Popover>

A tooltip shows on hover and focus, above the element; a popover opens on click, to its right. placement ("top", "bottom", "left" or "right") and trigger (a list of "hover", "focus" and "click") change that.

Plugins

The plugins have a wrapper component in src/components/plugins/. The large libraries load with the page that uses them and show a Skeleton until they have drawn, so the page keeps its size.

ComponentLibraryEdition
ChartJsChart.jsFree and PRO, see Charts
VectorMapjsVectorMapFree and PRO, see Charts
VanillaCalendarVanilla Calendar ProFree and PRO
ApexChartApexChartsPRO, see Charts
DataTableDataTables (datatables.net-react)PRO
FullCalendarFullCalendar (@fullcalendar/react)PRO
QuillEditorQuillPRO
MaskedInputInputmaskPRO
SelectReact SelectPRO

The scrollbars use simplebar-react directly, and the tasks board of AdminKit PRO uses dnd kit. Examples:

<VanillaCalendar options={{ selectedDates: [today] }} />
<DataTable data={rows} columns={columns} options={{ responsive: true }} className="table table-striped" />
<FullCalendar initialView="dayGridMonth" editable events={events} />
<QuillEditor theme="snow" defaultValue="<p>Hello</p>" onChange={(html) => setBody(html)} />
<MaskedInput className="form-control" mask="(999) 999-9999" />
<Select options={options} isMulti aria-labelledby="states-label" />

DataTable, FullCalendar and Select take the props of the library's React component. VanillaCalendar takes Vanilla Calendar Pro's options; in AdminKit PRO, input turns it into a date picker on an input and time adds the time picker. QuillEditor and MaskedInput are uncontrolled: read their value from onChange or from the form.

UI components

ComponentFileDescription
PageTitleui/page-title.tsxThe page heading (title), with a badge that links to the PRO upgrade page in the free version; in AdminKit PRO, pro adds a "Pro Component" badge
CountUpui/count-up.tsxA number that counts up when it scrolls into view; value is the final text, such as "$21,300"
Skeletonui/skeleton.tsxThe loading placeholder of the plugin components
Footerui/footer.tsxThe page footer, see Sidebar
CardActionsui/card-actions.tsxThe menu in a card header, PRO

Last updated on

On this page