- Add PLAN.md with 40-step checklist across 10 phases - Add CLAUDE.md with project-specific instructions - Set up nix flake with FastHTML/MonsterUI dependencies - Create Python package skeleton (src/animaltrack) - Vendor FastHTML and MonsterUI documentation - Add Docker build configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.8 KiB
Alerts & Toasts API Reference
Alerts
The simplest alert is a div wrapped with a span:
See Source
See Output
This is a plain alert
[code]
def ex_alerts1(): return Alert("This is a plain alert")
[/code]
Alert colors are defined by the alert styles:
See Source
See Output
Your purchase has been confirmed!
[code]
def ex_alerts2(): return Alert("Your purchase has been confirmed!", cls=AlertT.success)
[/code]
It often looks nice to use icons in alerts:
See Source
See Output
Please enter a valid email.
[code]
def ex_alerts3():
return Alert(
DivLAligned(UkIcon('triangle-alert'),
P("Please enter a valid email.")),
cls=AlertT.error)
[/code]
Alert
Source
[code]
Alert(*c, cls='', **kwargs) -> fastcore.xml.FT
[/code]
Alert informs users about important events.
Params
-
cContent for Alert (often text and/or icon) -
clsClass for the alert (often anAlertToption) -
kwargs
Returns: Div(Span(...), cls='alert', role='alert')
AlertT
Alert styles from DaisyUI
| Option | Value | Option | Value |
|---|---|---|---|
| info | alert-info | success | alert-success |
| warning | alert-warning | error | alert-error |
Toasts
To define a toast with a particular location, add horizontal or vertical toast type classes:
See Source
See Output
First Example Toast
[code]
def ex_toasts1():
return Toast("First Example Toast", cls=(ToastHT.start, ToastVT.bottom), dur=300)
[/code]
To define toast colors, set the class of the alert wrapped by the toast:
See Source
See Output
Second Example Toast
[code]
def ex_toasts2():
return Toast("Second Example Toast", alert_cls=AlertT.info, dur=300)
[/code]
Toasts will disappear automatically after 5 seconds. To change the duration of the toast set the dur param like this Toast('Content', dur=10).
Here's a demo app showing how to trigger a toast.
Toast
Source
[code]
Toast(*c, cls='', alert_cls='', dur=5.0, **kwargs) -> fastcore.xml.FT
[/code]
Toasts are stacked announcements, positioned on the corner of page.
Params
-
cContent for toast (often test) -
clsClasses for toast (oftenToastHTandToastVToptions) -
alert_clsclasses for altert (oftenAlertToptions) -
durno. of seconds before the toast disappears -
kwargs
Returns: Div(Alert(...), cls='toast')
ToastHT
Horizontal position for Toast
| Option | Value | Option | Value |
|---|---|---|---|
| start | toast-start | center | toast-center |
| end | toast-end |
ToastVT
Vertical position for Toast
| Option | Value | Option | Value |
|---|---|---|---|
| top | toast-top | middle | toast-middle |
| bottom | toast-bottom |