1.0.7 • Published 5 years ago

react-heart-switch v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

MIT license npm version npm size

Demo

Live demo and sandbox

Installation

React-Heart-Switch is available as an npm package.

// with npm

npm install react-heart-switch

Usage

import React, { useState } from "react"
import HeartSwitch from "react-heart-switch"

function  App() {
	const [active, setActive] = useState(false)
	return (
		<div style={{ width: "2rem" }}>
			<HeartSwitch isActive={active} onClick={() => setActive(!active)}/>
		</div>
	);
}

Props

NameTypeRequired?DefaultDescription
isActiveboolrequiredN/ACurrent heart status
onClickfunctionrequiredN/AHeart was clicked callback
animationTrigger'none' | 'click' | 'hover'optional'click'Animation trigger
AnimationScalenumberoptional1.05Scale of animation
inactiveColorstringoptional'black'Color of inactive heart
inactiveSwitchColorstringoptionalinactiveColorColor of inactive heart switch
activeColorstringoptional'red'Color of active heart
classNamestringoptionalN/AClass name to apply custom CSS
styleobjectoptionalN/AStyle object

Example

import React, { useState } from "react"
import HeartSwitch from "react-heart-switch"

function  App() {
	const [active, setActive] = useState(false)
	return (
		<div style={{ width: "2rem" }}>
			<HeartSwitch isActive={active} onClick={() => setActive(!active)} animationTrigger = "none" inactiveColor = "rgba(255,125,125,.75)" inactiveSwitchColor = "rgba(155,225,75,.75)" activeColor = "#e019ae" style = {{marginTop:'1rem'}}/>
		</div>
	);
}
1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago