Documentation
¶
Overview ¶
Package modal provides declarative modal dialog components with automatic hit region management, focus handling, scrolling, and keyboard/mouse interaction.
Index ¶
- Constants
- func ContentBoxWidth(surfaceWidth int) int
- func ListRows(surfaceHeight, seen int) int
- func ListRowsFor(surfaceHeight, seen, current int) int
- func NaturalWidth(sections ...Section) int
- func PreferredListRows(surfaceHeight int) int
- func WidthForSections(sections ...Section) int
- func WithMaxVisible(n int) maxVisibleOption
- type BtnOption
- type ButtonDef
- type ComboFilterFunc
- type ComboOption
- type Control
- type ControlRowOverlay
- type CustomRenderFunc
- type CustomUpdateFunc
- type DropdownItem
- type FocusableInfo
- type InputOption
- type ListItem
- type ListOption
- type Modal
- func (m *Modal) AddSection(s Section) *Modal
- func (m *Modal) Apply(opts ...Option)
- func (m *Modal) CanScroll(delta int) bool
- func (m *Modal) FocusedID() string
- func (m *Modal) HandleKey(msg tea.KeyPressMsg) (action string, cmd tea.Cmd)
- func (m *Modal) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) string
- func (m *Modal) HoveredID() string
- func (m *Modal) Invalidate()
- func (m *Modal) Render(screenW, screenH int, handler *mouse.Handler) string
- func (m *Modal) Reset()
- func (m *Modal) ScrollBy(delta int)
- func (m *Modal) ScrollToBottom()
- func (m *Modal) ScrollToTop()
- func (m *Modal) SectionBarAt(x, y int, handler *mouse.Handler) (declared SectionScrollbar, trackX, trackY int, onThumb bool, ok bool)
- func (m *Modal) SetFocus(id string)
- func (m *Modal) WheelAtBoundary(msg tea.MouseWheelMsg, h *mouse.Handler) bool
- type NaturalWidthSection
- type Option
- func WithCloseOnBackdropClick(close bool) Option
- func WithCustomFooter(footer string) Option
- func WithHintText(text string) Option
- func WithHints(show bool) Option
- func WithInitialFocus(id string) Option
- func WithMargin(x, y int) Option
- func WithPrimaryAction(actionID string) Option
- func WithTitle(t string) Option
- func WithVariant(v Variant) Option
- func WithWidth(w int) Option
- type Overlay
- type RenderedSection
- type ScrollOwnerSection
- type Section
- func Buttons(btns ...ButtonDef) Section
- func Checkbox(id, label string, checked *bool) Section
- func CheckboxDisplay(label string, checked *bool, hint string) Section
- func Combo(id string, input *textinput.Model, items []DropdownItem, selected *int, ...) Section
- func ControlRow(lead string, controls []Control, overlay ControlRowOverlay) Section
- func Custom(renderFn CustomRenderFunc, updateFn CustomUpdateFunc) Section
- func Input(id string, model *textinput.Model, opts ...InputOption) Section
- func InputWithLabel(id, label string, model *textinput.Model, opts ...InputOption) Section
- func List(id string, items []ListItem, selectedIdx *int, opts ...ListOption) Section
- func ScrollingCustom(renderFn CustomRenderFunc, updateFn CustomUpdateFunc, ...) Section
- func Select(id string, items []SelectItem, selected *int, opts ...SelectOption) Section
- func Spacer() Section
- func Text(s string) Section
- func Textarea(id string, model *textarea.Model, height int, opts ...TextareaOption) Section
- func TextareaWithLabel(id, label string, model *textarea.Model, height int, opts ...TextareaOption) Section
- func When(condition func() bool, section Section) Section
- type SectionScrollbar
- type SelectItem
- type SelectOption
- type SelectShape
- type TextareaOption
- type Variant
Constants ¶
const ( // BackdropRegionID names the region a modal registers over the whole // surface it was drawn on. A host that composites the box somewhere other // than where the modal thought it was — panemodal, placing it in a pane — // registers its own under this ID so the surface behind the box still // absorbs clicks. BackdropRegionID = "modal-backdrop" // RegionOverlayBackdrop names the region a modal registers over the whole // rectangle an overlay occupies, so clicks and hovers on the overlay's // chrome or empty cells do not bleed through to the content underneath it. RegionOverlayBackdrop = "modal-overlay-backdrop" DefaultWidth = 50 MinModalWidth = 30 MaxModalWidth = 120 ModalPadding = 6 // border(2) + horizontal padding(4) // ScrollbarColumns is the content column the body's scrollbar takes when // the content is taller than the viewport — buildLayout re-renders every // section at contentWidth-1 once it needs one. A host sizing a modal to its // widest control budgets for it, or the control fits until the modal grows // a scrollbar and then quietly changes shape. ScrollbarColumns = 1 // DefaultMarginX/Y are the cells left clear around the modal box. DefaultMarginX = 2 DefaultMarginY = 1 // RoomyMarginX is the surface a content-sized box tries to leave visible on // each side of itself, and the width a pane host requires before it will // show the surface behind the box at all. The two are the same number on // purpose: a box that grows to DefaultMarginX of its surface can never leave // a readable ring, so the host would always fall back to a takeover, which // is how a three-row picker came to own a whole pane. RoomyMarginX = 8 // MinRoomyWidth is the narrowest box worth keeping a ring around. Below it // the rows need the columns more than the surface behind them does. MinRoomyWidth = 40 // MinListRows/MaxListRows bound PreferredListRows. MinListRows = 8 MaxListRows = 14 // ChromeWidth/ChromeHeight are what the box itself costs: border plus // padding. A caller budgeting its own content needs the same numbers. ChromeWidth = 6 ChromeHeight = 4 )
Default modal dimensions
const ( RegionScrollbarThumb = "scrollbar-thumb" RegionScrollbarTrack = "scrollbar-track" )
Region IDs for the interactive scrollbars a modal can carry. They mirror ui.RegionScrollbarThumb/Track; internal/ui imports this package (the overlay helpers), so sharing them by import would cycle. Each surface owns its own HitMap, so the two spellings never meet in one map.
Variables ¶
This section is empty.
Functions ¶
func ContentBoxWidth ¶ added in v1.0.0
ContentBoxWidth is the widest a content-sized box may be on a surface this wide. It keeps RoomyMarginX clear on each side so a host that dims the surface around the box has something left to dim, and falls back to the ordinary margin on a surface too narrow for that to leave a usable box.
func ListRows ¶ added in v1.0.0
ListRows is how long a content-sized list actually draws itself: the preferred length, less what it has never needed, but never below MinListRows.
seen is the most rows the list has wanted since it was opened — a high-water mark, not the current count. A box sized to the current count breathes under the user's hands as a query is refined; a box sized to the preferred length whatever happens reserves two dozen rows for a picker that has one hit and reads as broken on a large screen. Growing once into the results and then holding still is the balance: refining a query, which is where the jitter was unbearable, never resizes anything.
func ListRowsFor ¶ added in v1.0.0
ListRowsFor is ListRows with the two cases the high-water mark gets wrong.
The mark exists so that refining a query does not resize the box under the user's hands, and that is right while the list is answering. It is not right once it has stopped:
- a query that matches nothing gets a one-row list. The mark had a box that grew to fifty hits still reserving a dozen rows under the words "No matches", which reads as broken rather than steady, and nothing is being refined at that point — the query has stopped matching.
- a list showing fewer rows than the ordinary floor keeps the floor and no more. One hit in a fourteen-row box is thirteen blank rows; one hit in an eight-row box is the same box an unasked finder draws, so nothing has jittered and nothing is being reserved for results that are not coming.
current is how many rows the list is showing. A caller in a state that has not asked anything yet — no query, or a scan still running — passes MinListRows rather than zero: an empty box is not a dead end, and a box that opens one row tall and grows is the jitter this all exists to avoid.
func NaturalWidth ¶ added in v1.14.0
NaturalWidth is the widest natural width among sections, or 0 when none of them asks for one. A When wrapper answers for its inner section only while its condition holds, so a hidden control does not widen a modal.
func PreferredListRows ¶ added in v1.0.0
PreferredListRows is the list length a content-sized modal aims for on a surface this tall: enough to be worth opening, never so much that a picker with three hits reserves most of a large pane. It deliberately does not depend on how many rows there are to show — a box that grows as results land breathes under the user's hands.
func WidthForSections ¶ added in v1.14.0
WidthForSections is the modal width that holds every section at its natural width: the widest control, the box's own border and padding, and the column a scrollbar takes when the body is taller than the surface — because a modal that fits its widest control only until the body scrolls is a modal that changes shape as it fills up. It returns 0 when no section asks for a width; a host takes the larger of this and its own default, and caps the result to the frame it floats over.
func WithMaxVisible ¶
func WithMaxVisible(n int) maxVisibleOption
WithMaxVisible sets the maximum number of visible items. Anything past it scrolls, with the more-above and more-below markers saying so.
Types ¶
type BtnOption ¶
type BtnOption func(*ButtonDef)
BtnOption is a functional option for buttons.
func BtnDanger ¶
func BtnDanger() BtnOption
BtnDanger marks the button as a danger/destructive action.
func BtnDisabled ¶ added in v1.3.0
func BtnDisabled() BtnOption
BtnDisabled marks the button unavailable: muted, unfocusable, and inert to both Enter and a click.
func BtnPrimary ¶
func BtnPrimary() BtnOption
BtnPrimary is a no-op for compatibility (primary styling is default for focused).
type ButtonDef ¶
type ButtonDef struct {
Label string
ID string
IsDanger bool
// Disabled buttons are drawn muted, are skipped by focus, and never
// return their action. A refusal the user can see beats a click that
// quietly does nothing.
Disabled bool
}
ButtonDef defines a button in a button row.
type ComboFilterFunc ¶ added in v1.0.0
type ComboFilterFunc func(query string, item DropdownItem) bool
ComboFilterFunc reports whether item matches the current query.
type ComboOption ¶ added in v1.0.0
type ComboOption func(*comboSection)
ComboOption configures a Combo section.
func WithComboFilter ¶ added in v1.0.0
func WithComboFilter(fn ComboFilterFunc) ComboOption
WithComboFilter replaces the default case-insensitive substring filter.
func WithComboMaxVisible ¶ added in v1.0.0
func WithComboMaxVisible(n int) ComboOption
WithComboMaxVisible sets how many overlay rows are shown (default 8).
func WithComboSubmitOnEnter ¶ added in v1.0.0
func WithComboSubmitOnEnter(submit bool) ComboOption
WithComboSubmitOnEnter submits the modal primary action after Enter commits the highlight (default true).
func WithOpenOnFocus ¶ added in v1.0.0
func WithOpenOnFocus(open bool) ComboOption
WithOpenOnFocus opens the overlay when the field gains focus (default true).
type Control ¶ added in v1.14.0
type Control struct {
// ID is the action a press reports and the region the pointer hits.
ID string
// Label is the text inside the pill, without its padding.
Label string
// Active marks the control's state as the one currently in force — the
// selected view, an open menu. It is a fact about the surface, not about
// focus, and the two are drawn differently on purpose.
Active bool
// Focused marks the control the keyboard is talking to.
Focused bool
}
Control is one pill in a control row.
type ControlRowOverlay ¶ added in v1.14.0
ControlRowOverlay lets a caller hang a popover off one of the controls. It receives each control's x offset within the section, in the order they were given, and the ID of the currently hovered element, and returns nil when nothing is open.
type CustomRenderFunc ¶
type CustomRenderFunc func(contentWidth int, focusID, hoverID string) RenderedSection
CustomRenderFunc is the signature for custom section render functions.
type CustomUpdateFunc ¶
CustomUpdateFunc is the signature for custom section update functions.
type DropdownItem ¶ added in v1.0.0
type DropdownItem struct {
ID string
Label string
Value string // written into the input on commit; empty means Label
Desc string
Data any
}
DropdownItem is one row in a Combo overlay.
type FocusableInfo ¶
type FocusableInfo struct {
ID string // Unique identifier for this element
OffsetX int // X offset relative to section top-left (within content area)
OffsetY int // Y offset relative to section top-left (within content area)
Width int // Width in characters
Height int // Height in lines
MouseOnly bool // Hit-tested but omitted from the Tab / focus order
}
FocusableInfo describes a focusable element within a section.
type InputOption ¶
type InputOption func(*inputSection)
InputOption is a functional option for Input sections.
func WithSubmitAction ¶
func WithSubmitAction(actionID string) InputOption
WithSubmitAction sets the action ID returned on submit.
func WithSubmitOnEnter ¶
func WithSubmitOnEnter(submit bool) InputOption
WithSubmitOnEnter enables or disables submit-on-enter behavior.
type ListItem ¶
type ListItem struct {
ID string // Unique identifier for this item
Label string // Display text
Data any // Optional associated data
}
ListItem represents an item in a list section.
type ListOption ¶
type ListOption interface {
// contains filtered or unexported methods
}
ListOption is an option for List sections. It is an interface rather than a function type so one option value can configure more than one kind of section: WithMaxVisible caps a List and a Select alike, and neither has to invent its own spelling of the same idea.
func WithPerItemFocus ¶
func WithPerItemFocus() ListOption
WithPerItemFocus makes the list register each item as a separate focusable for Tab navigation. This overrides the default single-focus behavior when you want Tab to cycle through individual items.
func WithSingleFocus ¶
func WithSingleFocus() ListOption
WithSingleFocus makes the list register as a single focusable unit for Tab navigation. When focused, j/k or up/down change selection within the list without Tab-cycling through each item. This is useful for lists that are part of a larger form where Tab should skip between sections. Note: This is now the default behavior. This option is kept for backward compatibility.
type Modal ¶
type Modal struct {
// contains filtered or unexported fields
}
Modal represents a declarative modal dialog with automatic hit region management.
func (*Modal) AddSection ¶
AddSection adds a section to the modal. Returns the modal for chaining.
func (*Modal) Apply ¶ added in v1.7.0
Apply applies options to an existing modal. It is how a long-lived modal changes presentation (title, variant, hints) without being rebuilt, so its focus list and hit regions survive the change.
func (*Modal) CanScroll ¶ added in v1.7.0
CanScroll reports whether the body viewport can still move delta lines in the given direction — what an inner scroller's owner needs to decide when to hand leftover scroll keys to the body.
func (*Modal) HandleKey ¶
HandleKey processes keyboard input. Returns:
- action: the action ID if triggered ("cancel" for Esc, button/input ID for Enter, etc.)
- cmd: any tea.Cmd from bubbles models (cursor blink, etc.)
func (*Modal) HandleMouse ¶
HandleMouse processes mouse input. Returns the action ID if a clickable element was clicked, empty string otherwise.
func (*Modal) Invalidate ¶ added in v1.0.0
func (m *Modal) Invalidate()
Invalidate marks the cached layout bounds as untrustworthy. Call it whenever the modal's content changes outside a render (for example when an async load replaces the text a Custom section draws). Until the next Render, boundary queries answer "unknown" rather than guessing.
func (*Modal) Render ¶
Render renders the modal and registers hit regions. Returns the styled modal content string.
func (*Modal) ScrollBy ¶
ScrollBy adjusts the scroll offset by delta lines (positive = down, negative = up). Movement is clamped through the last render's bounds; before the first trustworthy render the offset is clamped again in buildLayout.
func (*Modal) ScrollToBottom ¶
func (m *Modal) ScrollToBottom()
ScrollToBottom scrolls to the bottom of the content. The offset is clamped to the actual max in buildLayout.
func (*Modal) ScrollToTop ¶
func (m *Modal) ScrollToTop()
ScrollToTop scrolls to the top of the content.
func (*Modal) SectionBarAt ¶ added in v1.4.0
func (m *Modal) SectionBarAt(x, y int, handler *mouse.Handler) (declared SectionScrollbar, trackX, trackY int, onThumb bool, ok bool)
SectionBarAt reports the section-declared scrollbar under (x, y), if the point lands on one of its regions: the declaration the owner drew it with, the absolute position of the track's unclipped top row (so a press anchors correctly even when part of the bar is scrolled out of the viewport), and whether the point is on the thumb. ok is false for the framework's own viewport bar, empty space, and every non-scrollbar region — a host's mouse handler uses this to claim exactly its bar's events before anything else sees them.
func (*Modal) WheelAtBoundary ¶ added in v1.0.0
WheelAtBoundary reports whether this wheel event is certainly a no-op for the modal, using only the geometry and scroll bounds produced by the most recent Render. It never rebuilds or mutates visible content.
True means "certain no-op": the event can be dropped before Update and View. False means the surface can move, or that the answer is unknown - callers must forward the event. The query answers unknown before the first render and after Invalidate, and answers true for wheel over the backdrop or over non-scrollable modal chrome, because an open modal absorbs those events without changing state. When the pointer is over a section that owns its own scroll state (see ScrollOwnerSection), that section answers instead.
type NaturalWidthSection ¶ added in v1.14.0
type NaturalWidthSection interface {
Section
// NaturalWidth is the content width this section would rather have, or 0
// for a section that fills whatever column it is handed.
NaturalWidth() int
}
NaturalWidthSection is implemented by a section that has a width it would rather be given than be truncated to. A segmented Select is the case that forced it: its shape is a single row of labels, so a modal that is narrower than that row either truncates the labels into stubs or drops the control to its list shape, and both are decisions the host should be making with the number in front of it.
The reported width is a CONTENT width — what the section wants inside the modal's border and padding. It is a wish, not a floor: a host still caps it to the frame, and a section handed less must still draw something sensible.
type Option ¶
type Option func(*Modal)
Option is a functional option for configuring a Modal.
func WithCloseOnBackdropClick ¶
WithCloseOnBackdropClick controls whether clicking the backdrop dismisses the modal. Defaults to true.
func WithCustomFooter ¶
WithCustomFooter sets a fixed footer line rendered outside the scroll viewport.
func WithHintText ¶ added in v1.3.0
WithHintText replaces the default keyboard hint line. Use it where one of the default verbs is a lie — a modal whose Enter is a no-op should not advertise "Enter to confirm". Implies WithHints(true).
func WithInitialFocus ¶ added in v1.2.2
WithInitialFocus sets the element ID that receives focus on first render.
func WithMargin ¶ added in v1.0.0
WithMargin sets how much of the surface the modal leaves clear around itself. The default keeps the box off the edge of a screen; a modal that is meant to own its surface — a pane too small to show anything useful behind the modal — passes 0, 0 and is then rendered at exactly the surface's size.
func WithPrimaryAction ¶
WithPrimaryAction sets the action ID returned when input submits implicitly.
type Overlay ¶ added in v1.0.0
type Overlay struct {
Content string
OffsetX int
OffsetY int // preferred top relative to the section (typically just below it)
Focusables []FocusableInfo
}
Overlay is drawn over later sections and does not count toward modal height. Focusables are relative to the overlay's top-left, not the section.
type RenderedSection ¶
type RenderedSection struct {
Content string // Rendered string content
Focusables []FocusableInfo // Focusable elements with hit region info
Overlay *Overlay // Optional floating layer; does not affect section height
Scrollbar *SectionScrollbar // Interactive scrollbar drawn into this section's content (see scrollbar.go)
}
RenderedSection is the result of rendering a section.
type ScrollOwnerSection ¶ added in v1.0.0
type ScrollOwnerSection interface {
Section
// OwnsScrollRegion reports whether the given mouse hit region ID belongs to
// this section's scrollable area.
OwnsScrollRegion(regionID string) bool
// ScrollAtBoundary reports whether delta lines (negative up, positive down)
// cannot move this section's own scroll state.
ScrollAtBoundary(delta int) bool
}
ScrollOwnerSection is implemented by sections that own their own scroll state (a document viewport, a nested list) rather than moving the modal body's offset. When the pointer is over a region such a section claims, Modal.WheelAtBoundary delegates the answer to it.
Both methods must be read-only: they may not rebuild or mutate content. ScrollAtBoundary follows the same semantics as Modal.WheelAtBoundary - true only when applying delta is certainly a no-op, false for movable or unknown.
type Section ¶
type Section interface {
// Render returns the rendered section content and focusable elements.
// contentWidth is the available width for content (modal width minus border/padding).
// focusID is the ID of the currently focused element (for styling).
// hoverID is the ID of the currently hovered element (for styling).
Render(contentWidth int, focusID, hoverID string) RenderedSection
// Update handles input when this section contains the focused element.
// Returns action string if the input triggers an action, plus any tea.Cmd.
Update(msg tea.Msg, focusID string) (action string, cmd tea.Cmd)
}
Section is the interface for modal content sections.
func CheckboxDisplay ¶
CheckboxDisplay creates a non-focusable checkbox display. The hint shows the keyboard shortcut to toggle (e.g., "ctrl+a").
func Combo ¶ added in v1.0.0
func Combo(id string, input *textinput.Model, items []DropdownItem, selected *int, opts ...ComboOption) Section
Combo creates a text field whose filtered list floats over later sections. selected is an index into items (the same convention as List). Typing moves it to the top match's items index, not 0 unless that item is first.
func ControlRow ¶ added in v1.14.0
func ControlRow(lead string, controls []Control, overlay ControlRowOverlay) Section
ControlRow renders lead on the left and controls on the right, all on one line. Controls that do not fit keep their order and their regions; the caption is what gives way first, because a caption that is one column short still reads and a pill that is one column short does not.
func Custom ¶
func Custom(renderFn CustomRenderFunc, updateFn CustomUpdateFunc) Section
Custom creates a custom section with user-provided render and update functions. If updateFn is nil, updates are no-ops.
func Input ¶
func Input(id string, model *textinput.Model, opts ...InputOption) Section
Input creates an input section wrapping a textinput.Model.
func InputWithLabel ¶
func InputWithLabel(id, label string, model *textinput.Model, opts ...InputOption) Section
InputWithLabel creates an input section with a label.
func List ¶
func List(id string, items []ListItem, selectedIdx *int, opts ...ListOption) Section
List creates a list section with selectable items. selectedIdx is a pointer to the currently selected index (can be nil for no selection).
List is the low-level form: a column of rows a caller reads what it likes out of. A single choice among a known set — a sort, a filter, a kind — is a Select, which owns the two shapes and the disabled rule on top of these same mechanics.
func ScrollingCustom ¶ added in v1.0.0
func ScrollingCustom(renderFn CustomRenderFunc, updateFn CustomUpdateFunc, ownsRegion func(regionID string) bool, atBoundary func(delta int) bool) Section
ScrollingCustom creates a Custom section that owns its own scroll state and can answer wheel-boundary questions for the regions it claims. ownsRegion receives a mouse hit region ID; atBoundary must be read-only and may return true only when delta is certainly a no-op. Either callback may be nil, in which case the section never claims the wheel.
func Select ¶ added in v1.14.0
func Select(id string, items []SelectItem, selected *int, opts ...SelectOption) Section
Select creates the single-choice control: pick one of items, with selected holding the chosen index.
It draws as a segmented [ A | B | C ] while the choices are few and as a full-width ❯-cursor list once they are many, because a row of segments stops being readable at about five. Movement stops at the ends rather than wrapping, a click resolves to a row inside the section with no help from the host, and WithMaxVisible scrolls anything past it with the more-above and more-below markers.
func TextareaWithLabel ¶
func TextareaWithLabel(id, label string, model *textarea.Model, height int, opts ...TextareaOption) Section
TextareaWithLabel creates a textarea section with a label.
type SectionScrollbar ¶ added in v1.4.0
type SectionScrollbar struct {
TotalItems int
ScrollOffset int
VisibleItems int
TrackHeight int
LocalX int // column within the section content where the bar sits
}
SectionScrollbar declares the interactive scrollbar a section drew into its own content, at LocalX columns from the section's left edge. Declaring it is what makes the library place the hit regions (last, so they beat the content they overlap) and report their ownership back through SectionBarAt.
Rendering stays the section's job — the string it drew remains the single source of what its bar looks like. Gesture answering is the declaring surface's too, via SectionBarAt from its own mouse handler; the framework only absorbs the presses so they can never fall through to a list row underneath. This split exists because the app Model is passed by value per update: routed callbacks would mutate a stale copy, while the owning handler runs on the copy that survives.
type SelectItem ¶ added in v1.14.0
type SelectItem struct {
ID string // Unique hit-region identifier for this choice
Label string // The word the choice is known by
// Description is the aligned second column of the list shape. The
// segmented shape has no room for it and leaves it out.
Description string
Data any // Optional associated data
}
SelectItem is one choice in a Select.
type SelectOption ¶ added in v1.14.0
type SelectOption interface {
// contains filtered or unexported methods
}
SelectOption is an option for Select sections.
func WithDisabled ¶ added in v1.14.0
func WithDisabled(reason func(i int) string) SelectOption
WithDisabled marks choices that cannot be picked right now, answering per index WHY not — the empty string for a choice that can. A disabled choice stays visible and muted, with its reason in place of its description, so the rule is read before the row is entered; the keyboard steps over it and a click on it changes nothing.
func WithOnSelect ¶ added in v1.14.0
func WithOnSelect(fn func(i int)) SelectOption
WithOnSelect reports every selection change — by key or by click — to the caller, for a control whose choice has consequences beyond the index (the Create Workspace kind list rebuilds its form around it).
func WithSelectAction ¶ added in v1.14.0
func WithSelectAction(action string) SelectOption
WithSelectAction fixes the action a row activation returns, instead of the activated row's own ID. A selector embedded in a form uses it so a click still reports the control rather than a row the host has no branch for.
func WithShape ¶ added in v1.14.0
func WithShape(shape SelectShape) SelectOption
WithShape forces one of the two shapes instead of choosing by item count.
type SelectShape ¶ added in v1.14.0
type SelectShape int
SelectShape is how a Select draws itself.
const ( // ShapeAuto picks by item count: the segmented toggle under five choices, // the list at five or more, and the list whenever the segments would not // fit the width they are given. ShapeAuto SelectShape = iota // ShapeSegmented forces [ A | B | C ]. ShapeSegmented // ShapeList forces the ❯-cursor column. A surface whose labels are // sentences, or whose twin surface's are, forces it so the two match. ShapeList )
type TextareaOption ¶
type TextareaOption func(*textareaSection)
TextareaOption is a functional option for Textarea sections.