A custom component in UI Builder is a configured block you build once in Component Builder and then place on any page. Changes saved to the component reach all pages where it is used. A build can include properties, a layout, client state, scripts and event handlers, plus a controller inherited from the page it lands on.
What a custom component is for
Use a custom component when one part of a page, such as a heading, a list, a form or a row of buttons, should look and behave the same on several pages. A page collection covers the other case: reusing a whole layout, a set of tabs, or a full-page variant built for different users or workflows. The distinction decides where a later fix lands. Correct a component once and each page using it picks up the change. Correct a page collection and you are correcting the arrangement it carries.
Components built in one instance stay there until you move them with update sets or application installations, so plan that move early.
Choosing between Component Builder and NOW CLI
Component Builder is a visual, drag-and-drop tool inside UI Builder. The NOW CLI route is code-first. Both produce components that appear in the toolbox and can be reused, and a change to an included component can affect either kind.
| Factor | Component Builder | NOW CLI |
|---|---|---|
| Working style | Visual, drag-and-drop | Custom HTML, CSS and JavaScript |
| Good fit | Simple to moderately complex components | Complex, highly customized components |
| Storage | Macroponent Components in the sys_ux_macroponent table | Components in the sys_uib_toolbox_component table |
| Typical builder | Someone who prefers a visual interface | A developer who writes the component code |
NOW CLI components are built with the ui-component extension to the ServiceNow CLI. Check that your target page type is supported before choosing this route.
Building a component step by step
The stopwatch example builds a component that shows elapsed time with start and stop buttons. The steps below apply the same logic to any component with a few properties and some behavior.
Create the shell and its properties
Sign in with the ui_builder_admin role, open All, then Now Experience Framework, then UI Builder. Select Create, then Component. The name is internal but also appears in the toolbox, the category helps people find the component, and the description should say when to use it. Create opens Component Builder. Add a property in the Properties and policy section, choose a type such as String, and set the label, property ID and default value.
Lay out the content tree
Add a single column, place a Card Base Container in its first column, put a Flexbox layout inside the card, and add the visible elements inside the flex container. Wrappers control how their children sit, so layout changes can stay at the wrapper level instead of touching each element.
Add client state and bindings
Client state parameters sit in the Data and scripts section. Each has a name, a type (Number, String, JSON or Boolean) and an initial value. To bind one, select the bind icon beside a field, open the Client states tab, and double-click the state pill. The stopwatch needs a start time, a formatted elapsed-time string, a running flag and an interval identifier.
Show controls conditionally
A conditional renderer decides which element appears. Add a condition with a single Button iconic, give it a label and a component ID, then set its icon, variant, size and tooltip. Add a second condition, an empty container that renders when the running flag is true, and place the stop button inside it. Conditions run from the top down, so the running condition must sit above the start condition. If the wrong button shows, check the order first.
Write client scripts and wire the events
Add a client script with the plus control beside Client scripts. Each script exposes a handler that receives api and helpers objects. Read state through api.state, write it with api.setState, and use the timing helpers to start and clear the interval. Store the interval identifier in state so a later script can stop the same timer. Initialize undefined state in the first script, as the sample Start script does. Then open the button’s Events tab, add a handler under Button iconic clicked, choose the script, and save. Preview the result, and the component appears in the toolbox. For a navigation call made from a script, see the client script API navigate guide.
Inheriting controllers from the page
A component can keep its data resources internal, or inherit them from the page it lands on. Inheritance scans the page for data resources of the same type and connects without manual setup. The outcome depends on what the scan finds:
| Matching resources on the page | What the component does |
|---|---|
| None | Creates a new resource using the component’s initial configuration |
| One | Connects to that resource |
| Several | Connects to the first instance found |
To set it up, add a List Controller data resource, open Advanced configurations, and enable Inherit configurations from parent. One worked case is a text component that joins literal words with the list controller’s table label output. Placed on a list page, it names that page’s table. With more than one list controller on a page, the component attaches to the first one, so order the controllers deliberately.
Presets and repeaters inside a component
Presets and repeaters change how a built component behaves once it sits on a page. They solve different problems.
Presets apply configuration automatically
A preset applies predefined property values and event mappings to components that support presets. Create one through Create, then Preset, selecting the component and its controller. In the preset window, enter controller test values, set the properties, drag controller data onto the fields, optionally add events, and save. When a page comes from a template, or already holds the controller, the default preset applies. Overriding a preset value with the lock icon makes that setting your responsibility to maintain, and the reset option restores the defaults. Sub-pages cannot use presets, because they do not inherit controllers.
Repeaters repeat components across data
A repeater repeats its children once for each item in a data array, which can be a plain list or a list of objects. Inside the repeater, read each item through @item.value followed by the property name. Components inside a repeater repeat per item even when their output is static, so a heading with a fixed label shows the same text each time. Bind the label to the item instead. The worked case pulls up to five Incident records through a look-up data resource, binds the repeater to the results, and binds a heading to each item’s display value.
Testing, duplicating and styling
Test values supply simulated values for required and optional URL parameters, so bindings and data resources can be checked before placement. For other problems that show up during testing, see the UI Builder troubleshooting guide.
Duplicate a configured component by right-clicking it and selecting Duplicate, or by pressing cmd+D on a Mac or ctrl+D on Windows. The copy lands below the original with the same properties, bindings and events, except its name and ID. Duplicating a tabs component also copies its tabs, with unique names and IDs. The role is ui_builder_admin or admin.
Styles live on the Styles tab for the body, column layouts, columns and components. Options include Background, Border, Layout, Shadow, Sizing and Spacing, plus a View and edit CSS link. Some built-in component styles cannot be overridden with CSS in UI Builder. A style change applies to the component or wrapper you select, so style a wrapper when several components should share the same change. If edits do not appear on the stage, use Developer, then Reload Stage. That refreshes the view without saving, so select Save at the top right afterwards.
Governance and upgrade safety
Component Builder has no governance features. Teams can build near-duplicates with slight variations, and the experience fragments over time. Run regular audits and keep cross-team communication going. For the wider governance picture, see the UI Builder governance model. On upgrades, components are designed to be upgrade safe when their security policy is read_only, which gives larger components and page partials more protection than bundles or page templates. Out-of-the-box components may not be editable for that reason, so customize through your own components.
Frequently asked questions
Does editing a custom component change the pages already using it?
Yes. Changes made in Component Builder update on all pages where the component is used, so check the effect on those pages before you save.
Can I use a custom component in another instance?
Not directly. It stays in its creating instance until you migrate it with update sets or application installations.
When should I pick a custom component over a page collection?
Pick a custom component for one piece of a page that repeats across pages. Pick a page collection for a whole layout, a tab set or a variant built for different users.
Why does a conditional button not appear?
Conditions are evaluated from top to bottom, so an earlier condition can hide the one you expected to show. Move the running condition above the start condition, reload the stage and test again.
Related reading: UI Builder overview and workspace guides, layouts and component composition, data resources, controllers and event handlers, and how a UI Builder page is put together.