Skip to main content

Installation

To enable the ox_lib library inside of your resource, add @ox_lib/init.lua as a shared_script in your fxmanifest.lua file:
fxmanifest.lua
Make sure ox_lib is started before any resources that depend on it in your server.cfg!

Building the UI

For advanced UI building with ox_lib, please visit the official documentation:

Context Menus

Context menus provide an intuitive way to display multiple options to players.

Registering a Context Menu

Use lib.registerContext to define a menuโ€™s structure:
  • title string - The display text for the option
  • description string (optional) - Additional information shown below the title
  • icon string (optional) - Font Awesome icon class (e.g., 'fa-solid fa-box')
  • iconColor string (optional) - Hex color for the icon (e.g., '#C53030')
  • event string (optional) - Client event to trigger when selected
  • serverEvent string (optional) - Server event to trigger when selected
  • onSelect function (optional) - Function to execute when selected
  • args any (optional) - Arguments to pass to the event/function
  • arrow boolean (optional) - Shows an arrow indicator
  • menu string (optional) - ID of another menu to open
  • disabled boolean (optional) - Greys out and disables the option
  • metadata table (optional) - Additional data displayed on the right side

Showing a Menu

Display a registered menu using lib.showContext:

Complete Example


Notifications

Custom notifications with extensive styling options.

Client-Side Notifications

Server-Side Notifications

Notification Properties

  • title string (optional) - The notification title
  • description string - The main notification message
  • type string - Type of notification: 'success', 'error', 'warning', 'info'
  • icon string (optional) - Font Awesome icon class
  • iconColor string (optional) - Hex color for the icon
  • iconAnimation string (optional) - Animation: 'spin', 'shake', 'beat', 'fade', 'bounce'
  • duration number (optional) - Duration in milliseconds (default: 5000)
  • position string (optional) - Position: 'top', 'top-right', 'top-left', 'bottom', 'bottom-right', 'bottom-left', 'center-right', 'center-left'

Notification Types Examples


Input Dialogs

Request user input with customizable forms.

Basic Input Dialog

Multi-Field Input

Input Types

Text Input:
Number Input:
Select Dropdown:
Multi-Select:
Checkbox:
Textarea:
Date Picker:
Time Picker:

Progress Bars

Display progress for actions.

Basic Progress Bar

Progress with Animation


Localization

Text elements support multi-language via locale files.

Setup Localization

  1. Add to fxmanifest.lua:
  1. Create locale files (e.g., locales/en.json):
  1. Use in code:
Always use locales for multi-language support! Make sure to call lib.locale() at the top of your script if needed.

Alert Dialogs

Simple confirmation dialogs.

Useful Utilities

Request Model

Request Animation Dictionary


Best Practices

Use context menus for multiple options: They provide a better UX than command-based systems
Always validate user input: Never trust client-side input on the server without validation
Use locales from the start: Itโ€™s easier to add translations early than to retrofit them later

Performance Tips

  1. Request resources once: Donโ€™t request the same model/animation repeatedly
  2. Clean up resources: Always call SetModelAsNoLongerNeeded and RemoveAnimDict
  3. Use progress bars for long actions: Improves player experience
  4. Cache frequently used data: Donโ€™t query the same data repeatedly

For more advanced features, visit the official ox_lib documentation: https://overextended.dev/ox_lib