tigran tumasov

Split Button

Buttons 32

About

A button that offers a primary interaction coupled with a dropdown menu offering additional actions.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Split Button to your project and fits it to your theme.

Code

How Split Button is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { ButtonProps } from "@/components/ui/button-1";
import { SplitButton, SplitButtonMenuItem } from "@/components/ui/split-button";

const SIZES: ButtonProps["size"][] = ["small", "medium", "large"];
const TYPES: Extract<ButtonProps["type"], "primary" | "secondary">[] = [
  "primary",
  "secondary"
];

export default function DefaultDemo() {
  return (
    <div className="flex gap-10">
        {TYPES.map((type, i) => {
          return (
            <div className="flex flex-col gap-4" key={type + i}>
              {SIZES.map((size, j) => {
                return (
                  <SplitButton
                    buttonProps={{
                      onClick: () => {
                        alert("Clicked Saved");
                      },
                      size,
                      type
                    }}
                    key={`${type}-${i}-${j}`}
                    menuButtonLabel="Select save method"
                    menuItems={
                      <>
                        <SplitButtonMenuItem
                          description="Save changes"
                          menuItemProps={{
                            onClick: () => {
                              alert("Clicked Save");
                            }
                          }}
                          title="Save"
                        />
                        <SplitButtonMenuItem
                          description="Save changes and create a new production deployment"
                          menuItemProps={{
                            onClick: () => {
                              alert("Clicked Save + Redeploy");
                            }
                          }}
                          title="Save + Redeploy"
                        />
                      </>
                    }
                    menuProps={{ width: 264 }}
                  >
                    Save
                  </SplitButton>
                );
              })}
            </div>
          );
        })}
    </div>
  );
}

Dependencies

More by tigran tumasov

View all
  • Product Hunt Badge

    Product Hunt Badge

    1.8K
  • Book

    Book

    162
  • Calendar

    Calendar

    152
  • Theme Switcher

    Theme Switcher

    135
  • Snippet

    Snippet

    124
  • Table

    Table

    123
  • Toggle

    Toggle

    89
  • Feedback

    Feedback

    88

More in Buttons

View all
  • Button

    Button

    14
  • Button

    Button

    34
  • Texture Button

    Texture Button

    92
  • Button Save

    Button Save

    46
  • Button

    Button

    64
  • Button Group

    Button Group

    3
  • Notification Button

    Notification Button

    103
  • Button

    Button