TopbarPlus

repository·main·Indexed 42 days ago

https://github.com/1foreverhd/topbarplus

A Roblox library for creating and managing custom UI elements, buttons, and menus within the Roblox topbar. It features a chainable API for configuring icons via Icon.new(), support for dropdowns and horizontal menus, notification bubbles, and built-in gamepad and console support. Developers can bind GuiObjects or KeyCodes to icons and customize themes globally or per-icon.

Tokens
7.4K
Snippets
32
Records
45
Agent score
53%

What's inside TopbarPlus

  1. Overview of TopbarPlus

    main
    TopbarPlus is a library for Roblox developers that allows for the creation of custom, highly customizable buttons and elements in the Roblox topbar. It provides a way to manage UI elements that sit at the top of the screen, typically used for game menus, settings, or player actions, with a focus on ease of use and visual consistency.
  2. Use icon states to change appearance based on selection or hover

    main

    Methods tagged with toggleable in the API allow you to specify an iconState to apply a value only during specific interaction states. If no state is provided, the value applies to all states.

    Supported states (case-insensitive):

    • "Deselected": Applies when the icon is not pressed.
    • "Selected": Applies when the icon is pressed.
    • "Viewing": Applies when a cursor hovers over, a controller highlights, or a mobile user long-presses the icon (before release).
    -- Example: Changing labels based on state
    Icon.new()
        :setImage(4882429582)
        :setLabel("Closed", "Deselected")
        :setLabel("Open", "Selected")
        :setLabel("Viewing", "Viewing")
  3. Gamepad and Console Support

    main

    TopbarPlus includes built-in support for gamepads and consoles. Users can navigate the topbar via a virtual cursor or by pressing DPadUp to highlight the last-selected icon (or the leftmost icon if none are selected).

    To change the default trigger keycode from DPadUp, use:

    Icon.highlightKey = Enum.KeyCode.NEW_KEYCODE
  4. Create Dropdowns, Menus, and Fixed Menus

    main

    Organize multiple icons into navigation structures:

    Vertical navigation frames containing an array of icons. Note: Icons containing a dropdown can join other menus, but they cannot be placed inside other dropdowns.

    Icon.new()
        :setLabel("Example")
        :setDropdown({
            Icon.new():setLabel("Category 1"),
            Icon.new():setLabel("Category 2")
        })

    Horizontal navigation frames containing an array of icons.

    Icon.new()
        :setLabel("Example")
        :setMenu({
            Icon.new():setLabel("Item 1"),
            Icon.new():setLabel("Item 2")
        })

    Fixed Menus

    Similar to normal menus, but they are forcefully opened (selected) by default, and the close button is hidden.

    Icon.new()
        :setFixedMenu({
            Icon.new():setLabel("Item 1"),
            Icon.new():setLabel("Item 2")
        })
    -- Dropdown Example
    Icon.new()
        :setLabel("Example")
        :modifyTheme({"Dropdown", "MaxIcons", 3})
        :modifyChildTheme({"Widget", "MinimumWidth", 158})
        :setDropdown({
            Icon.new():setLabel("Category 1"),
            Icon.new():setLabel("Category 2")
        })
  5. Using multiple TopbarPlus packages in a single experience

    main

    TopbarPlus is designed to support multiple Icon packages within a single Roblox experience without conflicts, provided all packages are version v3.0.0 or above.

    When a new TopbarPlus package is required, it automatically checks if a TopbarPlus instance has already been initialized in the experience. If an instance is found, the new package cancels its own loading process and refers to the existing, already-initialized package. This mechanism ensures that third-party libraries or plugins using TopbarPlus do not interfere with your own implementation.

  6. Handle icon overflows

    main

    To prevent icons from overlapping on smaller screens or mobile devices in portrait mode, TopbarPlus uses an overflow system.

    • Left-set or right-set icons will trigger an overflow if they exceed the boundary of the closest opposite-aligned icon or the viewport.
    • If a center-aligned icon exceeds the bounds of another icon, its alignment will automatically switch to match the alignment of the icon it exceeded.
  7. Install and create a basic icon with TopbarPlus

    main

    To use TopbarPlus, require the Icon module from ReplicatedStorage within a LocalScript (typically placed in StarterPlayerScripts). Calling Icon.new() constructs an empty 32x32 icon on the topbar.

    By default, icons are ordered based on their construction sequence using the formula 1+(totalCreatedIcons*0.01). Icons created earlier have a lower order and appear further to the left.

    -- Within a LocalScript in StarterPlayerScripts
    local Icon = require(game:GetService("ReplicatedStorage").Icon)
    local icon = Icon.new()
  8. Configure icon appearance using method chaining

    main

    You can customize an icon's appearance by using setImage(imageId) and setLabel("Label"). These methods are chainable, allowing you to configure the icon in a single statement.

    To perform logic on an icon during the construction chain, use the :call(function(icon) ... end) method. This passes the icon instance as the first argument to your function.

    -- Using method chaining
    Icon.new()
        :setImage(imageId)
        :setLabel("Label")
    
    -- Using :call to act on the icon during construction
    Icon.new()
        :setName("TestIcon")
        :call(function(icon)
            print(icon.name) -- Prints 'TestIcon'
        end)
  9. Install TopbarPlus via the Roblox Model

    main

    The recommended installation method is to use the official Roblox model.

    1. Take the TopbarPlus model.
    2. In Roblox Studio, open the Toolbox and navigate to Inventory -> My Models.
    3. Insert the model into your game and place it anywhere within ReplicatedStorage or Workspace.

    Updating the model: Since TopbarPlus is a package, you can update it without re-adding it. Right-click the Icon module and select an option like 'Get Latest Package'. You can also enable 'AutoUpdate' within the PackageLink to receive automatic updates.

    Important Notes:

    • Do not modify code inside the Icon package, as this will break the package link.
    • Roblox Package Support: As of June 7th, 2025, if Roblox public packages have not been fully rolled out in your environment, attempting to use 'Get Latest Package' will throw an error.
    # No code snippet provided for manual model insertion, but the process is via Roblox Studio UI.