diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsx index f06e04d250c..0e0dce2ff27 100644 --- a/apps/design-system/__registry__/index.tsx +++ b/apps/design-system/__registry__/index.tsx @@ -159,6 +159,17 @@ export const Index: Record = { subcategory: "undefined", chunks: [] }, + "admonition-button-split": { + name: "admonition-button-split", + type: "components:example", + registryDependencies: ["admonition","button","dropdown-menu"], + component: React.lazy(() => import("@/registry/default/example/admonition-button-split")), + source: "", + files: ["registry/default/example/admonition-button-split.tsx"], + category: "undefined", + subcategory: "undefined", + chunks: [] + }, "admonition-description-only": { name: "admonition-description-only", type: "components:example", @@ -577,6 +588,17 @@ export const Index: Record = { subcategory: "undefined", chunks: [] }, + "button-split-dropdown": { + name: "button-split-dropdown", + type: "components:example", + registryDependencies: ["button","dropdown-menu"], + component: React.lazy(() => import("@/registry/default/example/button-split-dropdown")), + source: "", + files: ["registry/default/example/button-split-dropdown.tsx"], + category: "undefined", + subcategory: "undefined", + chunks: [] + }, "calendar-demo": { name: "calendar-demo", type: "components:example", diff --git a/apps/design-system/content/docs/components/button.mdx b/apps/design-system/content/docs/components/button.mdx index 7588d3262c8..43afbfad43f 100644 --- a/apps/design-system/content/docs/components/button.mdx +++ b/apps/design-system/content/docs/components/button.mdx @@ -105,7 +105,7 @@ Used for actions that are not as important as the primary action, or for actions -### Only an Icon +### Only an icon Displaying only an Icon in a button. @@ -115,12 +115,28 @@ Displaying only an Icon in a button. -### As Child +### As child Supports slot behavior with `asChild` prop. +### Split with dropdown + +Pair a button with a chevron `DropdownMenu` trigger when there are variations of the same action, or alternative ways to accomplish the same goal. The default or most likely option should be used on the exposed button. + +When secondary actions are related but distinct—not alternatives to the primary action—display the primary action as a button and place the rest in an overflow menu instead. See [Table multiple actions](./table#multiple-actions). + + + +The shared middle border is the tricky part. Do **not** use `border-l-0` on the chevron button — that drops the divider on hover/focus. Instead: + +- Primary: `rounded-r-none` and `hover:z-10` so its border stacks above the chevron on hover. +- Chevron trigger: `rounded-l-none`, `shrink-0`, `px-[4px] py-[5px]`, and `-ml-px` to overlap the adjacent border by one pixel. +- Chevron trigger only: `aria-label` describing the menu (the icon is decorative). + +Inside [Admonition](../fragments/admonition#split-button-with-dropdown) actions, also use `flex w-full @lg:w-auto` with `flex-1 @lg:flex-none` on the primary when `layout="responsive"`. + ## Accessibility [Keyboard focus](../accessibility#focus-management) is automatically handled: diff --git a/apps/design-system/content/docs/fragments/admonition.mdx b/apps/design-system/content/docs/fragments/admonition.mdx index e872689c3ef..3b4221424d0 100644 --- a/apps/design-system/content/docs/fragments/admonition.mdx +++ b/apps/design-system/content/docs/fragments/admonition.mdx @@ -46,6 +46,18 @@ Style the color of the button based upon the _context_ of the Admonition, not it Only ever use the `primary` (green) button `type` on a `default` Admonition. Even then—given that Admonition is an isolated callout—the `primary` button `type` should rarely be used. +### Split button with dropdown + +When a callout offers alternative ways to accomplish the same goal, use a [split button](../components/button#split-with-dropdown) instead of crowding the callout with multiple buttons. For related but distinct actions, use an overflow menu. See [Table multiple actions](../components/table#multiple-actions). + + + +In responsive Admonitions, wrap the pair in `flex w-full @lg:w-auto`, give the primary `flex-1 @lg:flex-none`, and keep the chevron `shrink-0`. + ## Examples + + + + + + +