create-modal

Featured

Create declarative modals using the modal library API. Covers modal types (confirm, input, select, form), sections (Text, Buttons, Input, Textarea, Checkbox, List, When, Custom), rendering with OverlayModal, and keyboard/mouse handling. Use when adding modals or dialogs to the application.

AI & Automation 1,041 stars 80 forks Updated today MIT

Install

View on GitHub

Quality Score: 92/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Creating Declarative Modals Use the `internal/modal` package. The library handles keyboard navigation, mouse hit regions, hover states, and scrolling automatically. ## Quick Start ```go import "github.com/marcus/sidecar/internal/modal" // 1. Create the modal m := modal.New("Delete Worktree?", modal.WithWidth(58), modal.WithVariant(modal.VariantDanger), modal.WithPrimaryAction("delete"), ). AddSection(modal.Text("Name: " + wt.Name)). AddSection(modal.Spacer()). AddSection(modal.Buttons( modal.Btn(" Delete ", "delete", modal.BtnDanger()), modal.Btn(" Cancel ", "cancel"), )) // 2. Render in View func (p *Plugin) View(width, height int) string { background := p.renderListView(width, height) rendered := p.myModal.Render(width, height, p.mouseHandler) return ui.OverlayModal(background, rendered, width, height) } // 3. Handle input in Update case tea.KeyMsg: action, cmd := p.myModal.HandleKey(msg) if action != "" { return p.handleAction(action) // "delete", "cancel", etc. } return p, cmd case tea.MouseMsg: action := p.myModal.HandleMouse(msg, p.mouseHandler) if action != "" { return p.handleAction(action) } return p, nil ``` ## Critical: Modal Initialization Pattern The modal must exist before input handling. Create an `ensure` function called in **both** View and Update: ```go func (p *Plugin) ensureMyModal() { if p.targetItem == nil { return // Required s...

Details

Author
marcus
Repository
marcus/sidecar
Created
7 months ago
Last Updated
today
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category