mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem The Button guidance explains split buttons but doesn't show how to group a visible action with other actions for the same item or section. ## Solution Document when to use each pattern: - **Split button:** the main button runs the most common variation of an action. The attached chevron opens alternatives, such as other export formats. - **Dropdown button:** the whole button opens a menu, such as a time-range picker. - **Button with more actions:** keep the main action visible and use a separate ellipsis menu for distinct actions. The examples show both a primary “Add pipeline” button and a default “Stop” button. Align the Admonition split-button example with the same guidance. ## Review instructions 1. Open the [Button guidance preview](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#split-with-dropdown) and compare the attached export chevron with the single time-range dropdown. 2. Open each ellipsis in [Button with more actions](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#button-with-more-actions). Check that the “Add pipeline” menu groups usage and settings separately from “Disable Pipelines”, and that the “Stop” menu separates restart from edit and delete.
38 lines
1000 B
TypeScript
38 lines
1000 B
TypeScript
'use client'
|
|
|
|
import { ChevronDown } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuRadioGroup,
|
|
DropdownMenuRadioItem,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
|
|
const ranges = ['Last hour', 'Last 24 hours', 'Last 7 days']
|
|
|
|
export default function ButtonDropdownDemo() {
|
|
const [range, setRange] = useState('Last 24 hours')
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="button" iconRight={<ChevronDown />} aria-label={`Time range: ${range}`}>
|
|
{range}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuRadioGroup value={range} onValueChange={setRange}>
|
|
{ranges.map((option) => (
|
|
<DropdownMenuRadioItem key={option} value={option}>
|
|
{option}
|
|
</DropdownMenuRadioItem>
|
|
))}
|
|
</DropdownMenuRadioGroup>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|