8000 GitHub - cristian-encalada/react-svg-buttons: React configurable animated svg buttons (support for React v18)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cristian-encalada/react-svg-buttons

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React SVG buttons

Version

React SVG buttons

This package provides a <MorphIcon /> component used to compose available buttons, it's able to morph from whatever icon type to another one.

The <MorphIcon /> component exposes 18 icon types.

It also provides a set of button components.

Please, take a look at the demo.

Installation

npm install @devbug/react-svg-buttons

Usage

You can create your own personalized buttons.

For instance, adding new react components:

Morphing onClick

// MorphingButtonClick.jsx
import { useState } from 'react';
import { MorphIcon } from '@devbug/react-svg-buttons';

const MorphingButtonClick = () => {
  const [iconType, setIconType] = useState('home');

  return (
    <MorphIcon
      type={iconType}
      size={100}
      thickness={2}
      color="#dd6e78"
      onClick={() => setIconType(iconType === 'home' ? 'thunderbolt' : 'home')}
    />
  );
};

export default MorphingButtonClick;

Morphing onMouseEnter/onMouseLeave

// MorphingButtonHover.jsx
import { useState } from 'react';
import { MorphIcon } from '@devbug/react-svg-buttons';

const MorphingButtonHover = () => {
  const [iconType, setIconType] = useState('home');

  return (
    <MorphIcon
      type={iconType}
      size={100}
      thickness={2}
      color="#dd6e78"
      onMouseEnter={() => setIconType('thunderbolt')}
      onMouseLeave={() => setIconType('home')}
    />
  );
};

export default MorphingButtonHover;

Then just add the new components to the react app or you can use the Pre configured buttons.

// main.jsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import MorphingButtonClick from './components/MorphingButtonClick'
import MorphingButtonHover from <
6B76
span class="pl-s">'./components/MorphingButtonHover'

import {
  MorphIcon,
  CloseButton
} from '@devbug/react-svg-buttons'

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
       <div>
        <MorphingButtonClick />
        <MorphingButtonHover />
        <MorphIcon
            type="hashtag"
            size={100}
            thickness={2}
            color="blue"
        />
        <CloseButton/>
      </div>
  </React.StrictMode>,
)

Result:

React SVG buttons

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Original work:

Updated to support React v18:

About

React configurable animated svg buttons (support for React v18)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%
0