🧠 Description
Experience a modern and interactive share button that smoothly transitions to reveal social media icons on hover. Built with HTML, CSS, and JavaScript, this elegant UI component uses Lucide icons and animations to create a clean, responsive, and visually engaging sharing experience.
💻 HTML Code
The HTML file sets up the structure of the animated share button.
Head Section
Defines the page’s metadata and loads the external CSS file (style.css) and the Lucide icon library (used for SVG icons).
Body
Contains a centered div with a single button (share-button large).
The button has two parts:
.share-content — the default visible part of the button showing the “Share” text and share icon.
.share-icons — hidden initially; contains social media icons (GitHub, X, and Facebook), which appear when hovering over the button.
Each icon uses data-platform attributes to identify which platform it represents.
The script file (script.js) is linked at the bottom to handle functionality.
CSS Code
The CSS controls the design, layout, and animation of the button.
Page Layout
The body is centered vertically and horizontally using flex.
Uses a light gray background and Poppins font for a clean modern style.
Button Styling (.share-button)
The button is blue (#2563eb), rounded, and slightly enlarges (scale(1.03)) when hovered.
It’s positioned relative so its inner content can be absolutely positioned for animation.
transition is added to create smooth hover animations.
Button Variants
.large adds bigger padding, font size, and radius for a large version.
.share-content
This is the part showing the text “Share” and the share icon by default.
It’s centered absolutely inside the button.
It fades and moves upward when hovered (opacity: 0; transform: translateY(-28px)).
.share-icons
Initially hidden (opacity: 0, placed below view using top: 100% and translateY(25px)).
When hovered, it moves into view (top: 0) and becomes visible (opacity: 1).
.icon
Each icon is clickable and changes color/position slightly on hover (translateY(-8px) and color: #93c5fd).
Smooth Transitions
Both .share-content and .share-icons use transitions for smooth animations.
Javascipt Code
The JavaScript file (script.js) controls the behavior when users click on any social media icon.
lucide.createIcons()
This line replaces all tags with SVG icons provided by the Lucide library.
Icon Click Functionality
The script selects all icons inside .share-icons.
For each icon, it listens for a click event.
When clicked:
It reads the data-platform attribute to know which platform was clicked.
Depending on the platform, it opens the corresponding website (GitHub, X, or Facebook) in a new browser tab using window.open().
