Socket
Socket
Sign inDemoInstall

react-element-state

Package Overview
Dependencies
20
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-element-state

Easily manage element states like focus, hover and active states, without cluttering your React components


Version published
Weekly downloads
4
decreased by-69.23%
Maintainers
1
Install size
3.33 MB
Created
Weekly downloads
 

Readme

Source

react-element-state

import ElementState from 'react-element-state';

<ElementState> is a React component that manages the 3 most common user interaction states, letting you focus on what to do with them. It provides:

  • isHovering (true/false) - whether the mouse is hovered over the element
  • isActive (true/false) - whether the mouse is pressed on the element
  • isFocused (true/false) - whether the element has the document focus

Usage

Pass a particular state to control your component:

<ElementState>
    {state => <MyButton highlight={state.isHovering}/>}
</ElementState>

If the prop names match up, spread all states onto your component:

<ElementState>
    {state => <MyButton {...state}/>}
</ElementState>

Or choose the states you care about and use them directly:

<ElementState>
    {({isFocused, isActive}) => {
        return <button>
            I'm {isFocused ? 'focused' : 'not focused'},
            and {isActive ? 'active' : 'not active'}
        </button>;
    }}
</ElementState>

Keywords

FAQs

Last updated on 14 Jul 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc