SplitButton
A button with a caret dropdown on its right edge, for the classic "Export CSV" ▾ pattern.
Props
SplitButton combines a primary Button with a caret dropdown. The main onClick fires the primary action; menu provides the alternate options via an internal DropdownMenu.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Main button label. |
menu | ReactNode | — | MenuItem components for the dropdown. |
onClick | () => void | — | Primary (left half) action. |
variant | ButtonVariant | "default" | Applies to both halves. |
size | ButtonSize | "md" | "sm" | "md" |
leftIcon | ReactNode | — | Icon before the main label. |
disabled | boolean | — | Disables both halves. |
placement | Placement | "bottom-end" | Dropdown placement relative to the trigger. |
Examples
import { SplitButton, MenuItem } from "@solarius/onset";
import { IconDownload } from "@tabler/icons-react";
<SplitButton
onClick={() => exportCSV()}
leftIcon={<IconDownload size={14} />}
menu={
<>
<MenuItem onClick={() => exportJSON()}>Export JSON</MenuItem>
<MenuItem onClick={() => exportPDF()}>Export PDF</MenuItem>
</>
}
>
Export CSV
</SplitButton>;