🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@metadiv-studio/action-buttons

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metadiv-studio/action-buttons

A flexible and responsive React component for creating action button groups with automatic responsive behavior and dropdown fallbacks.

latest
npmnpm
Version
0.1.3
Version published
Maintainers
2
Created
Source

@metadiv-studio/action-buttons

A flexible and responsive React component for creating action button groups with automatic responsive behavior and dropdown fallbacks.

🚀 Installation

npm i @metadiv-studio/action-buttons

đź“– Description

The @metadiv-studio/action-buttons package provides a smart button group component that automatically handles responsive layouts. When screen space is limited, buttons can collapse into a dropdown menu, ensuring your UI remains clean and accessible across all device sizes.

Key Features

  • Responsive Design: Buttons automatically collapse into dropdowns at configurable breakpoints
  • Flexible Content: Support for text-only, icon-only, or mixed content buttons
  • Multiple Variants: Built-in button styles (default, outline, destructive, secondary, ghost)
  • Customizable Sizes: Small, default, large, and icon-only sizes
  • Smart Collapse: Individual button collapse behavior with custom collapse content
  • Accessibility: Built-in tooltips and proper ARIA attributes
  • TypeScript Support: Full TypeScript definitions included

🎯 Usage Examples

Basic Action Buttons

import ActionButtons from '@metadiv-studio/action-buttons';

const basicButtons = [
  {
    variant: "default",
    content: "Primary Action",
    onClick: () => console.log("Primary clicked"),
    tooltip: "This is a primary action button"
  },
  {
    variant: "outline",
    content: "Secondary Action",
    onClick: () => console.log("Secondary clicked"),
    tooltip: "This is a secondary action button"
  },
  {
    variant: "destructive",
    content: "Delete",
    onClick: () => console.log("Delete clicked"),
    tooltip: "This will delete the item"
  }
];

function MyComponent() {
  return (
    <ActionButtons buttons={basicButtons} />
  );
}

Icon-only Buttons

import { Plus, Edit, Trash2 } from 'lucide-react';

const iconButtons = [
  {
    variant: "default",
    content: <Plus className="h-4 w-4" />,
    onClick: () => console.log("Add new item"),
    tooltip: "Add new item"
  },
  {
    variant: "outline",
    content: <Edit className="h-4 w-4" />,
    onClick: () => console.log("Edit item"),
    tooltip: "Edit item"
  },
  {
    variant: "destructive",
    content: <Trash2 className="h-4 w-4" />,
    onClick: () => console.log("Delete item"),
    tooltip: "Delete item"
  }
];

function MyComponent() {
  return (
    <ActionButtons buttons={iconButtons} size="icon" />
  );
}

Mixed Content Buttons

import { Download, Share2 } from 'lucide-react';

const mixedContentButtons = [
  {
    variant: "default",
    content: (
      <div className="flex items-center gap-2">
        <Download className="h-4 w-4" />
        <span>Download</span>
      </div>
    ),
    onClick: () => console.log("Download started"),
    tooltip: "Download the file"
  },
  {
    variant: "outline",
    content: (
      <div className="flex items-center gap-2">
        <Share2 className="h-4 w-4" />
        <span>Share</span>
      </div>
    ),
    onClick: () => console.log("Share dialog opened"),
    tooltip: "Share this item"
  }
];

function MyComponent() {
  return (
    <ActionButtons buttons={mixedContentButtons} />
  );
}

Responsive Buttons with Collapse

import { Eye, Star, Bookmark } from 'lucide-react';

const responsiveButtons = [
  {
    variant: "default",
    content: "View Details",
    collapse: "md", // Collapse at medium screens and below
    collapseContent: <Eye className="h-4 w-4" />, // Icon shown when collapsed
    onClick: () => console.log("View details clicked"),
    tooltip: "View item details"
  },
  {
    variant: "outline",
    content: "Add to Favorites",
    collapse: "lg", // Collapse at large screens and below
    collapseContent: <Star className="h-4 w-4" />,
    onClick: () => console.log("Added to favorites"),
    tooltip: "Add to favorites"
  },
  {
    variant: "secondary",
    content: "Bookmark",
    collapse: "xl", // Collapse at extra large screens and below
    collapseContent: <Bookmark className="h-4 w-4" />,
    onClick: () => console.log("Bookmarked"),
    tooltip: "Bookmark this item"
  }
];

function MyComponent() {
  return (
    <ActionButtons 
      buttons={responsiveButtons} 
      showCollapse="md" 
      collapseAlign="end"
    />
  );
}

Always Collapsed Layout

const userActionButtons = [
  {
    variant: "default",
    content: (
      <div className="flex items-center gap-2">
        <User className="h-4 w-4" />
        <span>Profile</span>
      </div>
    ),
    onClick: () => console.log("Profile page opened"),
    tooltip: "View your profile"
  },
  {
    variant: "outline",
    content: (
      <div className="flex items-center gap-2">
        <Settings className="h-4 w-4" />
        <span>Settings</span>
      </div>
    ),
    onClick: () => console.log("Settings opened"),
    tooltip: "Manage settings"
  }
];

function MyComponent() {
  return (
    <ActionButtons 
      buttons={userActionButtons} 
      showCollapse="always" 
      collapseAlign="center"
    />
  );
}

⚙️ Props

ActionButtons Props

PropTypeDefaultDescription
size"sm" | "lg" | "icon" | "default""default"Size of all buttons
buttonsActionButtonProps[][]Array of button configurations
showCollapse'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'always'undefinedWhen to show collapse dropdown
collapseAlign'start' | 'center' | 'end''start'Dropdown alignment

ActionButtonProps

PropTypeDefaultDescription
variant"default" | "destructive" | "outline" | "secondary" | "ghost"-Button style variant
contentReact.ReactNode-Button content (text, icon, or mixed)
collapse'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'always'-When to collapse this button
collapseContentReact.ReactNode-Content shown when button is collapsed
onClick() => void-Click handler function
tooltipstring-Tooltip text for the button
classNamestring-Additional CSS classes for the button
collapseClassNamestring-Additional CSS classes for collapsed state

🎨 Button Variants

  • default: Primary button style with solid background
  • outline: Button with outline border and transparent background
  • destructive: Button with destructive/danger styling (usually red)
  • secondary: Secondary button style with muted appearance
  • ghost: Minimal button style with transparent background

📱 Responsive Breakpoints

The component uses Tailwind CSS breakpoints for responsive behavior:

  • xs: Extra small screens (default: 0px+)
  • sm: Small screens (640px+)
  • md: Medium screens (768px+)
  • lg: Large screens (1024px+)
  • xl: Extra large screens (1280px+)
  • 2xl: 2X large screens (1536px+)

đź”§ Advanced Configuration

Custom Collapse Behavior

You can control when individual buttons collapse and what content they show:

const advancedButtons = [
  {
    variant: "default",
    content: "Full Text Button",
    collapse: "md", // Collapse at medium screens
    collapseContent: "Text", // Show abbreviated text when collapsed
    onClick: () => console.log("Clicked"),
  },
  {
    variant: "outline",
    content: "Button with Icon",
    collapse: "lg", // Collapse at large screens
    collapseContent: <Icon className="h-4 w-4" />, // Show icon when collapsed
    onClick: () => console.log("Clicked"),
  }
];

Dropdown Alignment

Control the alignment of the collapsed dropdown menu:

<ActionButtons 
  buttons={buttons} 
  showCollapse="md" 
  collapseAlign="end" // Align dropdown to the right
/>

🎯 Use Cases

  • Data Tables: Action buttons for edit, delete, view operations
  • Card Components: Quick actions for content cards
  • Toolbars: Application toolbars with responsive behavior
  • Media Players: Control buttons that adapt to screen size
  • User Interfaces: User action buttons that work on all devices
  • Admin Panels: Administrative actions with responsive layout

🚀 Getting Started

  • Install the package:

    npm i @metadiv-studio/action-buttons
    
  • Import and use:

    import ActionButtons from '@metadiv-studio/action-buttons';
    
    function App() {
      const buttons = [
        { variant: "default", content: "Click me", onClick: () => alert("Hello!") }
      ];
      
      return <ActionButtons buttons={buttons} />;
    }
    
  • Customize as needed with different variants, sizes, and responsive behaviors.

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

đź“„ License

This project is licensed under the MIT License.

FAQs

Package last updated on 20 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts