Skip to Content
DocumentationSidebar

Sidebar

A composable, themeable and customizable sidebar component.

Usage

First of all, create a Sidebar component in your application.

Provider

Then, add a SidebarProvider, SidebarTrigger and AppSidebar at the root of your application.

app/layout.tsx
import { SidebarProvider, SidebarTrigger } from "@medway-ui/core" import { AppSidebar } from "@/components/AppSidebar" export default function Layout({ children }: { children: React.ReactNode }) { return ( <SidebarProvider> <AppSidebar /> <main> <SidebarTrigger showTooltip enableHover tooltipContent={{ open: "Esconder sidebar", closed: "Mostrar sidebar" }} /> {children} </main> </SidebarProvider> ) }

Examples

The Sidebar component now supports enhanced tooltip functionality and hover effects:

  • SidebarTrigger: Use enableHover to show different icons on hover (ChevronLeftMd when open, ChevronRightMd when closed)
  • SidebarMenuButton: Use tooltip prop to show tooltips when the sidebar is collapsed
  • Custom tooltip content: Use tooltipContent prop on SidebarTrigger to customize tooltip messages

You can enable the hover effect on the SidebarTrigger by setting enableHover to true, which will show ChevronLeftMd when the sidebar is open and ChevronRightMd when closed on hover. You can also customize the tooltip content by setting tooltipContent with custom messages for open and closed states.

API

ComponentDescriptionUsage
SidebarProviderRoot component that manages the sidebar stateMust wrap the entire application where the Sidebar will be used
SidebarMain component that renders the sidebarMain container for the entire sidebar structure
SidebarContentContainer for the sidebar contentManages layout and scrolling of main content
SidebarHeaderTop section of the sidebarIdeal for logos, titles or main controls
SidebarFooterBottom section of the sidebarUseful for status information, user controls or secondary actions
SidebarGroupGroups related itemsContainer for groups of items with common title
SidebarGroupLabelGroup titleDefines the header of a group of items
SidebarGroupContentContainer for group contentWraps items within a group
SidebarGroupActionAction button for a groupContextual actions related to the group
SidebarMenuList of menu itemsContainer for navigation items
SidebarMenuItemIndividual menu itemContainer for a navigation item
SidebarMenuButtonClickable menu buttonInteractive element for navigation
SidebarMenuItemTitleItem title and iconDisplays the visual content of the menu item
SidebarMenuItemCollapseMenu item collapseDisplays the menu item with a collapse icon
SidebarMenuActionItem action buttonContextual actions for a specific item
SidebarMenuBadgeBadge or counterDisplays additional information about the item
SidebarMenuSubSubmenu containerGroups nested submenu items
SidebarMenuSubItemSubmenu itemContainer for a submenu item
SidebarMenuSubButtonSubmenu buttonInteractive element for submenu navigation
SidebarTriggerToggle buttonControls sidebar visibility
SidebarRailSeparator elementVisually separates sidebar from content
SidebarSeparatorDivider lineSeparates sections within the sidebar
SidebarInputInput fieldStyled text field for the sidebar
SidebarInsetContent containerAdjusts main content to the sidebar
SidebarMenuSkeletonLoading componentDisplays loading state for menu items
PropertyTypePossible ValuesDefaultDescription
side”left” | “right""left”, “right""left”Defines which side the sidebar will be displayed on.
variant”sidebar” | “floating” | “inset""sidebar”, “floating”, “inset""sidebar”Defines the visual style of the sidebar.
collapsible”offcanvas” | “icon” | “none""offcanvas”, “icon”, “none""offcanvas”Defines the sidebar collapse behavior.
defaultOpenbooleantrue, falsetrueDefines if the sidebar should be open by default.
openbooleantrue, false-Controls the sidebar open state (controlled).
onOpenChange(open: boolean) => void--Callback called when the open state changes.
containerClassNamestringAny CSS class string-Additional CSS classes for the sidebar container element.

SidebarMenuButton

PropertyTypePossible ValuesDefaultDescription
variant”default” | “outline""default”, “outline""default”Defines the visual style of the menu button.
size”md” | “sm” | “lg""md”, “sm”, “lg""md”Defines the size of the menu button.
isActivebooleantrue, falsefalseDefines if the menu button is active.
tooltipstring | TooltipContentProps--Defines the text or settings for the button tooltip. When provided as string, it will be converted to TooltipContentProps with the string as children.
asChildbooleantrue, falsefalseAllows rendering the button as a custom child element.

SidebarMenuSubButton

PropertyTypePossible ValuesDefaultDescription
size”sm” | “md""sm”, “md""md”Defines the size of the submenu button.
isActivebooleantrue, falsefalseDefines if the submenu button is active. When active, applies active styling with semibold font weight and secondary foreground color.
asChildbooleantrue, falsefalseAllows rendering the button as a custom child element.

SidebarTrigger

PropertyTypePossible ValuesDefaultDescription
iconReact.ReactNodeAny React node<HamburgerMd />Icon displayed when the sidebar is closed.
classNamestringAny CSS class string-Additional CSS classes for styling customization.
onClick(event: React.MouseEvent) => void--Callback function called when the trigger is clicked.
showTooltipbooleantrue, falsefalseDefines whether to show a tooltip when the trigger is hovered.
tooltipContent{ open?: string; closed?: string }-{ open: "Esconder", closed: "Mostrar" }Custom tooltip content for open and closed states.
sizeIconstringAny CSS class string”size-5”Defines the size of the icon.
enableHoverbooleantrue, falsefalseDefines whether the hover effect (icon change) is enabled. When enabled, shows ChevronLeftMd when open and ChevronRightMd when closed on hover.
Last updated on