How to Add Adjustable Spacers To Elements Via Drag | spacers.js

spacers.js is a JavaScript library for implementing multiple adjustable spacers with or without padding and margin to prevent elements.

Provides a convenient way to add extra white space between two UI components in your app. You can adjust the size and orientation of the separators by dragging and dropping.

html spacer div, flexbox spacer, how to make spacer blocks, spacer flex flutter, vertical space in html, how to add horizontal space in html, html vertical spacer

How to make use of it:

1. Load the stylesheet spacers.css and JavaScript spacers.js within the doc.

<link rel="stylesheet" href="spacers/spacers.css" />
<script src="spacers/spacers.js"></script>

2. Apply spacers to a given aspect and override the default spacing (in px) if wanted.

<div class="block">
  Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eius, eveniet laudantium, sit soluta ipsum
  reprehenderit libero eaque ex, unde nesciunt blanditiis itaque nemo exercitationem voluptates modi
  et cumque quas. Aliquid.
</div>
spacers({
  element: '.block',
  defaultSpacing: '8', // default: 8
  spacingUnit: 'px', // em, rem, in, cm, ch, mm, pt, pc ..etc
})

3. Enable/disable padding & margin.

spacers({
  element: '.block',
  padding: true,
  margin: true,
  defaultPadding: {
   'top': '20',
   'bottom': '20',
   'left': '20',
   'right': '20'
  }
  defaultMargin: {
   'top': '10',
   'bottom': '10',
   'left': '10',
   'right': '10'
  }
})

4. Determine whether or not to solely present the spacers on hover.

spacers({
  element: '.block',
  showOnHover: true,
})

5. Determine at which place the library appends the spacer HTML.

spacers({
  element: '.block',
  appendHtml: 'begin',
})

6. Determine whether or not to cover the margin/padding values within the spacer.

spacers({
  element: '.block',
  hideSpacingValue: true,
})

7. Determine whether or not to indicate the spacer label.

spacers({
  element: '.block',
  showLabel: 'Spacer Label',
})

8. Determine whether or not to lock reverse spacers.

spacers({
  element: '.block',
  enableLock: true,
  lockIcon: '🔒'
  unlockIcon: '🔓'
})

9. Apply extra CSS classes to the spacers.

spacers({
  element: '.block',
  spacerClass: 'my-class'
})

10. Specify the container area.

spacers({
  element: '.block',
  containedArea: document
})

11. Trigger a perform when the drag ends.

spacers({
  element: '.block',
  onDragEnd: function( data ) {
    console.log(data);
  }
})

Add Adjustable Spacers To Elements Via Drag, spacers Plugin/Github, html spacer line


See Demo And Download

Official Website(actuallyakash): Click Here

This superior jQuery/javascript plugin is developed by actuallyakash. For extra Advanced Usages, please go to the official website.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…