# Dropdown

The `Dropdown` component displays a menu to the user, such as a set of actions or functions, triggered by a button.

### Preview

<div align="left"><figure><img src="/files/nZCHsxoWi0zPgaofUswm" alt="Gravity dropdown component" width="186"><figcaption></figcaption></figure></div>

### Usage

```javascript
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from 'components/lib';

function MyComponent({ ...props }){
  return (
    <DropdownMenu>
      <DropdownMenuTrigger >Open Menu</DropdownMenuTrigger>
      <DropdownMenuContent>
        <DropdownMenuItem>Item 1</DropdownMenuItem>
        <DropdownMenuItem>Item 2</DropdownMenuItem>
        <DropdownMenuItem>Item 3</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  );
}
```

### Props

| Prop      | Description          | Required | Value            |
| --------- | -------------------- | -------- | ---------------- |
| children  | children to render   | required | component(s)     |
| className | custom class         | optional | SCSS or Tailwind |
| inset     | toggle triggle style | optional | boolean          |

### Example

```javascript
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from 'components/lib';

export function User(){

  return (
    <div>
      <DropdownMenu>

        <DropdownMenuTrigger asChild>
          Trigger
        </DropdownMenuTrigger>

        <DropdownMenuContent align='end'>
        
          <DropdownMenuItem>
            <Button 
              variant='naked' 
              icon='user' 
              text='Edit Account' 
              url='/account/profile'
            />
          </DropdownMenuItem>

          <DropdownMenuItem>
            <Button 
              variant='naked' 
              icon='help-circle' 
              text='Help' 
              url='/help'
            />
          </DropdownMenuItem>

        </DropdownMenuContent>
      </DropdownMenu> 
    </div>
  )
}
```

### Notes

* The `Dropdown` component uses `DropdownMenuPrimitive` components from `@radix-ui/react-dropdown-menu`.
* The `children` prop is required and should include the elements to be displayed in the dropdown.
* The `className` prop allows for custom styling.
* The `inset` prop toggles the trigger style.
* For more details, refer to the [Shadcn Dropdown Menu documentation](https://ui.shadcn.com/docs/components/dropdown-menu).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.usegravity.app/gravity-web/components/dropdown.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
