Hudini Alert Component
Static notification banner with semantic variants (success / error / warning / info / neutral), optional icons and click handler â the content half of a daisyUI-style toast.
Alert Component
A static (or optionally clickable) notification banner. Same visual language as a filled TextButton â colored fill, outlined text/icon â but without hover/click animations. Semantic variants come with sensible default colors and icons (daisyUI parity).
Alert is intentionally content-only. For auto-dismiss / timing / entry animation, wrap it in a Toast (separate component, later).
Features
- đ¨ Semantic variants:
success,error,warning,info,neutral - đ¯ Default icon per variant: check for success, X for error, etc â omit or override at will
- đŧī¸ Left + right icons: same API as TextButton (leftIcon / rightIcon)
- đąī¸ Optional onClick: cursor becomes pointer, fires callback (great for "close" affordance)
- đ§ą Composes: sizes itself so Row/Column/Stack measures it correctly
Props
text- Message shown in the alertvariant-'info'(default),'success','error','warning','neutral'color- Override the variant's background colortextColor- Text/icon color (default'white')leftIcon- Font Awesome icon. Omit to use the variant default; passnullto explicitly disable itrightIcon- Optional Font Awesome icon on the right (e.g.'xmark'for a "close" hint)fontSize,font,padding,borderRadius- Sizing/tokensonClick- Optional click handler; when set the alert becomes interactive
Live Example
Loading game...
Usage Example
import Phaser from 'phaser';
import {
createTheme,
HUDINI_KEY,
HudiniPlugin,
withHudini,
Alert,
} from 'hudini';
const theme = createTheme({});
type Theme = typeof theme;
class AlertDemoScene extends Phaser.Scene {
create(): void {
const hudini = withHudini<Theme>(this);
const { pw } = hudini;
// 1. Semantic variants â default color + icon per variant
new Alert({
scene: this, x: 400, y: 100,
variant: 'success',
text: 'Player saved!',
});
// 2. Override the variant's icon or color
new Alert({
scene: this, x: 400, y: 200,
variant: 'warning',
text: 'Low health',
leftIcon: 'heart-crack', // override the default
rightIcon: 'xmark', // "close" hint
});
// 3. Clickable
const alert = new Alert({
scene: this, x: 400, y: 300,
variant: 'error',
text: 'Tap to dismiss',
rightIcon: 'xmark',
onClick: () => alert.destroy(),
});
}
}