Skip to content

View

Source: shiva-core/client/cl_view.lua

NUI host controller. Manages mouse focus and sends messages to the React NUI app via SendNUIMessage.

Client only

View is a client-side global injected by shiva-core. It is not available on the server.

Availability

View is a global in every shiva module running client-side. No import required.

Focus

View.focus(state, cursor?)

Show or hide mouse cursor focus for the NUI. cursor defaults to true when state is true.

lua
View.focus(true)   -- show cursor + enable NUI input
View.focus(false)  -- hide cursor + disable NUI input

View.isFocused()

Returns true if the NUI currently has focus.

lua
if View.isFocused() then ... end

Notifications

View.notify(opts)

Show a notification in the NUI overlay layer.

lua
View.notify({ message = 'Item added', type = 'success', duration = 3000 })
View.notify({ message = 'Not enough cash', type = 'error' })
FieldTypeDefaultDescription
messagestringNotification text
typestring'info''success' | 'error' | 'warning' | 'info'
durationinteger3000Display time in milliseconds

Progress Bar

View.progress(opts)

Show a progress bar.

lua
View.progress({ label = 'Fishing...', duration = 5000, color = '#e63946' })

View.progressEnd()

Dismiss the progress bar immediately.

lua
View.progressEnd()

Context Menu

View.contextMenu(opts)

Show a context menu and give NUI focus.

lua
View.contextMenu({
    items = {
        { label = 'Buy', value = 'buy' },
        { label = 'Sell', value = 'sell', icon = 'cash' },
    }
})

View.contextMenuClose()

Hide the context menu and release NUI focus.

lua
View.contextMenuClose()

Modals

View.modalShow(id, opts)

Show a modal by ID, passing arbitrary data to the NUI.

lua
View.modalShow('shop', { title = 'Fish Market', items = items })

View.modalHide()

Hide the current modal.

lua
View.modalHide()

Released under the MIT License.