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

class-name-prop

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-name-prop

A lightweight utility function to create a React className prop value for multiple class names.

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
77
decreased by-16.3%
Maintainers
1
Weekly downloads
 
Created
Source

class-name-prop

A lightweight utility function to create a React className prop value for multiple class names.

  • 📦 Tiny bundle size, tested.
  • ⚡️ Simple and fast API.
  • 🧠 Returns undefined if there are no class names, to prevent rendering a redundant class attribute; unlike packages like classnames.

Installation

For Node.js, to install class-name-prop with npm, run:

npm install class-name-prop

For Deno and browsers, an example import map:

{
  "imports": {
    "class-name-prop": "https://unpkg.com/class-name-prop@6.0.0/classNameProp.mjs"
  }
}

Then, import and use the function classNameProp.

Examples

A React component for a link that can be declared active, whilst supporting custom class names:

import classNameProp from "class-name-prop";
import React from "react";

function Link({ className, active, ...props }) {
  return React.createElement("a", {
    className: classNameProp(className, active && "active"),
    ...props,
  });
}

Requirements

Supported runtime environments:

Non Deno projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

The npm package class-name-prop features optimal JavaScript module design. These ECMAScript modules are exported via the package.json field exports:

Keywords

FAQs

Package last updated on 22 Aug 2022

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