import React from 'react';
import * as Dropdown from "~/ui/components/Dropdown";
export default function App() {
return (
<div style={styles.container}>
<p>Dropdown Example</p>
<div className="flex">
<Dropdown.Dropdown
trigger={
<div className="relative">
<Button
size="xs"
theme="secondary"
leftSlot={<SettingsIcon className="icon-sm text-icon-secondary pointer-events-none" />}
rightSlot={<ChevronDownIcon className="icon-xs text-icon-secondary pointer-events-none" />}
>
<FOOTNOTE>
Settings
</FOOTNOTE>
</Button>
</div>
}
>
<Dropdown.Item
preventAutoClose
label="Use dark theme"
onSelect={() => alert('selected dark theme')}
/>
<Dropdown.Item
preventAutoClose
label="Wrap long lines"
onSelect={() => alert('selected line wrap')}
/>
</Dropdown.Dropdown>
</div>
);
}
Prop Name | Type | Default | Description |
---|---|---|---|
trigger | ReactNode | - | The element that triggers the dropdown menu. |
children | ReactNode | - | The content of the dropdown menu. |
className | string | undefined | Additional classnames to be applied to the dropdown menu container. |
sideOffset | number | 0 | The offset in pixels from the triggers side. |
collisionPadding | { left: number; right: number; } | { left: 16, right: 16 } | Padding applied to the dropdown menu to prevent it from colliding with other elements. |
side | string | "bottom" | The side of the trigger where the dropdown menu should appear. Options: "top" , "bottom" , "right" , "left" . |
...rest | DropdownMenu.DropdownMenuContentProps | - | Other props from the @radix-ui/react-dropdown-menu library for customizing the dropdown menu behavior. |
Prop Name | Type | Default | Description |
---|---|---|---|
label | string | - | The label text of the dropdown item. |
description | React.ReactNode | undefined | Additional description content for the dropdown item. |
href | string | undefined | If provided, renders the dropdown item as a link with the specified href. |
Icon | ReactElement | undefined | An optional icon component to be rendered alongside the dropdown item. |
rightSlot | ReactNode | undefined | Additional content to be rendered on the right side of the dropdown item. |
disabled | boolean | false | If true, disables the dropdown item. |
destructive | boolean | false | If true, applies a destructive styling to the dropdown item. |
openInNewTab | boolean | false | If true and href is provided, opens the link in a new tab when clicked. |
preventAutoClose | boolean | false | If true, prevents the dropdown menu from automatically closing after clicking on the dropdown item. |
...rest | Omit<DropdownMenu.DropdownMenuItemProps, "onClick"> | - | Other props from @radix-ui/react-dropdown-menu for customizing the dropdown item behavior. |