Skip to content

Radix UI Dropdown Menu Checkbox Not Working — Fix Checked State

DodaTech Updated 2026-06-24 1 min read

In this fix, you'll learn how to use checkable items in Radix UI dropdown menus. This matters for multi-select menu items, and appears in filter menus and settings dropdowns.

The Problem

The following code demonstrates the typical mistake:

<DropdownMenuCheckboxItem>
  Show details
</DropdownMenuCheckboxItem>
// Checkbox never shows as checked

The Fix

Here is the corrected version:

const [showDetails, setShowDetails] = useState(true);
<DropdownMenuCheckboxItem
  checked={showDetails}
  onCheckedChange={setShowDetails}
>
  <DropdownMenuItemIndicator>
    <Check className="h-4 w-4" />
  </DropdownMenuItemIndicator>
  Show details
</DropdownMenuCheckboxItem>
// Checkbox toggles checked state correctly

Prevention

  • Use checked and onCheckedChange for controlled checkbox items.
  • Add DropdownMenuItemIndicator to show a check icon when checked.
  • For radio groups, use DropdownMenuRadioGroup and DropdownMenuRadioItem.
  • The checked state persists within the menu session unless managed externally.
  • Use onCheckedChange handler to persist the setting (localStorage, state).

Common Mistakes with ui dropdown check

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world RADIX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How does DropdownMenuCheckboxItem differ from DropdownMenuItem?

DropdownMenuCheckboxItem is a selectable item with a checked state. It's rendered as a role='menuitemcheckbox' for accessibility. DropdownMenuItem is a simple clickable item.

How do I create a radio group in a dropdown?

Use DropdownMenuRadioGroup as parent with value prop, and DropdownMenuRadioItem children with individual value props. Only one radio item can be selected at a time.

Can I prevent the dropdown from closing on checkbox click?

No — by default, checking a checkbox closes the menu. To keep it open, you'd need to handle the close behavior manually with the open state of DropdownMenu.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro