Slider
Install
npm install @svg-animated-icons/reactCLI
Copy an icon component straight into your project — shadcn-style. Replace {icon} with an icon name like arrow-left.
terminal
npx @svg-animated-icons/cli add {icon} --react| Flag | Description |
|---|---|
--dest <dir> | Destination directory (default: components/animated-icons) |
Or copy the component with the CLI
CLI
npx @svg-animated-icons/cli add slider --reactCode
React
// Generated by @svg-animated-icons/cli
// You own this file — edit it freely.
import React from "react";
type Props = {
disableHover?: boolean;
className?: string;
};
export function SliderIcon({ disableHover, className }: Props) {
const classes = [
"ai-slider-icon",
disableHover ? "no-hover" : "",
className ?? "",
]
.filter(Boolean)
.join(" ");
return (
<>
<style>{`
.ai-slider-icon {
width: 1em;
height: 1em;
display: inline-block;
cursor: pointer;
overflow: visible;
}
.ai-slider-icon * {
transform-box: fill-box;
}
.ai-slider-icon.no-hover * {
transform: none;
opacity: 1;
animation: none;
}
.ai-slider-icon .knob,
.ai-slider-icon .cutout {
transform-box: view-box;
}
.ai-slider-icon:not(.no-hover):hover .knob,
.ai-slider-icon:not(.no-hover):hover .cutout {
animation: ai-slider-slide 700ms ease-in-out;
}
@keyframes ai-slider-slide {
0%, 100% { transform: translateX(0); }
50% { transform: translateX(-2.5px); }
}
`}</style>
<svg
xmlns="http://www.w3.org/2000/svg"
className={classes}
viewBox="0 0 15 15"
fill="none"
>
<defs>
<mask id="ai-slider-mask">
<rect width="15" height="15" fill="white"/>
<circle className="cutout" cx="8.5" cy="7.5" r="1.5" fill="black"/>
</mask>
</defs>
<g mask="url(#ai-slider-mask)">
<path className="track" d="M0.5 7H14.5C14.7761 7 15 7.22386 15 7.5C15 7.77614 14.7761 8 14.5 8H0.5C0.22399 8 0 7.77614 0 7.5C0 7.22386 0.223858 7 0.5 7Z" fill="currentColor"/>
</g>
<path className="knob" fillRule="evenodd" d="M8.5 4.74942C9.84783 4.74942 10.9678 5.72027 11.2031 7H11.2031C11.6953 7 12.0951 7.40021 12.0951 7.5C12.0951 7.5998 11.6952 8 11.2031 8C10.9678 9.27993 9.84773 10.2502 8.5 10.2504C7.10422 10.2504 6 9.0974 6 7.5004C6 5.90341 7.10422 4.74942 8.5 4.74942ZM8.5 5.69962C7.50578 5.69981 6.69922 6.50613 6.69922 7.5004C6.69948 8.49444 7.50594 9.30001 8.5 9.3002C9.494 9.29994 10.2995 8.4944 10.2998 7.5004C10.2998 6.50617 9.49416 5.69988 8.5 5.69962Z" fill="currentColor"/>
</svg>
</>
);
}