1.0.0-beta14 • Published 5 months ago

popover-css-inspector v1.0.0-beta14

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

LICENSE GitHub Super-Linter code style: prettier npm Version npm Downloads

Popover CSS Inspector

Displays CSS attributes of elements in a Bootstrap popover. Ideal for design systems and style guides.

  • Easy to use - just add data-bs-custom-class="popover-css-inspector" to the element (requires Bootstrap 5 JavaScript)
  • Customizable with your own CSS and Bootstrap's Popover options
  • Popover remains static on the document and does not reposition on scroll
  • Supports Bootstrap 5 dark mode
  • Option to hide CSS elements - e.g. just add data-css-inspector-hide="font-size" to prevent font-size properties from displaying
  • Some CSS properties are hidden by default but can be enabled - e.g. just add data-css-inspector-show="border" to show border properties
  • Reloads CSS attributes if the theme is changed via the data-bs-theme attribute - perfect for checking color value changes between light and dark mode
  • Supports optional title with data-bs-title attribute.
  • Only 3 KB minified and gzipped!

Popover CSS Inspector

Quick start

Several quick start options are available:

  • Download the latest release
  • Clone the repo git clone https://github.com/coliff/popover-css-inspector.git
  • Install with npm npm install popover-css-inspector
  • Install with yarn yarn add popover-css-inspector

Usage

  1. Add the data-bs-custom-class="popover-css-inspector" to the element you'd like to show the popover on. For example, a button.
<button
  type="button"
  class="btn btn-primary"
  data-bs-toggle="popover"
  data-bs-custom-class="popover-css-inspector">
  Button
</button>
  1. Load the script (either async or defer is recommended):
<script src="/js/popover-css-inspector.min.js" defer></script>
  1. Some CSS properties are opt-in only. For example, to show border properties, add data-css-inspector-show="border" to the element.

  2. All CSS properties can be hidden. For example, to hide font-size properties, add data-css-inspector-hide="font-size" to the element.

  3. Optional. Consider adding the pe-none class to the element to prevent the popover from being triggered by the user.

How it works

The script will look for any element with the data-bs-custom-class="css-inspector" attribute and add a click event listener to it. When clicked, it will get the element's CSS attributes and display them in a Bootstrap popover.

Demo

Demo page

List of CSS properties

These CSS properties are displayed by default unless their value is null or empty. You can also opt out with a data-attribute if needed.

PropertyOpt-out attribute
animation-durationdata-css-inspector-show="animation-duration"
animation-namedata-css-inspector-show="animation-name"
background-colordata-css-inspector-hide="bg-color"
border-radiusdata-css-inspector-hide="b-radius"
border-widthdata-css-inspector-hide="b-width"
colordata-css-inspector-hide="color"
font-sizedata-css-inspector-hide="font-size"
font-styledata-css-inspector-hide="font-style"
font-weightdata-css-inspector-hide="font-weight"
heightdata-css-inspector-hide="height"
margindata-css-inspector-hide="margin"
max-heightdata-css-inspector-hide="max-height"
max-widthdata-css-inspector-hide="max-width"
opacitydata-css-inspector-hide="opacity"
paddingdata-css-inspector-hide="padding"
text-aligndata-css-inspector-hide="text-align"
text-transformdata-css-inspector-hide="text-transform"
widthdata-css-inspector-hide="width"

Note: Most attributes are hidden if the value is none or null.

List of opt-in CSS properties

PropertyOpt-in attribute
accent-colordata-css-inspector-show="accent-color"
animationdata-css-inspector-show="animation"
appearancedata-css-inspector-show="appearance"
aspect-ratiodata-css-inspector-show="aspect-ratio"
background-imagedata-css-inspector-show="bg-image"
background-positiondata-css-inspector-show="bg-position"
background-repeatdata-css-inspector-show="bg-repeat"
background-sizedata-css-inspector-show="bg-size"
borderdata-css-inspector-show="border"
border-bottom-colordata-css-inspector-show="b-bottom-color"
border-colordata-css-inspector-show="b-color"
border-left-widthdata-css-inspector-show="b-left-width"
border-styledata-css-inspector-show="b-style"
box-shadowdata-css-inspector-show="box-shadow"
box-sizingdata-css-inspector-show="box-sizing"
color-schemedata-css-inspector-show="color-scheme"
cursordata-css-inspector-show="cursor"
displaydata-css-inspector-show="display"
floatdata-css-inspector-show="float"
font-familydata-css-inspector-show="font-family"
letter-spacingdata-css-inspector-show="letter-spacing"
line-breakdata-css-inspector-show="line-break"
line-heightdata-css-inspector-show="line-height"
list-styledata-css-inspector-show="list-style"
margin-bottomdata-css-inspector-show="margin-bottom"
margin-leftdata-css-inspector-show="margin-left"
margin-rightdata-css-inspector-show="margin-right"
margin-topdata-css-inspector-show="margin-top"
min-heightdata-css-inspector-show="min-height"
min-widthdata-css-inspector-show="min-width"
overflowdata-css-inspector-show="overflow"
paddingdata-css-inspector-show="padding"
positiondata-css-inspector-show="position"
text-aligndata-css-inspector-show="text-align"
text-decorationdata-css-inspector-show="text-decoration"
text-indentdata-css-inspector-show="text-indent"
text-shadowdata-css-inspector-show="text-shadow"
text-transformdata-css-inspector-show="text-transform"
text-wrapdata-css-inspector-show="text-wrap"
transformdata-css-inspector-show="transform"
transitiondata-css-inspector-show="transition"
user-selectdata-css-inspector-show="user-select"
vertical-aligndata-css-inspector-show="vertical-align"
white-spacedata-css-inspector-show="white-space"
word-breakdata-css-inspector-show="word-break"
word-spacingdata-css-inspector-show="word-spacing"
word-wrapdata-css-inspector-show="word-wrap"
z-indexdata-css-inspector-show="z-index"

Browser support

Works well with all the browsers supported by Bootstrap.

Credits

Created by Christian Oliff with help from GitHub Copilot.

1.0.0-beta10

6 months ago

1.0.0-beta11

6 months ago

1.0.0-beta12

6 months ago

1.0.0-beta13

6 months ago

1.0.0-beta14

5 months ago

1.0.0-beta9

8 months ago

1.0.0-beta8

10 months ago

1.0.0-beta7

10 months ago

1.0.0-beta6

10 months ago

1.0.0-beta5

10 months ago

1.0.0-beta4

10 months ago

1.0.0-beta3

10 months ago

1.0.0-beta2

10 months ago

1.0.0-beta1

10 months ago