Skip to content

List

A list shows entries in a card with an optional caption and footer. list.Entry is the typical row with a leading view, a headline, a supporting text and a trailing view. Rows can be clicked.

List

func view(wnd core.Window) core.View {
    person := func(name, role string) list.TEntry {
        return list.Entry().
            Leading(avatar.Text(name)).
            Headline(name).
            SupportingText(role).
            Trailing(ImageIcon(icons.ChevronRight)).
            Action(func() {
                // navigate to the details of the person
            })
    }

    return list.List(
        person("Ada Lovelace", "Engineering"),
        person("Grace Hopper", "Operations"),
        person("Alan Turing", "Research"),
    ).
        Caption(Text("Team members")).
        Footer(Text("3 entries")).
        Frame(Frame{Width: L400})
}

Constructors

List

func List(entries ...core.View) TList

List creates a new TList with the given entries as rows.

Entry

func Entry() TEntry

Entry creates a new full-width entry with default frame.

Methods

List

MethodDescription
Caption(s core.View) TListCaption sets an optional caption view above the list.
ColorBody(color ui.Color) TListColorBody sets the background color of the entries.
ColorCaption(color ui.Color) TListColorCaption sets the background color of the caption.
ColorFooter(color ui.Color) TListColorFooter sets the background color of the footer.
ColorHighlight(color ui.Color) TListColorHighlight sets the background color of highlighted entries.
ColorHover(color ui.Color) TListColorHover sets the background color of a hovered entry.
Footer(s core.View) TListFooter sets an optional footer view below the list.
Frame(frame ui.Frame) TListFrame sets the layout frame of the list.
FullWidth() TListFullWidth expands the list to use the full available width.
OnEntryClicked(fn func(idx int)) TListOnEntryClicked sets a callback for when a row is clicked.
OnHighlighted(fn func(idx int) bool) TListOnHighlighted sets a predicate which decides whether the entry at idx is highlighted.
With(fn func(c TList) TList) TListWith applies the given function to the list, which helps with conditional configuration.

Entry

MethodDescription
Action(fn func()) TEntryAction sets a click/tap action handler.
Frame(frame ui.Frame) TEntryFrame sets the layout frame for the entry.
Headline(s string) TEntryHeadline sets the main title text of the entry.
HeadlineView(view core.View) TEntryHeadlineView sets a custom view instead of the headline text.
Leading(v core.View) TEntryLeading sets an optional leading view, e.g. an avatar or icon.
SupportingText(s string) TEntrySupportingText sets an optional supporting text below the headline.
SupportingView(view core.View) TEntrySupportingView sets an optional supporting view below the headline.
Trailing(v core.View) TEntryTrailing sets an optional trailing view, e.g. an icon or a button.

Related