1.0.1 • Published 9 months ago

react-devbar v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

📏 react-devbar

A customizable floating toolbar for React applications. Build and integrate your own dev tools with a draggable interface inspired by the Vercel toolbar. Perfect for adding debugging panels, theme controls, and other development utilities for your app. Check out the Storybook for a live demo.

Screenshot of react-devbar

✨ Features

  • ✅ Fully customizable, with custom icons, styles, and components.
  • ✅ Toggle it with a hotkey.
  • ✅ Drag it anywhere on the screen.
  • ✅ Use default styles or style it yourself. Seamlessly integrates with Tailwind and supports dark-mode.

📡 Install

npm install react-devbar

yarn add react-devbar

pnpm add react-devbar

👋 Hello there! Follow me @linesofcode or visit linesofcode.dev for more cool projects like this one.

🚀 Getting started

import { DevBar } from "react-devbar";
import { Bug, Palette, Settings } from "lucide-react";
// if you're not using Tailwind, you can import default styles
import "react-devbar/styles.css";

const tools = [
	{
		icon: Settings,
	},
	{
		icon: Palette,
	},
	{
		icon: Bug,
	},
];


// somewhere in your app render:
<DevBar tools={tools} />

Available props

DevBarTool

Each tool in the tools array can have the following properties:

PropertyTypeRequiredDescription
namestringNoThe name of the tool (used for tooltips)
iconReact.ElementTypeYesThe icon component to display
ComponentReact.ComponentTypeNoThe component to render when the tool is selected

DevBarProps

PropertyTypeDefaultDescription
toolsTool[]-Array of tools to display in the toolbar
orientation"horizontal" | "vertical""horizontal"Orientation of the toolbar
defaultPositionPosition | { x: number; y: number }"bottom-right"Initial position of the toolbar
defaultOpenbooleanfalseWhether the toolbar is initially open
hotkeystring-Keyboard shortcut to toggle the toolbar
hotKeyOptionsOptions-Options for the hotkey behavior
CommandIconReact.ElementType-Custom command icon component
GripIconReact.ElementType-Custom grip icon component
CloseIconReact.ElementType-Custom close icon component
containerClassNamestring-Class name for the main container
toolbarClassNamestring-Class name for the toolbar
toolbarContentClassNamestring-Class name for the toolbar content
moveButtonClassNamestring-Class name for the move button
toolsContainerClassNamestring-Class name for the tools container
toolButtonClassNamestring-Class name for individual tool buttons
controlsContainerClassNamestring-Class name for the controls container
closeButtonClassNamestring-Class name for the close button
openButtonClassNamestring-Class name for the open button
ButtonComponenttypeof Button-Custom button component
TooltipComponenttypeof Tooltip-Custom tooltip component
TooltipTriggerComponenttypeof TooltipTrigger-Custom tooltip trigger component
TooltipContentComponenttypeof TooltipContent-Custom tooltip content component
TooltipProviderComponenttypeof TooltipProvider-Custom tooltip provider component
moveButtonLabelstring-Accessibility label for the move button
closeToolbarLabelstring-Accessibility label for the close button
openToolbarLabelstring-Accessibility label for the open button

DevBarPosition Types

The defaultPosition prop accepts the following position values:

  • "top-left"
  • "top-center"
  • "top-right"
  • "bottom-left"
  • "bottom-center"
  • "bottom-right"
  • "center-left"
  • "center-right"
  • "center"

Or an object with x and y coordinates for precise positioning.