Docs
Draw Outline Button
The Draw Outline Button adds or toggles an outline around an element, enhancing visibility and focus in the UI.
Installation
Install dependencies
npm install framer-motion lucide-react
Run the following command
It will create a new file draw-outline-button.tsx
inside the components/mage-ui/button
directory.
mkdir -p components/mage-ui/button && touch components/mage-ui/button/draw-outline-button.tsx
Paste the code
Open the newly created file and paste the following code:
"use client"
import React from "react";
const DrawOutlineButtonComponent = () => {
return (
<div className="grid h-screen w-[90vw] place-content-center bg-slate-900 p-4">
<DrawOutlineButton>Hover me</DrawOutlineButton>
</div>
);
};
const DrawOutlineButton = ({
children,
...rest
}: React.DetailedHTMLProps<
React.ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
>) => {
return (
<button
{...rest}
className="group relative px-4 py-2 font-medium text-slate-100 transition-colors duration-[400ms] hover:text-indigo-300"
>
<span>{children}</span>
{/* TOP */}
<span className="absolute left-0 top-0 h-[2px] w-0 bg-indigo-300 transition-all duration-100 group-hover:w-full" />
{/* RIGHT */}
<span className="absolute right-0 top-0 h-0 w-[2px] bg-indigo-300 transition-all delay-100 duration-100 group-hover:h-full" />
{/* BOTTOM */}
<span className="absolute bottom-0 right-0 h-[2px] w-0 bg-indigo-300 transition-all delay-200 duration-100 group-hover:w-full" />
{/* LEFT */}
<span className="absolute bottom-0 left-0 h-0 w-[2px] bg-indigo-300 transition-all delay-300 duration-100 group-hover:h-full" />
</button>
);
};
export default DrawOutlineButtonComponent;