OverflowOverflow
UI Library

Notifications

Toasts that stack in a screen corner and dismiss themselves. Non-blocking: the export returns immediately.

Four notifications stacked in the top right: success, error, warning and info

notify

exports.of_ui:notify(data)
FieldTypeDescription
titlestring?Bold first line.
descriptionstring?Second line. At least one of title / description is needed for a useful toast.
typestring?info (default), success, warning, error. inform is accepted as an alias for info.
durationnumber?Milliseconds on screen. Falls back to the player's theme when omitted.
positionstring?top, top-right, top-left, bottom, bottom-right, bottom-left. Theme decides when omitted.
iconstring|table?Font Awesome icon name, overriding the one implied by type.
iconColorstring?Hex colour for the icon.
iconAnimationstring?Font Awesome animation, e.g. beat, fade, spin.
alignIconstring?top or center.
idstring|number?Reuses the toast with this id instead of stacking a new one.
styletable?Inline CSS applied to the toast.
soundtable?{ bank?: string, set: string, name: string }: played once as the toast appears.

Examples

exports.of_ui:notify({
    type = 'success',
    title = 'Vehicle stored',
    description = 'Sultan RS, Legion garage',
})

A warning that stays longer and plays a game sound:

exports.of_ui:notify({
    type = 'warning',
    title = 'Engine damaged',
    description = 'Repair it before continuing',
    duration = 8000,
    sound = { set = 'HUD_FRONTEND_DEFAULT_SOUNDSET', name = 'ERROR' },
})

Custom icon and accent, ignoring the type preset:

exports.of_ui:notify({
    title = 'New contract',
    description = 'Check the shop board',
    icon = 'file-signature',
    iconColor = '#6c63ff',
    iconAnimation = 'beat',
})

From the server

The client listens on of_ui:client:notify, so a server script can notify a player directly:

TriggerClientEvent('of_ui:client:notify', source, {
    type = 'error',
    title = 'Not enough money',
    description = 'You are $2,400 short',
})

sound is played client-side. If you send it from the server, the sound plays on that one player's machine only, which is normally what you want.

On this page