October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DocumentaryTube
CSS

How to Customize Stream Alerts with CSS and JavaScript

A practical guide to customizing StreamElements AlertBoxes with HTML, CSS, and JavaScript, choosing event variables, and testing the finished alert in your broadcast software.

By DocumentaryTube Team 5 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In StreamElements, add an AlertBox to an overlay, open the settings for the alert type you want to change, enable custom code, then edit its HTML, CSS, and JavaScript in the Overlay Editor’s Code Editor. Use the documented template variables for event details, and test the finished alert in your streaming software—not only in the editor preview. The steps and variable names below are specific to StreamElements; other platforms may offer different customization tools.

Customize a native StreamElements AlertBox

  1. Create an overlay. In StreamElements, open the Overlay Editor and create an overlay at the resolution you intend to use. The official Getting Started with Overlays guide covers the setup and adding widgets.
  2. Add an AlertBox. Add the native AlertBox widget to the overlay. It displays live events from a queue.
  3. Choose the event type. Open the AlertBox options and select the relevant event tab, such as Followers. Custom code is enabled separately for the alert type you are editing.
  4. Enable custom code and edit it. Toggle “Enable custom CSS” for that event type, then use the Overlay Editor’s Code Editor to edit the alert’s HTML, CSS, and JavaScript. The exact controls can change; consult the current official setup guide if labels differ.

HTML defines the alert’s elements, CSS controls their appearance and animation, and JavaScript can coordinate behavior or respond to widget events. Keep the markup and selectors specific to the alert type so that an event’s content and styling do not unintentionally affect other alerts.

Use the right event data in the alert

AlertBox templates provide inline variables, but the available values depend on the event. The StreamElements custom-code reference documents these examples:

  • {{name}} identifies the person associated with an event.
  • {{amount}} provides an amount for event types that support one; {{currency}} provides a tip’s currency, and {{tier}} can identify a subscription tier.
  • {{sender}} identifies the sender for a gifted subscription.
  • {{message}} and {{messageRaw}} provide user-message values where supported.
  • {{image}}, {{video}}, and {{audio}} are media URLs.
  • {{widgetDuration}} is the configured duration in seconds.

Use only variables relevant to the selected event, and check the current reference rather than assuming every event supplies the same fields. If JavaScript uses setTimeout to hide or remove an alert, convert the seconds-based duration to milliseconds: for example, multiply {{widgetDuration}} by 1000 before passing it as the timer delay.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Style and animate the alert with CSS

Use CSS for typography, color, spacing, positioning, transitions, and keyframe animations. Start with a layout that fits the overlay’s canvas, then verify it at the resolution used by your broadcast scene. A responsive width and sensible wrapping help prevent long names or messages from running beyond the alert area.

  • Use the classes and elements present in your alert markup; avoid selectors based on guessed platform internals.
  • Check both short and long names and messages for wrapping, clipping, and overlap.
  • Make animation and exit timing fit the configured alert duration so content does not disappear too early or remain after the alert ends.

Use JavaScript when the behavior needs it

For a native AlertBox, JavaScript is useful for behavior beyond styling, such as coordinating an animation with event data. Keep DOM handling minimal and test names, messages, and special characters. StreamElements’ documentation does not establish a platform-specific sanitization guarantee, so do not assume that arbitrary input is safe to treat as HTML.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

If the design requires a general-purpose widget rather than a native AlertBox, StreamElements also provides a Custom Widget with HTML, CSS, JavaScript, and configurable JSON fields. Its JavaScript can respond to onWidgetLoad for field or session information and onEventReceived for event information, including an event listener type and payload. See Your First Custom Widget and Widget Structure & Custom Fields for the editor and event model.

Custom Widget code runs in a protected sandbox. StreamElements documents limitations including no access to cookies, console.*, or IndexedDB storage. Session-data keys may change, so rely on the current reference rather than undocumented payload shapes. External libraries can be included, but dependency availability and behavior can change; avoid them unless they are necessary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Test in the actual broadcast scene

An editor preview is useful for checking the basic design, but it does not confirm the complete browser-source rendering in your streaming software. Test representative alert events in the destination scene before broadcasting. Confirm the alert appears in the intended position, fits the source dimensions, displays event data correctly, and remains visible for the intended duration. For long names or messages, check wrapping and visibility at the scene’s actual canvas size.

When Streamlabs may be a better fit

If you prefer ready-made alert visuals over writing CSS and JavaScript, Streamlabs documents an Alert Box workflow with setup settings, test controls, browser-source URLs for OBS and other software, event filtering, and a theme library with free and premium choices. Its theme workflow is a preset-oriented alternative, not the same thing as editing a StreamElements AlertBox’s code. Follow the current Streamlabs alert setup guide for that platform’s steps.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2Ă— USB C male to USB A female adapters and 2Ă— USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common alert problems

  • The alert appears without the expected name or amount: Confirm you are editing the correct event tab and use variables documented for that event. The available values vary by event type.
  • The alert looks right in the editor but not in OBS or another streaming app: Test the browser source in the actual scene and check its size, placement, and visibility against the overlay canvas.
  • Long text is clipped or overlaps the design: Adjust the CSS width and wrapping behavior, then test with long names and messages at the broadcast scene’s resolution.
  • The alert disappears too soon or lingers: Compare the animation timing with the configured widget duration. If using setTimeout, convert the seconds value to milliseconds.
  • Custom Widget JavaScript cannot access a browser feature: Check the documented sandbox limitations; cookies, console.*, and IndexedDB are unavailable to widget code.
  • An external script or session field stops working: Recheck the current StreamElements references. External dependency behavior can change, and session-data keys are not guaranteed to remain stable.

Or let it run in the cloud

Customizing an alert changes what viewers see; it does not keep a YouTube channel broadcasting continuously. For a prerecorded-video stream that should remain live, StreamNeo is a separate cloud service: upload a recording or build a playlist, add your YouTube stream key, and go live. It loops uploaded videos to YouTube, not a live camera feed.

  • Your computer and home connection do not have to stay on.
  • Any quality up to 4K 60fps streams as uploaded at one flat price per slot, without re-encoding or quality tiers.
  • StreamNeo automatically recovers if YouTube drops the stream.
  • The first day is free with no card required; it is one free day per account.

The monthly option is $9.99 per month. Start your free day with StreamNeo.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Screening Room

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.