npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-squircle

v1.0.6

Published

Functions for generating superellipse squircles in the form of SVG strings, to be used as clip-path and background inline styles.

Downloads

18

Readme

html-squircle

html-squircle is a lightweight, framework-agnostic JavaScript package designed to create superellipse squircles (smooth, rounded shapes) that can be used as SVG clip paths or backgrounds for web elements. This package is perfect for developers looking to add modern, beautifully-rounded corners to the web with minimal effort.

Features

  • Generate squircles as SVG strings for use in clip-path or background inline styles.
  • Unlike a true superellipse, transitions gracefully into straight edges, making it suitable for UI elements of various sizes.
  • Customizable curve length, curve sharpness, background (solid color or gradient), stroke color, and stroke width.
  • Easy to use with any web framework or vanilla JavaScript.

Installation

You can install html-squircle directly into your project using npm:

npm install html-squircle

Usage

After installing html-squircle, you can import and use it in your project as follows:

import { clipSquircle, bgSquircle } from "html-squircle"

// Example usage for a clip path
const clipPathStyle = clipSquircle({
    bgWidth: 200,
    bgHeight: 200
})

// Example usage for a background with a solid color
const backgroundStyle = bgSquircle({
    bgWidth: 200,
    bgHeight: 200,
    svgBackground: "#ff6347", // Tomato color
    svgStroke: "black",
    svgStrokeWidth: 2
})

// Apply the generated styles to your elements
document.getElementById("yourElementId").style.clipPath = clipPathStyle
document.getElementById("anotherElementId").style.background = backgroundStyle

The clipSquircle and bgSquircle exports provide Apple-like default values to curveLength and curveSharpness, such that square elements will look like app icons. It also makes the default background white, with no stroke, and stroke width 1px.

To create functions with defaults adhering to your own design system, use the newClipSquircler and newBgSquircler exports and supply them with your own preferences.

There is also the getConstantCurveLength export, which you can use as an input to the curveLength parameter to define a curve length in pixels that will not change in response to the size of the element.