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

react-bound-highlight

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bound-highlight

Highlight other components when a component is hovered

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React bound highlight

React component for connecting elements hover states

GitHub Workflow Status npm bundle size

Features:

  • Highlight other components when a component is hovered
  • Custom styles
  • Lightweight
  • No dependencies

Examples from storybook

Two directions bound:

Two directions bound with current element highlight ON:

Single direction bound:

Multiple elements in bound:

Custom highlight styles:

Can be used for building side by side editor like this:

Install

npm install react-bound-highlight --save

Basic usage

Wrap needed elements and specify unique id for connected components group:

import BoundHighlight from 'react-bound-highlight';
...
    <div>
      <BoundHighlight id="group1">Group 1</BoundHighlight>
      <BoundHighlight id="group2">Group 2</BoundHighlight>
      ...
      <BoundHighlight id="group1">Group 1</BoundHighlight>
      <BoundHighlight id="group2">Group 2</BoundHighlight>
    </div>
...

Props

PropDescriptionTypeDefault
id*unique group bound identifierstring
currentHoverHighlightOnturn on hover highlight on current elementboolfalse
oppositeHoverHighlightOffturn off current component oposite highlightboolfalse
defaultStyleOffturn off default style for highligtingboolfalse
classNamecustom classNamestring'BoundHighlight'
htmlTagwrapper HTML tagstring'span'
children*nested elementsstring, node

Classes

Use classes to override highlighting styles. Set defaultStyleOff=true prop to turn off default style.

ClassDesciption
BoundHighlightMain class name, can by override via className prop
{className}--currentHoverCurrent hover state className
{className}--boundHoverBound hover state className

Storybook

Review all examples on storybook:

npm run storybook

Run tests

npm run test

Linter

Run linter:

npm run lint

Fix formatting issues:

npm run lint:fix

License

MIT

Keywords

FAQs

Package last updated on 29 Apr 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