How to Build an OTP Input: One Real Input or One per Digit
A verification code field usually looks like a row of boxes, one per
character. There are two ways to build it. You can render one <input> per
box and move the focus from box to box, or you can render one real <input>
and draw the boxes underneath it from its value and its selection.
The two look the same, but they are not the same amount of work. A field per digit splits one value over six editors, so it has to rebuild, box by box, how text is replaced, composed, undone and autofilled, and a screen reader meets six fields instead of one. A single input keeps the browser’s editing model, the undo history of the edits that go through it, and one name for the whole code; the script still handles the slot selection, IME composition and text inserted several characters at once. This guide compares the two models, then builds the single input with that short list.
How to Build a Controlled Accordion on the Details Element
The <details> element is a good base for an accordion. The browser gives it
keyboard support, exposes its expanded state to assistive technology, closes
the other open item of a group that shares a name, and, in browsers that
search closed disclosures, opens an item when a find-in-page match is inside
it. None of that needs JavaScript, and if nothing in your page has to approve
or follow which items are open, a plain <details name> group is all you
need.
The trouble starts when the open items belong to your state: a form wizard
that refuses to open step two before step one is valid, a route that decides
which section is open, a React or Vue component with a value and an
onChange. A <details> element toggles itself, and it does not wait for
your permission. This guide shows how to build an accordion on top of it that
does what the state says, and only that.
What a Second Click Should Do While a Dialog Is Closing
A user opens a filters panel, changes their mind and clicks the Filters button to close it. The panel starts to slide out, and halfway through they realise they wanted one more filter after all, so they click the button again.
What should happen? The panel is still on screen, still in the DOM, still
open as far as the browser is concerned. It is just on its way out. Many
dialog implementations drop that second click, so the panel finishes closing
and the user has to wait and click a third time. This guide shows how to
reopen a dialog during its closing animation instead, and the details that
make that harder than it looks.
Your Mouse Didn't Move, but the Menu Thinks It Did
Picture a long menu with a scrollbar. A user opens it from the keyboard and walks down the items with the arrow keys, while their mouse just lies on the desk with the pointer somewhere over the panel. The list scrolls, a submenu trigger slides under the resting pointer, and its submenu pops open. One more arrow press, the trigger slides away, and the submenu closes again.
Nobody touched the mouse. The browser decided that the pointer had entered a new element, and the menu believed it. This guide shows why that happens, how to tell a hover the user made from one the browser made up, and how to test it.
Accessible Focus Traps: Trap the Keyboard, Not the User
Date pickers, comboboxes, menus and popovers all open a panel on top of the page. The moment that panel opens, the keyboard has a question to answer: where does the focus go now, where may it go next, and where does it land when the panel closes? Get it wrong and a keyboard user walks out of an open calendar into the page behind it, or a screen reader user is sent back to the top of the document after picking a date.
This guide covers how to answer those questions in a way that works for keyboard users, screen reader users and everyone using a mouse or a finger. The examples are plain JavaScript, so they apply to any framework.
CoreUI v6 Alpha vs Bootstrap 6 Alpha: What We Took, What We Didn't, and Why
Bootstrap published its first v6 alpha on October 8. CoreUI v6 followed with its first alpha two weeks later. CoreUI has been built on Bootstrap from the start, so the obvious question is how close the two v6 lines are.
The short answer: as close as we could make them, with a list of deliberate exceptions. For every file we share with Bootstrap we follow one rule. Class names, CSS custom properties, options, events and public methods stay the same as in Bootstrap wherever we can manage it, so moving from one to the other does not mean rewriting markup. The code behind those names is a separate question. Where we can do better than Bootstrap without changing a name, we do. Where following Bootstrap would cost our users a migration step that buys them nothing, we don’t.
This post goes through all three cases: what we took, what we left out, and where we kept the name but changed what is behind it.
Focusable Is Not Selectable: A Keyboard Focus Model for Date Grids
Open almost any date picker, press Tab until you reach the grid, and focus lands on a day. Which day it can land on, and which days the arrow keys can reach, comes down to one small decision that most implementations make without noticing: can an unavailable date receive focus?
The intuitive answer is no. A disabled date is disabled, so you render it as
<button disabled>, the browser skips it, and you move on. It looks right in
a demo. It stops being right as soon as a real product starts disabling
dates: weekends, public holidays, fully booked days, a minimum notice period,
a cut-off time.
This post describes the model we use in the CoreUI v6 Calendar, and why: a cell’s focusability depends only on the calendar’s limits. Everything else decides only whether the cell can be selected.
Bootstrap Calendar: From Date Picker to Full Scheduler
“Add a calendar” is one of those requirements that means five different things depending on who says it. A form field for picking a delivery date is a calendar. A month grid showing this sprint’s deadlines is a calendar. A week view where a dispatcher drags jobs between technicians’ columns is also, apparently, a calendar.
These are not sizes of the same feature — they are different features with different costs, and Bootstrap itself ships none of them. Bootstrap 5 has no calendar component at all: no date picker, no month grid, no scheduler. So every “bootstrap calendar” is Bootstrap’s design language plus a component that comes from somewhere else — a library, or your own code.
This article climbs that ladder honestly: what each rung actually requires, what you can reasonably build yourself, and where the cost curve bends hard enough that building stops making sense.
Bootstrap Data Table: When a Plain Table Stops Being Enough
Every Bootstrap data table starts the same way: a <table class="table">, a
loop over some rows, done. And for a surprising number of applications, that
is genuinely all you need.
Then the requirements arrive one at a time. “Can we sort this by date?” “Can I search it?” “It’s slow with this quarter’s data.” Each one looks small, and each one is answerable with a few lines of JavaScript — until, at a fairly predictable point, it isn’t.
This article walks that ladder honestly. For each threshold we show what you can build yourself with plain Bootstrap (or CoreUI, which shares the same table markup and classes) and vanilla JavaScript, where the hand-rolled version starts to leak, and at which rung it stops being reasonable to keep writing table infrastructure by hand. If your table has 50 rows and never will have more, the code below is all you need — no library, no license, nothing to ship but a few kilobytes of your own JavaScript.
How to raise a number to a power in JavaScript
Raising numbers to powers is essential for mathematical calculations, exponential growth models, compound interest, and geometric progressions in JavaScript applications. As the creator of CoreUI, I’ve used exponentiation in calculators, financial tools, and chart scaling utilities. For square roots (power of 0.5), see how to get the square root of a number in JavaScript.