Skip to main content
The $sleek object is the global entry point for programmatic control over the Sleekplan widget. It exists as soon as the install snippet has run, and every method below is callable on it. For identifying users see User setup, for load-time globals see Configuration, for reacting to widget activity see Events, and for survey and announcement prompts see Popups.
Call methods after the SDK has initialized. The safest hook is the sleek:init event, which fires once the widget settings have loaded: document.addEventListener('sleek:init', function () { /* $sleek is ready */ }). See Events.

Method reference

Widget controls

Open the widget

$sleek.open(view, callback) opens the widget. Without arguments it opens the home screen. Pass a view string to jump straight to a screen, plus an optional callback that runs once the view has rendered and the panel is visible.
Dots in the view string are path separators, so feedback.48121 resolves to the /feedback/48121 route inside the widget. You can also pass an object with a page key, which is what the data-sleek-* HTML triggers use internally:
A query string on the view is passed through to the widget route untouched. That is how showPopup() hands a custom title and payload to a popup, and you can use the same form directly.
The SDK also reads the page URL on load. If the hash contains sp-item, it opens that feedback item automatically, which makes feedback items shareable from anywhere in your app.

Close the widget

$sleek.close() hides the widget and returns the launcher button. The widget stays on the page, so reopening it is instant. Pass true to skip the closing animation, which is useful when you are closing in response to something else appearing.

Toggle the widget

$sleek.toggle(view) alternates between open() and close(). The optional view is used only when the widget is currently closed.

Show a compact panel

$sleek.showTiny(type) opens a small panel positioned next to your data-tiny-changelog trigger element instead of the full side panel. If no trigger element is on the page, the panel falls back to the widget’s configured position.
string
default:"changelog"
changelog or feedback.
showTiny() returns false and does nothing while the full widget is already open. Close it first.

Expand the panel

$sleek.expandView(expanded) switches the open widget between the standard panel and a wider one. Below 730px viewport width the expanded panel becomes full screen.
If the user has collapsed the panel themselves, that preference is remembered and expandView(true) respects it rather than overriding them.

Set the color theme

$sleek.setTheme(mode) changes the widget’s color theme for the current page load, overriding the theme configured in your workspace. Use it to keep the widget in step with a theme toggle in your own product.
string
default:"device"
light, dark, or device. Any other value is treated as device.
It works both before and after the widget has been opened: called early, the theme is queued and applied when the widget mounts. The change is not persisted, so the workspace setting applies again on the next page load.

Show and hide the launcher button

Use hideButton() when you drive the widget entirely from your own UI. To keep the launcher from ever being built, set enable_button: false in window.SLEEK_SETTINGS instead, which avoids a brief flash of the default button.

Shut down the SDK

$sleek.shutdown() signs the current user out, then, one second later, removes the launcher, the widget iframe, and the capture tool iframe from the page and releases the singleton.
shutdown() cannot be undone within the page load, and it does not remove event listeners you registered with on(). To bring the widget back, reload the page.

Read session state

$sleek.get(path) returns the notification counts and the signed-in user as the SDK currently knows them. Called without arguments it returns the whole object; pass a dot path to read one value.
user.user_id and user.data are both false while no user is signed in. Counts are 0 until the first session response arrives, so read them from a sleek:init handler rather than immediately after the snippet.

Capture a screenshot

$sleek.loadTool('capture', callback) opens Sleekplan’s full-screen capture tool over your page, hiding the widget while it runs. The callback receives the result once the user finishes or an empty object if they cancel. This is the same tool the widget’s own attachment button uses.
string
image for a screen capture.
string
The capture as a JPEG data URL, ready to attach to a form or upload.
string
default:"capture"
capture is the only supported tool.

HTML attributes (no-code triggers)

Widget triggers

Add these attributes to any clickable element to open the widget on click. The SDK binds the first matching element for each attribute, so use one trigger of each kind per page.

Badge counters

Attach these attributes to any element and the SDK keeps its unread count up to date.
The SDK writes the number into the element’s data-count attribute and removes the attribute when the count is zero, so [data-count]::after is the hook to style. To suppress badge counts entirely on a page, use session.skip_notifications.

SPA support and rebinding

The SDK patches history.pushState and listens for popstate, so it rebinds the HTML triggers and refreshes badge counts on client-side navigation, and it re-runs the session ping whenever the URL changes. If you render trigger or badge elements after that point (inside a modal or a lazily mounted component, for example), call $sleek.rebind() once they are in the DOM.

Dispatch your own events

$sleek.push_trigger(name, detail) dispatches a sleek:{name} CustomEvent on document, with detail as its payload. It is the same mechanism the SDK uses internally, so anything listening through $sleek.on() receives it. Use it to route your own signals through one channel.

Version

Configuration

The window.SLEEK_* globals, session flags, and storage behavior.

User setup

Identify users with setUser() and attach metadata.

Events

Every event the SDK emits and the payload each one carries.

Popups

CSAT, NPS, feedback, and announcement prompts.