Editable List
Data Display
Forms
Interactive list with checkable items, inline editing, drag-and-drop reordering, and action menus.
Preview
Checkable list with inline editing - double-click to edit, hover for actions
- Review design mockups
- Update component library
- Write documentation
Drag & Drop Reordering
Enable reorderable to drag items to new positions
- High priority task
- Medium priority task
- Low priority task
Without Checkboxes
Simple list without completion tracking
- First item
- Second item
- Third item
Read-Only Mode
Checkable but not editable
- Read-only item 1
- Read-only item 2
- Read-only item 3
Custom Actions
Add custom action buttons to the menu
- Feature request
- Bug report
- Enhancement
Empty State
Custom message when list is empty
No tasks yet. Add one to get started!
Props
EditableList component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
items | EditableListItem[] | — | Array of list items (required) |
onChange | (items: EditableListItem[]) => void | — | Called when items change |
onItemToggle | (item: EditableListItem) => void | — | Called when item is checked/unchecked |
onItemEdit | (item, newText) => void | — | Called when item text is edited |
onItemDelete | (item: EditableListItem) => void | — | Called when item is deleted |
actions | EditableListAction[] | — | Custom action menu items |
reorderable | boolean | false | Enable drag-and-drop reordering |
checkable | boolean | true | Show checkboxes |
editable | boolean | true | Enable inline editing |
emptyMessage | string | — | Message shown when list is empty |
className | string | — | Additional CSS classes |
EditableListItem Type
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | number | — | Unique identifier (required) |
text | string | — | Item text content (required) |
completed | boolean | — | Whether item is checked |
editable | boolean | — | Override editability per item |
Usage
Import and implementation example
import { EditableList, EditableListItem } from '@/blocks/data-display/editable-list'
import { Star } from 'lucide-react'
export default function Example() {
const [items, setItems] = useState<EditableListItem[]>([
{ id: 1, text: 'Task 1', completed: false },
{ id: 2, text: 'Task 2', completed: true },
])
return (
<>
{/* Basic editable list */}
<EditableList
items={items}
onChange={setItems}
onItemDelete={(item) => console.log('Deleted:', item)}
/>
{/* With drag-and-drop reordering */}
<EditableList
items={items}
onChange={setItems}
reorderable
/>
{/* Without checkboxes */}
<EditableList
items={items}
onChange={setItems}
checkable={false}
/>
{/* Read-only (no editing) */}
<EditableList
items={items}
onChange={setItems}
editable={false}
/>
{/* With custom actions */}
<EditableList
items={items}
onChange={setItems}
actions={[
{
label: 'Star',
icon: <Star className="w-4 h-4" />,
onClick: (item) => console.log('Starred:', item),
},
]}
/>
{/* Custom empty message */}
<EditableList
items={[]}
emptyMessage="No items yet"
/>
</>
)
}Features
Built-in functionality
- Checkable items: Track completion with styled checkboxes
- Inline editing: Double-click to edit, Enter to save, Escape to cancel
- Drag and drop: Reorder items with native HTML5 drag-and-drop
- Actions menu: Built-in edit/delete plus custom actions
- Hover effects: Show actions and drag handle on hover
- Strikethrough: Completed items show with strikethrough text
- Empty state: Custom message when no items
- Dark mode: Full dark mode support
Accessibility
Accessibility considerations
ARIA Attributes
Uses semantic list elementsCheckbox has proper labelingDrag handle is keyboard accessibleKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between items |
| Space | Toggle checkbox |
| Enter | Save edit / Activate action |
| Escape | Cancel edit |
| Double-click | Start editing |
Notes
- Focus management during edit mode
- Drag operations announced to screen readers
- Delete confirmation for destructive actions