Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-css-unit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-css-unit

Check if a given value contains a valid CSS unit

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
increased by0.98%
Maintainers
1
Weekly downloads
 
Created
Source

is-css-unit

Check if a given value contains a valid CSS unit

Installation

npm install --save is-css-unit

Usage

const isCSSUnit = require('is-css-unit').isCSSUnit;

console.log(isCSSUnit('300px'))
// => true

console.log(isCSSUnit('10bark'))
// => false

If you need more specific checks, you can require different functions:

  • isFontUnit: checks for all relative font units (em, ex, ch, rem)
  • isViewportUnit: checks for all viewport units (vw, vh, vmin, vmax)
  • isAbsoluteUnit: checks for all absolute units (cm, mm, q, in, pt, pc, px)
  • isAngleUnit: checks for all angle units (deg, grad, rad, turn)
  • isDurationUnit: checks for all duration units (s, ms)
  • isFrequencyUnit: checks for all frequency units (Hz, kHz)
  • isResolutionUnit: checks for all resolution units (dpi, dpcm, dppx)

License

is-css-unit is licensed under the MIT License

Keywords

FAQs

Package last updated on 30 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc