Styling
The stylesheet draws the drag states only - the ghost, the chosen item, the preview, the swap target, the selection, the locked items - and leaves the look of your list to you. Every state is tinted with one accent and tuned through custom properties, and each state's class can be replaced with one of your own.
An accent and a few properties
These two lists use the stylesheet's own drag states, with no class of this site's. The controls set the stylesheet's custom properties on the element around them, and the lists inherit them: the accent every state is tinted with, how transparent the dragged item is, and outlines for the lists that take a drag.
--bit-bortable-accent-rgb
.board {
--bit-bortable-accent-rgb: 13, 110, 253;
--bit-bortable-ghost-opacity: 0.40;
--bit-bortable-accepts-outline: 2px dashed rgba(13, 110, 253, .5);
--bit-bortable-over-outline: 2px solid rgb(13, 110, 253);
}Classes of your own
GhostClass, ChosenClass and DragClass replace the class of a state with your
own, for a list that wants its own look instead of the stylesheet's: here a dashed amber ghost, an amber chosen
item, and a tilted preview. The list has ForceFallback, so the mouse drags with the preview too.
.my-ghost { opacity: .55; outline: 2px dashed var(--bb-warning); outline-offset: -2px; } .my-chosen { background-color: var(--bb-warning-soft); } .my-drag { rotate: -3deg; opacity: .95; outline: 2px solid var(--bb-warning); box-shadow: 0 18px 36px rgba(0, 0, 0, .25); }
Order: One, Two, Three, Four
Try it
- Pick Violet and drag a fruit: the dragged item and its preview in the Basket are tinted violet.
- Lower the ghost opacity to
0.1: the dragged item almost disappears from its place. - Tick the outlines and drag a fruit: both lists are outlined dashed, and the one under the pointer solid.
- Drag an item of the last list with the mouse: the preview that follows the pointer is tilted, the place it left is dashed. Pick one up from the keyboard: a keyboard drag wears only the chosen class.
Every custom property
Override them on :root for the whole app, on one list's Class, or inline through its
Style. The colours are worked out on the item itself, so an accent set on one list reaches its items.
| Property | Default | Used for |
|---|---|---|
--bit-bortable-accent-rgb | 13, 110, 253 | The accent every state is tinted with, as an r, g, b triplet. |
--bit-bortable-ghost-opacity | 0.4 | The dragged item and the drop placeholder. |
--bit-bortable-chosen-bg | the accent at 12% | The chosen item's background. |
--bit-bortable-swap-bg | the accent at 18% | The swap target's background. |
--bit-bortable-swap-outline | 2px dashed, accent at 60% | The swap target's outline. |
--bit-bortable-selected-bg | the accent at 25% | A multi-drag selected item's background. |
--bit-bortable-selected-ring | inset 2px, accent at 80% | A multi-drag selected item's ring (a box-shadow). |
--bit-bortable-filtered-opacity | 0.7 | A filtered item. |
--bit-bortable-focus-outline | 2px solid, accent at 90% | The outline of an item focused from the keyboard. |
--bit-bortable-focus-offset | 2px | How far that outline sits outside the item. |
--bit-bortable-lifted-outline-style | dashed | The outline style of an item picked up from the keyboard. |
--bit-bortable-drag-opacity | 0.92 | The preview that follows a finger, a pen or a ForceFallback mouse. |
--bit-bortable-drag-shadow | a soft shadow | That preview's shadow. |
--bit-bortable-accepts-outline | none | During a drag, the outline of every list that takes it. |
--bit-bortable-over-outline | none | The outline of the list under the pointer. |
--bit-bortable-refused-outline | none | The outline of that list when it refused the position (see rules). |
--bit-bortable-target-offset | 2px | How far those outlines sit outside the list. |
The classes
| Class | Set on | Replaced by |
|---|---|---|
bit-bortable | The list container. | |
bit-bortable-item | Every item wrapper, and the drop placeholder. | |
bit-bortable-ghost | The item being dragged with a pointer, in its list, and the drop placeholder. | GhostClass |
bit-bortable-chosen | The item being dragged - also from the keyboard - and the drop placeholder. | ChosenClass |
bit-bortable-drag | The preview that follows a finger, a pen or a ForceFallback mouse. | DragClass |
bit-bortable-hidden | The original of a moved item while it is previewed in another list. | |
bit-bortable-swap-highlight | The swap target, in swap mode. | SwapClass |
bit-bortable-selected | The items of a multi-drag selection. | SelectedClass |
bit-bortable-filtered | Items the Filter locks. | |
bit-bortable-disabled | The container of a Disabled list. | |
bit-bortable-has-handle | The container of a list with a Handle. |
While a drag runs, the browser layer also sets attributes you can style, at no render cost:
data-bortable-accepts on every list that takes the drag, data-bortable-over on the one
under the pointer, data-bortable-refused on that one when it refused the position, and
data-bortable-dragging on <html>, set to native,
pointer or keyboard. Your own look for the list and its items goes through
Class and Style on the container and ItemClass and
ItemClassSelector on the items.
GhostClass, ChosenClass, DragClass, SwapClass and
SelectedClass can also be set once for every list of the app, in
the app-wide defaults.