# Border draw button

> On hover, the four sides of the border are drawn one after another, like a pen going around.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-btn-draw
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This border draw button has an editorial feel. It suits an architecture studio's “Explore projects”, the “See the collection” link of a fashion lookbook or the contact button of a photographer's site. The lines trace the rectangle one side at a time, so the hover feels like a small drawing rather than a flash.

The full loop takes almost a second, and people who move fast only see half of it. If that bothers you, raise the speed. It fits minimal layouts with thin rules and plenty of white space better than busy, colorful pages.

## Code

### HTML

```html
<button class="uv-draw"><b></b><b></b><b></b><b></b>Explore</button>
```

### CSS

```css
.uv-draw {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uv-draw {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 600;
  line-height: 1;
  padding: 1em 2em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  border-radius: .3em;
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 8%,transparent);
}

.uv-draw b {
  position: absolute;
  background: var(--c1);
  transition: transform calc(0.2s / var(--k)) linear;
}

.uv-draw b:nth-child(1) {
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  transform-origin: left;
  transform: scaleX(0);
}

.uv-draw b:nth-child(2) {
  right: 0;
  top: 0;
  width: 2px;
  height: 100%;
  transform-origin: top;
  transform: scaleY(0);
}

.uv-draw b:nth-child(3) {
  right: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  transform-origin: right;
  transform: scaleX(0);
}

.uv-draw b:nth-child(4) {
  left: 0;
  bottom: 0;
  width: 2px;
  height: 100%;
  transform-origin: bottom;
  transform: scaleY(0);
}

.uv-draw:hover b {
  transform: none;
}

.uv-draw:hover b:nth-child(2) {
  transition-delay: calc(0.2s / var(--k));
}

.uv-draw:hover b:nth-child(3) {
  transition-delay: calc(0.4s / var(--k));
}

.uv-draw:hover b:nth-child(4) {
  transition-delay: calc(0.6s / var(--k));
}
```

### React

```tsx
import type { CSSProperties } from "react";

const css = `
.uv-draw {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 600;
  line-height: 1;
  padding: 1em 2em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  border-radius: .3em;
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 8%,transparent);
}

.uv-draw b {
  position: absolute;
  background: var(--c1);
  transition: transform calc(0.2s / var(--k)) linear;
}

.uv-draw b:nth-child(1) {
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  transform-origin: left;
  transform: scaleX(0);
}

.uv-draw b:nth-child(2) {
  right: 0;
  top: 0;
  width: 2px;
  height: 100%;
  transform-origin: top;
  transform: scaleY(0);
}

.uv-draw b:nth-child(3) {
  right: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  transform-origin: right;
  transform: scaleX(0);
}

.uv-draw b:nth-child(4) {
  left: 0;
  bottom: 0;
  width: 2px;
  height: 100%;
  transform-origin: bottom;
  transform: scaleY(0);
}

.uv-draw:hover b {
  transform: none;
}

.uv-draw:hover b:nth-child(2) {
  transition-delay: calc(0.2s / var(--k));
}

.uv-draw:hover b:nth-child(3) {
  transition-delay: calc(0.4s / var(--k));
}

.uv-draw:hover b:nth-child(4) {
  transition-delay: calc(0.6s / var(--k));
}
`;

export default function BtnDraw() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uv-draw"><b></b><b></b><b></b><b></b>Explore</button>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Border draw button” block (Buttons) from AIMRAN Library to my project.

## What it is
On hover, the four sides of the border are drawn one after another, like a pen going around.

## Chosen settings
- Main color: #0071e3
- Secondary color: #8ec5ff
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Explore"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import type { CSSProperties } from "react";

const css = `
.uv-draw {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 600;
  line-height: 1;
  padding: 1em 2em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  border-radius: .3em;
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 8%,transparent);
}

.uv-draw b {
  position: absolute;
  background: var(--c1);
  transition: transform calc(0.2s / var(--k)) linear;
}

.uv-draw b:nth-child(1) {
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  transform-origin: left;
  transform: scaleX(0);
}

.uv-draw b:nth-child(2) {
  right: 0;
  top: 0;
  width: 2px;
  height: 100%;
  transform-origin: top;
  transform: scaleY(0);
}

.uv-draw b:nth-child(3) {
  right: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  transform-origin: right;
  transform: scaleX(0);
}

.uv-draw b:nth-child(4) {
  left: 0;
  bottom: 0;
  width: 2px;
  height: 100%;
  transform-origin: bottom;
  transform: scaleY(0);
}

.uv-draw:hover b {
  transform: none;
}

.uv-draw:hover b:nth-child(2) {
  transition-delay: calc(0.2s / var(--k));
}

.uv-draw:hover b:nth-child(3) {
  transition-delay: calc(0.4s / var(--k));
}

.uv-draw:hover b:nth-child(4) {
  transition-delay: calc(0.6s / var(--k));
}
`;

export default function BtnDraw() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <button className="uv-draw"><b></b><b></b><b></b><b></b>Explore</button>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
