HomePaymentsNo-codeDevelopersContribute
Safepay Home PageLive DashboardTest Dashboard

Dropdown


Usage

Basic Dropdown usage
  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>
    );
  }

Example

Props

Dropdown

Prop NameTypeDefaultDescription
triggerReactNode-The element that triggers the dropdown menu.
childrenReactNode-The content of the dropdown menu.
classNamestringundefinedAdditional classnames to be applied to the dropdown menu container.
sideOffsetnumber0The 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.
sidestring"bottom"The side of the trigger where the dropdown menu should appear. Options: "top", "bottom", "right", "left".
...restDropdownMenu.DropdownMenuContentProps-Other props from the @radix-ui/react-dropdown-menu library for customizing the dropdown menu behavior.

Dropdown.Item

Prop NameTypeDefaultDescription
labelstring-The label text of the dropdown item.
descriptionReact.ReactNodeundefinedAdditional description content for the dropdown item.
hrefstringundefinedIf provided, renders the dropdown item as a link with the specified href.
IconReactElementundefinedAn optional icon component to be rendered alongside the dropdown item.
rightSlotReactNodeundefinedAdditional content to be rendered on the right side of the dropdown item.
disabledbooleanfalseIf true, disables the dropdown item.
destructivebooleanfalseIf true, applies a destructive styling to the dropdown item.
openInNewTabbooleanfalseIf true and href is provided, opens the link in a new tab when clicked.
preventAutoClosebooleanfalseIf true, prevents the dropdown menu from automatically closing after clicking on the dropdown item.
...restOmit<DropdownMenu.DropdownMenuItemProps, "onClick">-Other props from @radix-ui/react-dropdown-menu for customizing the dropdown item behavior.