Overlays & Actions
Dropdown
Context menu from a trigger — dismiss layer, positioning, asChild trigger, submenus, shortcuts, checkbox and radio items (shadcn Dropdown Menu pattern). Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/dropdown.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Dropdown primitives from @/components/kamod-ui/dropdown.
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Use DropdownTrigger to toggle, DropdownContent for the panel (side, align, sideOffset). Optional DropdownSub / DropdownSubTrigger / DropdownSubContent for nested menus; DropdownSubContent supports side="inline-end" (default) or side="inline-start" to open toward the inline end or start (use inline-start when the trigger is near the viewport edge to avoid horizontal page scroll). Checkbox and radio items do not use DropdownItem’s auto-close behavior where noted.
import { Dropdown } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Dropdown in Different Contexts, from the starting pattern to the compositions below. Begin with Basic, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Basic
Keep the Menu Focused on Related Commands. Pair the default dropdown trigger with a short menu of related operations. Each menu item should represent an action available from that trigger, giving the reader a predictable set of choices when the popup opens.
Essential actions should have a discoverable trigger, and navigation items should retain link semantics where appropriate; a menu's visual grouping does not replace the behavior of its individual entries.
import { Dropdown, DropdownContent, DropdownItem, DropdownTrigger } from "@kamod-ch/ui";
export const Example = () => (
<Dropdown>
<DropdownTrigger>Open menu</DropdownTrigger>
<DropdownContent>
<DropdownItem>Profile</DropdownItem>
<DropdownItem>Settings</DropdownItem>
</DropdownContent>
</Dropdown>
);Trigger asChild
Make the Existing Control the Actual Trigger. Use asChild to make a Button or another compatible element the dropdown trigger. The child keeps its chosen presentation while receiving the behavior needed to open and control the associated menu.
Preserve a meaningful accessible name, forwarded attributes and focus styling, and choose a label that explains the menu rather than the visual symbol used to open it.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthGroups, Shortcuts, Icons
Add Structure Only Where It Helps Scanning. Organize a longer dropdown with labels, separators and recognizable icons, reserving trailing space for shortcut hints. These elements explain the hierarchy of the actions without changing the operation attached to each item.
Keep these cues secondary to the command text, and do not show a shortcut unless your application actually registers and maintains that behavior.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthCheckbox Items
Use Checkmarks for Independent Settings. Use checkbox menu items for independent settings that can be changed without closing the root menu. Their checked values should describe the same state used by the rest of the interface after the menu is dismissed.
Bind each checked value to the actual application state and make the effect of each label clear; a checked menu item should reflect a setting, not merely the last command clicked.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthRadio Group
Represent One Current Choice. Use DropdownRadioItem within a radio group for one choice among alternatives. Selecting an item updates the chosen value and closes the menu, so the trigger or surrounding interface should make the result visible.
Reopen the menu after changing the setting elsewhere in the application to verify that the marked option follows parent state. Use stable option values, keeping translated labels separate from the data used to apply the preference.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthPositioning
Position for the Available Space. Set side, align and sideOffset on DropdownContent to position the menu relative to its trigger. These choices tune the available space around the popup without changing the labels or behavior of its actions.
Test triggers near each edge and within scrolling containers. When a parent clips overflow, pass portal so the menu renders in document.body instead of being cut off. Avoid large offsets that make the menu feel disconnected from its source.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Dropdown using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Dropdown
DropdownProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
defaultOpen | Configure
|
DropdownCheckboxItem
DropdownCheckboxItemProps
| Prop / type | Description |
|---|---|
checked | Configure
|
children | Configure
|
class | Configure
|
defaultChecked | Configure
|
disabled | Configure
|
onCheckedChange | Configure
|
onClick | Configure
|
DropdownContent
DropdownContentProps
| Prop / type | Description |
|---|---|
align | Configure
|
children | Configure
|
class | Configure
|
forceMount | Configure
|
onKeyDown | Configure
|
portal | Render in `document.body`, align to the trigger, and keep the menu in the viewport. Default `false` (inline next to the trigger). Set `portal` when a parent uses `overflow: hidden` or scroll clipping would cut off the menu.
|
side | Configure
|
sideOffset | Configure
|
style | Configure
|
DropdownGroup
DropdownGroupProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
DropdownItem
DropdownItemProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
href | Configure
|
inset | Configure
|
onClick | Configure
|
variant | Configure
|
DropdownLabel
DropdownLabelProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
inset | Configure
|
DropdownPortal
DropdownPortalProps
| Prop / type | Description |
|---|---|
children | Configure
|
DropdownRadioGroup
DropdownRadioGroupProps
| Prop / type | Description |
|---|---|
children | Configure
|
defaultValue | Configure
|
onValueChange | Configure
|
value | Configure
|
DropdownRadioItem
DropdownRadioItemProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
disabled | Configure
|
onClick | Configure
|
value | Configure
|
DropdownSeparator
DropdownSeparatorProps
| Prop / type | Description |
|---|---|
class | Configure
|
DropdownShortcut
DropdownShortcutProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
DropdownSub
DropdownSubProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
DropdownSubContent
DropdownSubContentProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
onKeyDown | Configure
|
onPointerEnter | Configure
|
side | `inline-end` (default): opens toward inline end (right in LTR). `inline-start`: toward inline start (left in LTR) — use near the viewport edge to avoid horizontal page scroll.
|
DropdownSubTrigger
DropdownSubTriggerProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
onClick | Configure
|
onKeyDown | Configure
|
onPointerEnter | Configure
|
side | Must match `DropdownSubContent` `side` for arrow-key open direction.
|
DropdownTrigger
DropdownTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
class | Configure
|
onClick | Configure
|
onKeyDown | Configure
|
ref | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
DropdownContextValue
9 declared fieldsDropdownContextValueDropdown.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownContextValue before adapting it.open, setOpen, triggerId, contentId, rootRef, triggerRef, contentRef, triggerClickHandledRef, clickIntentRefDropdown Props
2 declared fieldsDropdownPropsDropdown.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownProps before adapting it.DropdownCheckboxItem Props
4 declared fieldsDropdownCheckboxItemPropsDropdownCheckboxItem.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownCheckboxItemProps before adapting it.DropdownContent Props
6 declared fieldsDropdownContentPropsDropdownContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownContentProps before adapting it.DropdownGroup Props
1 declared fieldDropdownGroupPropsDropdownGroup.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownGroupProps before adapting it.DropdownItemShared Props
1 declared fieldDropdownItemSharedPropsDropdownItem.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownItemSharedProps before adapting it.DropdownItem Props
DeclarationDropdownItemPropsDropdownItem.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownItemProps before adapting it.DropdownLabel Props
2 declared fieldsDropdownLabelPropsDropdownLabel.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownLabelProps before adapting it.DropdownPortal Props
1 declared fieldDropdownPortalPropsDropdownPortalProps before adapting it.DropdownRadioGroup Props
4 declared fieldsDropdownRadioGroupPropsDropdownRadioGroup.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownRadioGroupProps before adapting it.DropdownRadioItem Props
2 declared fieldsDropdownRadioItemPropsDropdownRadioItem.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownRadioItemProps before adapting it.valueDropdownSeparator Props
DeclarationDropdownSeparatorPropsDropdownSeparator.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownSeparatorProps before adapting it.DropdownShortcut Props
1 declared fieldDropdownShortcutPropsDropdownShortcut.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownShortcutProps before adapting it.DropdownSub Props
1 declared fieldDropdownSubPropsDropdownSub.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownSubProps before adapting it.DropdownSubContent Props
2 declared fieldsDropdownSubContentPropsDropdownSubContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownSubContentProps before adapting it.DropdownSubTrigger Props
2 declared fieldsDropdownSubTriggerPropsDropdownSubTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownSubTriggerProps before adapting it.DropdownTrigger Props
2 declared fieldsDropdownTriggerPropsDropdownTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownTriggerProps before adapting it.DropdownRadioContextValue
2 declared fieldsDropdownRadioContextValuedropdown-radio-context.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownRadioContextValue before adapting it.value, setValueDropdownSubContextValue
4 declared fieldsDropdownSubContextValuedropdown-sub-context.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropdownSubContextValue before adapting it.open, setOpen, markFocusOnOpen, consumeFocusOnOpenAccessibility
Build the Complete Interaction, Including the Parts Outside Dropdown. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
DropdownTrigger exposes aria-haspopup="menu", expanded state and the controlled content ID. Content and items use menu roles, including checked states for checkbox and radio items. Escape closes the menu and returns to its trigger.
Labels and Relationships
Name the trigger by its action scope, such as Invoice actions, and use specific item text. Keep shortcuts supplementary: the item name must describe the action even when the keyboard hint is omitted.
Keyboard and Focus
Exercise the shipped menu keyboard behavior with enabled, disabled and nested items. Reuse its item components and focus handling rather than installing a second document-level listener. Verify the complete path through a submenu and back to its parent.
States and Integration Details
Menu roles promise more than a visually positioned list. Test arrow-key behavior and screen-reader output in the exact composition rather than assuming parity with another library. For ordinary site destinations, consider navigation links instead of application-menu semantics.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Open, choose an action and dismiss without a pointer; confirm return focus.
- Check selected/checked menu items and disabled actions with assistive technology.
- Traverse nested menus and long localized labels without losing focus or triggering the wrong action.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.