toast

package module
v0.0.0-...-a73ab86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 7 Imported by: 0

README

Bubbletea Toast

bubbletea-toast is a simple Go library that demonstrates toast notifications using bubbletea.

This is a small personal project whilst I'm on a sabbatical. You're free to use in your own projects.

Demo

Simple Toast HTTP GIF

go run examples/http/main.go

Custom Toast with Dismiss Action Trigger GIF

go run examples/trigger/main.go

Features

  • Toast Notifications: Display different types of notifications (Info, Warning, Error, and custom types such as Party).
  • Custom Styling: Customize toast styles and positions.

Documentation

Index

Constants

View Source
const (
	TopLeft position = iota
	TopCenter
	TopRight
	BottomLeft
	BottomCenter
	BottomRight
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomToastStyle

type CustomToastStyle struct {
	Prefix string
	Style  lipgloss.Style
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles the lifecycle of toasts

func NewManager

func NewManager() Manager

NewManager creates a new toast manager

func (Manager) DismissAll

func (m Manager) DismissAll() tea.Cmd

func (Manager) Push

func (m Manager) Push(message string, toastType Type, duration time.Duration) tea.Cmd

Push adds a new toast to the queue

func (Manager) SetSize

func (m Manager) SetSize(width, height int) Manager

SetSize updates the width and height for toast positioning

func (Manager) Update

func (m Manager) Update(msg tea.Msg) (Manager, tea.Cmd)

func (Manager) View

func (m Manager) View() string

func (Manager) WithMaxToasts

func (m Manager) WithMaxToasts(max int) Manager

WithMaxToasts sets the maximum number of visible toasts

func (Manager) WithPosition

func (m Manager) WithPosition(pos position) Manager

WithPosition sets the position for toast notifications

func (Manager) WithStyle

func (m Manager) WithStyle(prefixType Type, prefix string, style lipgloss.Style) Manager

func (Manager) WithWidth

func (m Manager) WithWidth(width int) Manager

WithWidth sets the width of toast notifications

type Type

type Type int
const (
	Info Type = iota
	Warning
	Error
)

Directories

Path Synopsis
examples
http command
trigger command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL