The component catalog
Your main reference is UI Kit › Components. Every component there is a live example with two buttons below it:
- Show code reveals the exact HTML of the example above it, so the two never differ.
- Copy puts that HTML on your clipboard, ready to paste into a page in
src/pages/.
The other UI Kit pages (charts, forms, pickers, upload, data tables and more) work the same way: each example comes with its code.
Component classes
These components work on any page — the styles are in assets/css/selaras.css and the shared behavior in assets/js/selaras.js, which every page already loads.
| Component | Main classes | Notes |
|---|---|---|
| Buttons | .sl-btn .sl-btn-primary .sl-btn-light .sl-btn-sm .sl-icon-btn .sl-linkbtn | Colors, sizes, icon-only and text-style buttons |
| Badges & status | .sl-status .sl-status--success .sl-chip .sl-kbd | Tones: success, warning, danger, info, neutral, secondary |
| Avatars | .sl-av .sl-stack .sl-person .sl-thumb | Initials, a group, an avatar with a name, image tiles |
| Alerts | .sl-alert .sl-alert--info data-sl-dismiss | Four tones; the close button removes the alert |
| Forms | .sl-field .sl-control .sl-help .sl-field-err .sl-addon | A label, the input, help text and an error message |
| Choices | .sl-choices .sl-check .sl-radio .sl-switch .sl-seg | Checkboxes, radios, switches, segmented control |
| Special inputs | .sl-input .sl-pass .sl-meter .sl-otp | Search, password with strength meter, one-time code |
| Cards & KPIs | .sl-card .sl-card-head .sl-card-title .sl-kpi .sl-kpi-value | Panels and statistic tiles |
| Tabs | .sl-tabs .sl-tabs-panel | Clicks and arrow keys handled by selaras.js |
| Tables | .sl-table-wrap .sl-table .sl-pager | Scrolls sideways on small screens |
| Progress & loading | .sl-progress .sl-spin .sl-skel | Bars, spinner, loading placeholders |
| Menus | .sl-menu | Skin for Bootstrap’s .dropdown-menu |
| Modals & toasts | .sl-modal .sl-modal-head .sl-modal-body .sl-modal-foot .sl-toast | Bootstrap modals and tooltips, styled |
| Empty states | .sl-empty | An icon, a message and actions |
The catalog has more: breadcrumb and pagination, accordion, list group, timeline, carousel, popover and offcanvas. Icons are Tabler Icons, written as <i class="ti ti-home"></i>. Bootstrap 5 is loaded on every page, so its grid and utility classes (row, col-md-6, d-flex, gap-3…) are available too.
JavaScript helpers
Three helpers are available on every page, from assets/js/selaras.js:
| Helper | What it does |
|---|---|
window.slChart | Draws ApexCharts charts that follow the active theme and the light/dark mode. |
window.slFmt | Formats numbers, money, dates and times in the page language. |
window.slI18n | Translates text written by your scripts. |
Charts — window.slChart
Charts use ApexCharts. Draw them through window.slChart and they take their colors from the active theme and redraw by themselves when the theme or the light/dark mode changes.
| Function | What it does |
|---|---|
draw(selector, factory) | Draws a chart into the element. The factory returns ApexCharts options and runs again on every theme change. |
base() | The shared look: font, axis and grid colors, no toolbar, no legend, no data labels. |
merge(a, b) | Deep-merges your options into base(). |
colors() | The current theme colors as hex values (series, text, lines, surface). |
tip(title, rows) | Builds a tooltip in the Selaras style for the tooltip.custom option. |
An example — a bar chart of orders per day. Add an element to your page:
<div class="sl-card">
<div id="chart-orders" role="img" aria-label="Orders per day, Sep 21 to Sep 27"></div>
</div> Then draw it from your page script (a file listed in the page’s "scripts" meta, which loads after selaras.js):
(function () {
var K = window.slChart, F = window.slFmt, _t = window.slI18n.t;
if (!K) return; // ApexCharts is not loaded on this page
var days = ['2026-09-21', '2026-09-22', '2026-09-23', '2026-09-24',
'2026-09-25', '2026-09-26', '2026-09-27'];
var orders = [42, 51, 47, 63, 58, 71, 39];
K.draw('#chart-orders', function () {
// series: C.primary, C.secondary, C.d3, C.d4
// interface: C.ink, C.ink3, C.ink4, C.line, C.lineStrong, C.surface
var C = K.colors();
return K.merge(K.base(), {
chart: { type: 'bar', height: 260 },
series: [{ name: _t('Orders'), data: orders }],
colors: [C.primary],
xaxis: { categories: days.map(function (d) { return F.short(d); }) },
yaxis: { labels: { formatter: function (v) { return F.num(v); } } },
tooltip: {
custom: function (o) {
var i = o.dataPointIndex;
return K.tip(F.date(days[i]), [
{ c: C.primary, n: _t('Orders'), v: F.num(orders[i]) }
]);
}
}
});
});
})(); Use the series colors in a fixed order — first primary, then secondary, then the third and fourth data colors — so the same kind of data keeps the same color across charts. UI Kit › Charts has 13 chart types built this way, each with its source.
ApexCharts and window.slChart are loaded on every page that has the sidebar (src/layout.html). The sign-in, error and store pages do not load them.
Numbers, money and dates — window.slFmt
Format every figure through window.slFmt instead of writing it by hand. It follows the page language: on the English pages money is in dollars with cents, on the Indonesian pages in rupiah without decimals, and dates and times use each language’s own order.
var F = window.slFmt;
// English Indonesian
F.money(1234.5); // '$1,234.50' 'Rp1.235'
F.num(5717); // '5,717' '5.717'
F.pct(12.4, 1); // '12.4%' '12,4%'
F.moneyShort(1500); // '$1.5k' 'Rp1,5rb'
F.date('2026-09-23'); // 'Sep 23, 2026' '23 Sep 2026'
F.short('2026-09-23'); // 'Sep 23' '23 Sep'
F.dayDate('2026-09-23'); // 'Wed, Sep 23' 'Rab, 23 Sep'
F.clock('2026-09-23T14:05'); // '2:05 PM' '14.05'
F.parse('1,234.50'); // 1234.5 — an amount typed in a field
F.parse(''); // null — empty field
F.parse('abc'); // NaN — not an amount Dates can be ISO text or Date objects. F.lang tells you the page language ('en' or 'id'), and F.cur the currency symbol. More helpers — int, bigMoney, monthYear, span, clockRange, hour, time, loose — are described in a short comment at the top of assets/js/selaras.js.
Text in scripts — window.slI18n
Text that your JavaScript writes goes through window.slI18n, so it can be translated. On the English pages it returns the text unchanged.
var _t = window.slI18n.t, _tn = window.slI18n.tn;
_t('Saved'); // 'Saved' (or its translation)
_t('Sent to {name}', { name: 'Ava' }); // placeholders are filled in
_tn(3, '{n} item', '{n} items'); // '3 items' (singular or plural)
window.slI18n.key('my-app-data'); // a storage key per language How translations are stored and added is described in Languages.
Ready-made widgets
Three widgets written for Selaras need no extra library. The date picker and the uploader each come with a script — add it to the page’s "scripts" meta; the toast needs only markup and a few lines of JavaScript.
Date picker
assets/js/sl-datepicker.js picks a single date or a range and works fully with the keyboard. Mark the field with data-sl-datepicker:
<div class="sl-field">
<label for="dueDate">Due date</label>
<div class="sl-dp" data-sl-datepicker data-min="2026-01-01">
<input class="sl-control" id="dueDate" type="text" autocomplete="off">
<button class="sl-dp-toggle" type="button" aria-label="Choose due date">
<i class="ti ti-calendar" aria-hidden="true"></i>
</button>
</div>
</div> data-mode="range"picks a start and an end date;data-minanddata-maxlimit the dates (ISO format).- The chosen date is stored as ISO text in
data-valueon the.sl-dpelement (data-startanddata-endfor a range), and the input fires achangeevent. - People can also type a date into the input; it is checked when the field loses focus.
- Fields that already exist are set up when the script loads. For a field you add later, call
window.slDatepicker.setup(element).
document.getElementById('dueDate').addEventListener('change', function (e) {
var picker = e.target.closest('[data-sl-datepicker]');
var iso = picker.getAttribute('data-value'); // '2026-10-06'
}); The demo pages set data-today to a fixed date so the examples always look the same. Leave it out and the picker uses the real date.
File upload
assets/js/sl-upload.js handles drag & drop or browse, checks type and size with a clear reason when a file is refused, and shows a progress bar and an image preview per file:
<div class="sl-upload" data-sl-upload
data-types="image/png,image/jpeg,application/pdf" data-max-mb="5" data-max-files="6">
<input class="visually-hidden" type="file" id="files" multiple accept=".png,.jpg,.jpeg,.pdf">
<label class="sl-upload-zone" for="files">
<span class="sl-upload-icon" aria-hidden="true"><i class="ti ti-cloud-upload"></i></span>
<strong>Drop files here or <span class="sl-upload-browse">browse</span></strong>
<small>PNG, JPG or PDF · up to 5 MB each</small>
</label>
<ul class="sl-upload-list"></ul>
</div> data-typeslists the allowed MIME types,data-max-mbthe size limit per file anddata-max-filesthe number of files. Each one is optional.- When a file finishes, the
.sl-uploadelement fires ansl-upload:doneevent with theFileinevent.detail. - For an uploader you add later, call
window.slUploadSetup(element).
No file leaves the browser. To send files to your server, replace the upload() function in sl-upload.js with your own fetch or XMLHttpRequest call.
Toast
A toast is a short message in the bottom corner, for example after saving. Place a container once on the page:
<div class="sl-toast-wrap" role="status" aria-live="polite">
<div class="sl-toast" id="myToast" hidden>
<i class="ti ti-circle-check" aria-hidden="true"></i>
<span id="myToastMsg"></span>
</div>
</div> The toast slides in when it gets the is-in class. A minimal function to show it for six seconds:
var toastTimer;
function showToast(msg) {
var el = document.getElementById('myToast');
document.getElementById('myToastMsg').textContent = msg;
el.hidden = false;
requestAnimationFrame(function () { el.classList.add('is-in'); });
clearTimeout(toastTimer);
toastTimer = setTimeout(function () {
el.classList.remove('is-in');
setTimeout(function () { el.hidden = true; }, 220);
}, 6000);
} There is no global toast function — each app keeps its own small one. For a version with an Undo button that pauses while hovered or focused, copy toast() from assets/js/ecommerce.js. For dialog-style toasts, UI Kit › SweetAlert shows SweetAlert2 styled to match.
Class names
- Every Selaras component class starts with
sl-. States use anis-class, such asis-inoris-done. - Give your own classes a prefix of your own (for example
app-). Then they can never collide with a Selaras or Bootstrap class, now or after an update. - Page-specific classes in Selaras carry a short page prefix after
sl-(for examplesl-cx-for the component catalog). Do the same when a page needs its own styles. - The skins for third-party libraries (FullCalendar, DataTables, Flatpickr and others) target the library’s own classes. Each one sits under its own heading comment in
selaras.css.
Accessibility
The components come with keyboard support and the right ARIA attributes, so you start from accessible markup:
- Tabs — arrow keys, Home and End move between tabs; only the selected tab is in the Tab order.
- Customizer options — the theme and mode choices behave as radio groups and work with the arrow keys.
- Alerts — closing an alert moves focus to the next element instead of the top of the page.
- Modals, dropdowns, offcanvas, tooltips and popovers use Bootstrap’s built-in keyboard and focus handling.
- Date picker — follows the WAI-ARIA date picker dialog pattern: arrow keys, Page Up/Down for months, Enter to pick, Escape to close.
- File upload — the real file input stays reachable with the keyboard, and results are announced to screen readers.
- Toasts are announced through an
aria-liveregion. - Charts have
role="img"and a text summary inaria-label; the charts in UI Kit › Charts can also be shown as a table. - Focus is always visible when you use the keyboard, animations are turned off when the system asks for reduced motion, and the text colors of all five themes meet WCAG AA contrast in light and dark mode.
When you build new markup, keep the same habits: give icon-only buttons an aria-label, mark decorative icons with aria-hidden="true" and connect every input to a <label>.