Upgrade Your Oracle APEX UI with This Free Toggle Switch Plug-in

APEX Plug-in PL/SQL ⭐ View on GitHub

Segmented Toggle Switch for Oracle APEX: One Plug-in, Any Number of Options

A List-of-Values-driven item plug-in that renders a segmented switch — two options, three, or five, all from the same component.

📅 August 2026 👤 Sajjad Hanifa ⏱ ~8 min read 🏢 S&H Software Solutions

Hi everyone, welcome back to another Oracle APEX tutorial. Today I want to show you a small item plug-in I built after running into the same limitation on a few different projects: the native APEX switch is a great component, but it only ever gives you two fixed values.

Most of the time that's fine. But every so often you need a choice rather than a switch — three delivery tiers, three priority levels, or in the example I'll use throughout this post, a login duration with two options that could just as easily grow into three. So I built a Toggle Switch plug-in that is driven entirely by a List of Values and renders one segment per entry — the exact same plug-in covers a simple yes/no just as comfortably as a five-way choice.

💡
Note: The plug-in is MIT licensed, free, and open source — download it on GitHub. Zero external dependencies: no icon fonts, no JS libraries, no database objects. Everything ships inside a single export file.
Toggle switch showing One-Time Login and Remember 1 Year segments
The segmented Toggle Switch — two options, LOV-driven segments.

How It Works

The plug-in is a single render procedure plus a small client-side script. Together they handle everything from reading your LOV to writing the selected value back into session state.

LOV Queryapex_plugin_util.get_data fetches the display/return pairs from your Static Values, SQL Query, or Shared LOV
HTML Render — one <span> segment is generated per LOV entry, with the matching one marked active
Click / Keyboard — clicking, or pressing Enter/Space on a focused segment, slides the knob and updates the hidden input
Session State — a native change event fires on selection, so the value submits normally and Dynamic Actions on Change work without extra wiring

Attributes at a Glance

AttributeTypeDefault
1  Background ColorText#eef0f3
2  Toggle ColorText#3a6df0
3  Border ColorTextrgba(0,0,0,0.08)
4  Border ThicknessNumber1

All four are optional — leave any of them empty and the default applies automatically, so the plug-in works out of the box with zero configuration.


01
Step One
Import the Plug-in
Shared Components → Plug-ins → Import

Download the export file, item_type_plugin_sh_toggle_switch.sql, from the GitHub repository. In your target application, go to Shared Components → Plug-ins → Import, select the file, set File Type to Plug-in, click Next twice, then Install Plug-in. Once imported, Toggle switch appears in your plug-in list — the CSS and JavaScript install automatically, there's nothing to upload separately.

⚠️
Tip: Use "Download raw file" rather than copy-pasting the SQL into an editor and saving — that can alter line endings and break the import.

02
Step Two
Create the Page Item
Identification → Type = Toggle switch

Right-click the region in the rendering tree and choose Create Page Item. Give it a name — for example P1_AUTO_LOGIN_YN — and under Identification → Type, select Toggle switch. All of the plug-in's custom attributes then appear right alongside the standard item settings.

Page Item settings panel with Type set to Toggle switch, Color Settings and Border Settings
The Page Item editor — Type, Color Settings, Border Settings and List of Values all in one place.

03
Step Three
Define the List of Values
Static Values · SQL Query · Shared Component

This is the step that decides how many segments render. Under List of Values → Type, pick one of the three supported sources. The first column is the label shown inside the segment; the second is the return value written to session state.

static — List of Values
STATIC:One-Time Login;NO,Remember 1 Year;YES
sql — SQL Query
SELECT 'One-Time Login'  AS d, 'NO'  AS r FROM dual
UNION ALL
SELECT 'Remember 1 Year' AS d, 'YES' AS r FROM dual

Already maintaining the values as a shared List of Values? Select it here instead — that's exactly what the screenshot in Step 2 shows.


04
Step Four
Configure the Appearance
Color Settings · Border Settings — all optional

All four appearance attributes are optional. Leave any of them empty and a sensible default is applied automatically. Color fields accept hex, RGB, RGBA, or named colors, with a native color picker next to each one.

AttributeExampleEffect
Background Color#cfb9b9The track behind the segments
Toggle Color#d37c93The sliding knob marking the selection
Border Color#050404Outline around the track
Border Thickness2Border width in pixels, clamped 0–99

05
Step Five
Set the Width
Standard APEX item Width setting

Sizing follows the standard APEX item width setting — there is no custom width attribute. Height scales with the larger widths too, because a wide but thin segmented switch looks visually unbalanced; Stretch is the exception, since it grows only in width.

APEX SettingWidthHeight
Default200px34px
Large300px42px
X-Large400px50px
StretchFills the container34px

06
Step Six
Set a Default Value
Default → Type = Static

A switch should always show a selection. Under Default → Type, choose Static and enter one of your return values, for example YES.

Result: If no default is set and session state is empty, the plug-in falls back to selecting the first segment and writes that value into session state on load — so the visible selection and the submitted value never disagree.

Seeing It on a Real Page

Here's the same toggle used as an auto-login duration selector on a login page. Clicking a segment slides the knob and fires a native change event, so any Dynamic Action bound to the item's Change event works without extra wiring.

Animated toggle switch sliding between One-Time Login and Remember 1 Year on a login form
The knob sliding to the clicked segment on a login page.
Login page using the toggle switch as an auto-login duration selector
Used as an auto-login duration selector, with emoji labels for a quick visual cue.

The labels support emoji, which is a cheap way to add meaning to a segment without pulling in an icon font — the 🔒 and 🛡️ prefixes above are plain text in the LOV.


Troubleshooting

Clicking does nothing — the JavaScript didn't load. Check the console for shToggleSwitch is not defined and re-import, confirming the export still includes the file under Files
Segments have no styling — same root cause, but for the stylesheet. Filter the Network tab for toggle_switch.css to confirm it's fetched
Labels are cut off — too many segments for the current width. Increase the width, enable Stretch, or shorten the labels
Nothing selected on load — session state holds a value matching no LOV return value, often a case mismatch such as Yes vs. YES. Return values compare exactly

Final Thoughts

The Toggle Switch plug-in is a small piece, but it closes a real gap in Oracle APEX's native item set: a switch that isn't limited to two values. Because it's entirely LOV-driven, the same plug-in serves a plain yes/no today and a five-way choice tomorrow, with nothing more than an LOV change in between. Import it once, wire up a List of Values, and from there it behaves exactly like any other page item — session state, Dynamic Actions, and all.

It ships under the MIT license, has zero external dependencies, and the full source — PL/SQL, CSS, and JavaScript — is kept readable in the GitHub repository alongside the packaged plug-in export. Grab it, star it if it's useful, and open an issue if you hit a bug. Happy coding! 🚀

SH
Sajjad Hanifa
Software Developer · S&H Software Solutions · Oracle APEX Plug-in Development
Oracle APEX Plug-in PL/SQL JavaScript UI/UX Item Type List of Values

 {fullWidth}

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

نموذج الاتصال