diff --git a/apps/web/content/docs/components/dropdown.mdx b/apps/web/content/docs/components/dropdown.mdx index bd3199d88..645cb6fc9 100644 --- a/apps/web/content/docs/components/dropdown.mdx +++ b/apps/web/content/docs/components/dropdown.mdx @@ -3,9 +3,9 @@ title: React Dropdown - Flowbite description: Use the dropdown component to trigger a list of menu items when clicking on an element such as a button or link based on multiple styles, sizes, and placements with React --- -The dropdown component is a UI component built with React that allows you to show a list of items when clicking on a trigger element (ie. a button) that you can use to build dropdown menus, lists, and more. +The dropdown component is a UI element built with React that displays a list of items when a trigger element (e.g., a button) is clicked. You can use it to build dropdown menus, lists, and more. -The default styles are built with the utility classes from Tailwind CSS and you can use the custom props from React to customize the behaviour and positioning of the dropdowns. +The default styles are built using utility classes from Tailwind CSS. You can customize the behavior and positioning of the dropdowns using custom props from React. To start using the component make sure that you have imported it from Flowbite React: @@ -15,7 +15,7 @@ import { Dropdown } from "flowbite-react"; ## Default dropdown -Use this example to create a simple dropdown with a list of menu items by adding child `` components inside of the main `` component. +Use this example to create a simple dropdown with a list of menu items by adding child `` components inside the main `` component. @@ -29,6 +29,8 @@ Use the `` component to add a divider between the dropdown ite Use the `` component to add a header to the dropdown. You can use this to add a user profile image and name, for example. +For more complex headers that include an `` or `` control, set `enableTypeAhead` to `false` on the `` to prevent keystrokes from being interpreted as item searches. + ## Dropdown items with icon @@ -63,7 +65,7 @@ Add a custom `onClick` event handler to the `` component to handl ## Custom trigger -To customize the trigger element you can use `renderTrigger` property. +To customize the trigger element, you can use the `renderTrigger` property. diff --git a/packages/ui/src/components/Dropdown/Dropdown.stories.tsx b/packages/ui/src/components/Dropdown/Dropdown.stories.tsx index 023558dcf..fa8f38ec6 100644 --- a/packages/ui/src/components/Dropdown/Dropdown.stories.tsx +++ b/packages/ui/src/components/Dropdown/Dropdown.stories.tsx @@ -60,6 +60,23 @@ WithHeader.args = { ), }; +export const WithUsableInputHeader = Template.bind({}); +WithUsableInputHeader.storyName = "With usable input header"; +WithUsableInputHeader.args = { + enableTypeAhead: false, + children: ( + <> + + + + Dashboard + Settings + Earnings + Sign out + + ), +}; + export const Inline = Template.bind({}); Inline.args = { inline: true, diff --git a/packages/ui/src/components/Dropdown/Dropdown.tsx b/packages/ui/src/components/Dropdown/Dropdown.tsx index 7a1ada791..58d476864 100644 --- a/packages/ui/src/components/Dropdown/Dropdown.tsx +++ b/packages/ui/src/components/Dropdown/Dropdown.tsx @@ -47,6 +47,7 @@ export interface DropdownProps extends Pick; + enableTypeAhead?: boolean; renderTrigger?: (theme: FlowbiteDropdownTheme) => ReactElement; "data-testid"?: string; } @@ -108,6 +109,7 @@ const DropdownComponent: FC = ({ className, dismissOnClick = true, theme: customTheme = {}, + enableTypeAhead = true, renderTrigger, ...props }) => { @@ -164,6 +166,7 @@ const DropdownComponent: FC = ({ activeIndex, selectedIndex, onMatch: handleTypeaheadMatch, + enabled: enableTypeAhead, }); const { getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({