Navbar

Top navigation, typically used as primary navigation in websites or stacked application layouts.

Props#

The Navbar component and all sub components accept all Box properties.

PropTypeDefaultDescription
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | ReactNode[]
colorScheme"whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram" | "primary" | "secondary" | "indigo"The visual color appearance of the component
disableScrollHandlerbooleanfalseWhether the navbar parent scroll event should be listened to or not.
heightstring | number"3.5rem" (56px)The height of the navbar.
motionPropsHTMLMotionProps<"nav">The props to modify the framer motion animation. Use the variants API to create your own animation. This motion is only available if the shouldHideOnScroll prop is set to true.
onAnimationStart(definition: AnimationDefinition) => voidCallback when animation defined in animate begins. The provided callback will be called with the triggering animation definition. If this is a variant, it'll be the variant name, and if a target object then it'll be the target object. This way, it's possible to figure out which animation has started. ```jsx function onStart() { console.log("Animation started") } <motion.div animate={{ x: 100 }} onAnimationStart={onStart} /> ```
onDrag( event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, ) => voidCallback function that fires when the component is dragged. ```jsx <motion.div drag onDrag={ (event, info) => console.log(info.point.x, info.point.y) } /> ```
onDragEnd( event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, ) => voidCallback function that fires when dragging ends. ```jsx <motion.div drag onDragEnd={ (event, info) => console.log(info.point.x, info.point.y) } /> ```
onDragStart( event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo, ) => voidCallback function that fires when dragging starts. ```jsx <motion.div drag onDragStart={ (event, info) => console.log(info.point.x, info.point.y) } /> ```
onScrollPositionChange(scrollPosition: number) => voidThe scroll event handler for the navbar. The event fires when the navbar parent element is scrolled. it only works if disableScrollHandler is set to false or shouldHideOnScroll is set to true.
parentRefRefObject<HTMLElement>`window`The parent element where the navbar is placed within. This is used to determine the scroll position and whether the navbar should be hidden or not.
shouldHideOnScrollbooleanfalseWhether the navbar should hide on scroll or not.
sizestringThe size of the Navbar
styleCSSPropertiesStyle props to be applied to the navbar container.
variantstringThe variant of the Navbar
PropTypeDefaultDescription
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | ReactNode[]
PropTypeDefaultDescription
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | ReactNode[]Typically the NavbarItem component
spacingResponsiveValue<number | "px" | "initial" | "inherit" | (string & {}) | "auto" | "-moz-initial" | "revert" | "revert-layer" | "unset" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | ... 54 more ... | "-3.5">Spacing between each navbar item
PropTypeDefaultDescription
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>
isActivebooleanfalseWhether the item is active or not.

Was this helpful?