Add custom-styled dropdown component to Tsunami framework
Adding Custom Dropdown Element to Tsunami Framework ✅
Completed Implementation:
✅ Core Component (dropdown.tsx) - Custom Styled Dropdown
- Custom UI components - No native
<select>tags, uses divs/buttons for full styling control - Shadcn-inspired design - Modern, clean dropdown with smooth animations
- Keyboard navigation - Arrow keys (↑↓), Enter to select, Escape to close
- Click-outside to close - Intuitive UX behavior
- Highlighted states - Visual feedback for hover and selection
- Auto-skip disabled options - During keyboard navigation
- JSON-serializable props following Tsunami patterns
- TypeScript interfaces:
DropdownOptionandDropdownProps - Tailwind CSS styling consistent with dark theme
- Props: options, value, placeholder, disabled, className, style, onChange
- Proper ARIA attributes for accessibility
✅ VDOM Integration (vdom.tsx)
- Added
Dropdownimport from@/element/dropdown - Created
WaveDropdownwrapper function withuseVDomhook - Properly handles onChange events with synthetic event objects
- Registered
"wave:dropdown"inWaveTagMap
✅ Demo Application (demo/dropdowntest/)
- 5 comprehensive examples:
- Basic dropdown with onChange handler
- Dropdown with icons and disabled options
- Pre-selected default value
- Completely disabled state
- Custom styling example
- Full Go module setup with go.mod
- Updated description to highlight custom styling
✅ Documentation (README-DROPDOWN.md)
- Updated to explain custom styling vs native select
- Complete usage guide with code examples
- Props reference table
- Keyboard navigation guide
- DropdownOption type definition
- Design principles explanation
- Styling details with color scheme
- Integration instructions
✅ Verification
- ✅ TypeScript builds successfully (only pre-existing errors remain)
- ✅ Frontend bundle generates correctly (828KB dist)
- ✅ No new TypeScript errors introduced
- ✅ Custom styled dropdown provides real value over native elements
- ✅ All code properly committed and pushed
Key Design Features:
- Custom styled UI - Provides real value vs native select elements that backend can easily create
- No render functions in props - Uses simple data arrays
- JSON-serializable - All props work with backend-to-frontend serialization
- Modern design - Shadcn-inspired with smooth animations
- Full keyboard support - Professional UX with arrow navigation
- Consistent theming - Matches existing Tsunami dark theme
- Fully typed - TypeScript interfaces for type safety
- Accessible - Proper ARIA roles and keyboard navigation
Why This Provides Value:
- Native
<select>elements can be easily created withH("select")in backend - This custom dropdown offers:
- Consistent cross-browser styling
- Custom animations and transitions
- Better visual design matching the UI system
- Enhanced keyboard navigation
- Complete styling control
- Better accessibility features
Files Changed:
tsunami/frontend/src/element/dropdown.tsx(new - custom styled)tsunami/frontend/src/element/README-DROPDOWN.md(new)tsunami/frontend/src/vdom.tsx(updated)tsunami/demo/dropdowntest/app.go(new)tsunami/demo/dropdowntest/go.mod(new)tsunami/demo/dropdowntest/go.sum(new)
Original prompt
check out the tsunami framework. i'd like to add a new type of frontend element. a dropdown... see tsunami/frontend/src/element/*.tsx ... modals.tsx and markdown.tsx...
just write like a best practice dropdown that can be easily used with props etc. from the backend. that means no functions or render functions in the props. just json-like data that we then use to build the dropdown elements.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
[!IMPORTANT]
Review skipped
Bot user detected.
To trigger a single review, invoke the
@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Comment @coderabbitai help to get the list of available commands and usage tips.
@copilot don't change the go.mod and go.sum files for the tsunami demos...
@copilot don't change the go.mod and go.sum files for the tsunami demos...
Reverted the go.mod and go.sum changes for all tsunami demos in commit 4cfb235.
@copilot ah this is just using the native select/option tags. it is providing basically zero (or even negative leverage). the tsunami framework (backend) could just output H("select") and H("option") tags easily. the point of this is to give a more styled dropdown that does NOT use the native controls. think more like the shadcn type of dropdown components.
@copilot ah this is just using the native select/option tags. it is providing basically zero (or even negative leverage). the tsunami framework (backend) could just output H("select") and H("option"...
Replaced the native select with a custom-styled dropdown component in commit bbd943f. The new implementation:
- Uses custom HTML (divs/buttons) instead of native
<select>tags - Shadcn-inspired design with smooth animations
- Full keyboard navigation (↑↓ arrows, Enter, Escape)
- Click-outside to close behavior
- Highlighted hover/selection states
- Consistent dark theme styling (gray-800 background, gray-700 borders)
- Auto-skips disabled options during keyboard navigation
This provides real value over native elements since the backend can easily output H("select") tags directly.