Components
Dropdown

Dropdown

The Dropdown component creates a customizable dropdown menu that appears when a button is clicked. It can be used to display additional options or content.

Props

NameTypeDefaultDescription
buttonJSX.Element | React.ReactNode | React.ReactElementThe button element or content that triggers the dropdown.
childrenJSX.Element | React.ReactNode | React.ReactElementThe content to be displayed inside the dropdown when it's open.
showbooleanControls whether the dropdown is open or closed.
onClickOutside() => voidA callback function triggered when a click occurs outside the dropdown, only when the dropdown is open.

Try It

import { Dropdown, Button } from '@kloktun/uikit'
import { useState } from 'react';

export default function DropdownExample() {
  const [showDropdown, setShowDropdown] = useState(false);

  return (
    <div className="flex flex-row">
      <Dropdown button={<Button onClick={() => setShowDropdown(!showDropdown)}>Toggle Dropdown</Button>} show={showDropdown} onClickOutside={() => setShowDropdown(false)}>
        Some content inside
      </Dropdown>
    </div>
  );
}