# Fountain pen underline tabs

> Italic serif tabs where an ink stroke draws itself under the chosen one and wipes away from the previous one.

- Category: [Navigation](https://library.aimran.es/components/navigation)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-nav-ink-tabs
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Literary tabs set in italic serif, where the active one gets a hand-drawn ink underline. When you switch, the old stroke wipes away from its start and the new one is drawn from left to right, and hovering shows a faint pencil line first. Each stroke is an SVG path animated with stroke-dashoffset, which suits blogs, magazines, portfolios and writing apps.

The main color is the ink and the secondary color the pencil preview. Change the path in the data to give each tab its own wobble, and keep the labels to one or two words.

## Code

### HTML

```html
<div class="uvq12-it"><div role="tablist" aria-label="Sections"><button type="button" role="tab" id="uvq12-it-t0" aria-selected="true" aria-controls="uvq12-it-p0" tabindex="0"><span>Essays</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 7c18-4 30 3 48 0s32-3 48 1" pathLength="1"/></svg></button><button type="button" role="tab" id="uvq12-it-t1" aria-selected="false" aria-controls="uvq12-it-p1" tabindex="-1"><span>Notes</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M3 8c10-5 22 2 34-1s30-4 60 0" pathLength="1"/></svg></button><button type="button" role="tab" id="uvq12-it-t2" aria-selected="false" aria-controls="uvq12-it-p2" tabindex="-1"><span>Letters</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 6c20 3 40-3 60 0s25 2 36-1" pathLength="1"/></svg></button><button type="button" role="tab" id="uvq12-it-t3" aria-selected="false" aria-controls="uvq12-it-p3" tabindex="-1"><span>Poems</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 8c15-3 25 1 45-2s35 3 51 0" pathLength="1"/></svg></button></div><div class="pn" role="tabpanel" id="uvq12-it-p0" aria-labelledby="uvq12-it-t0">Twelve short pieces about the city and its noise.</div><div class="pn" role="tabpanel" id="uvq12-it-p1" aria-labelledby="uvq12-it-t1" hidden>Loose notes, lists and lines overheard on the train.</div><div class="pn" role="tabpanel" id="uvq12-it-p2" aria-labelledby="uvq12-it-t2" hidden>Letters to friends who live far away.</div><div class="pn" role="tabpanel" id="uvq12-it-p3" aria-labelledby="uvq12-it-t3" hidden>Short verses written before dawn.</div></div>
```

### CSS

```css
.uvq12-it {
  --c1: #2f5fd0;
  --c2: #a8a29e;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq12-it {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 21em;
}

.uvq12-it [role="tablist"] {
  display: flex;
  gap: 1.2em;
  padding: 0 .2em .55em;
  border-bottom: 1px solid color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq12-it [role="tab"] {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  padding: .2em .1em .5em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-style: italic;
  font-size: 1.3em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq12-it [role="tab"]:hover,.uvq12-it [role="tab"][aria-selected="true"] {
  color: var(--fg);
}

.uvq12-it [role="tab"]:active {
  transform: translateY(1px);
}

.uvq12-it [role="tab"]:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
  border-radius: .2em;
}

.uvq12-it svg {
  position: absolute;
  left: -.15em;
  bottom: 0;
  width: calc(100% + .3em);
  height: .55em;
  overflow: visible;
}

.uvq12-it path {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq12-it [role="tab"]:not([aria-selected="true"]):hover path {
  stroke: var(--c2);
  stroke-dashoffset: .55;
  opacity: .7;
}

.uvq12-it [aria-selected="true"] path {
  stroke-dashoffset: 0;
}

.uvq12-it .out path {
  stroke-dashoffset: -1;
  transition-duration: calc(0.4s / var(--k));
}

.uvq12-it .rs path {
  transition: none;
}

.uvq12-it .pn {
  margin: .9em .2em 0;
  min-height: 3em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-size: 1em;
  line-height: 1.5;
  color: color-mix(in srgb,var(--fg) 78%,transparent);
  animation: uvq12-it calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq12-it {
  from {
    opacity: 0;
    filter: blur(3px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq12-it,.uvq12-it *,.uvq12-it *::before,.uvq12-it *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq12-it").forEach(el => {
  const ps=[...el.querySelectorAll('[role="tabpanel"]')];const tb=[...el.querySelectorAll('[role="tab"]')];const sel=(t,f)=>{const i=tb.indexOf(t);const o=tb.find(x=>x!==t&&x.getAttribute("aria-selected")==="true");if(o){o.classList.add("out");setTimeout(()=>{o.classList.add("rs");o.classList.remove("out");void o.offsetWidth;o.classList.remove("rs")},450)}tb.forEach((x,j)=>{x.setAttribute("aria-selected",String(j===i));x.tabIndex=j===i?0:-1});ps.forEach((p,j)=>{p.hidden=j!==i});if(f)t.focus()};tb.forEach(t=>t.addEventListener("click",()=>sel(t)));el.addEventListener("keydown",e=>{const i=tb.indexOf(document.activeElement);if(i<0)return;const n={ArrowRight:i+1,ArrowDown:i+1,ArrowLeft:i-1,ArrowUp:i-1,Home:0,End:tb.length-1}[e.key];if(n===undefined)return;e.preventDefault();sel(tb[(n+tb.length)%tb.length],1)});
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq12-it {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 21em;
}

.uvq12-it [role="tablist"] {
  display: flex;
  gap: 1.2em;
  padding: 0 .2em .55em;
  border-bottom: 1px solid color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq12-it [role="tab"] {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  padding: .2em .1em .5em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-style: italic;
  font-size: 1.3em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq12-it [role="tab"]:hover,.uvq12-it [role="tab"][aria-selected="true"] {
  color: var(--fg);
}

.uvq12-it [role="tab"]:active {
  transform: translateY(1px);
}

.uvq12-it [role="tab"]:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
  border-radius: .2em;
}

.uvq12-it svg {
  position: absolute;
  left: -.15em;
  bottom: 0;
  width: calc(100% + .3em);
  height: .55em;
  overflow: visible;
}

.uvq12-it path {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq12-it [role="tab"]:not([aria-selected="true"]):hover path {
  stroke: var(--c2);
  stroke-dashoffset: .55;
  opacity: .7;
}

.uvq12-it [aria-selected="true"] path {
  stroke-dashoffset: 0;
}

.uvq12-it .out path {
  stroke-dashoffset: -1;
  transition-duration: calc(0.4s / var(--k));
}

.uvq12-it .rs path {
  transition: none;
}

.uvq12-it .pn {
  margin: .9em .2em 0;
  min-height: 3em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-size: 1em;
  line-height: 1.5;
  color: color-mix(in srgb,var(--fg) 78%,transparent);
  animation: uvq12-it calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq12-it {
  from {
    opacity: 0;
    filter: blur(3px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq12-it,.uvq12-it *,.uvq12-it *::before,.uvq12-it *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ps=[...el.querySelectorAll('[role="tabpanel"]')];const tb=[...el.querySelectorAll('[role="tab"]')];const sel=(t,f)=>{const i=tb.indexOf(t);const o=tb.find(x=>x!==t&&x.getAttribute("aria-selected")==="true");if(o){o.classList.add("out");setTimeout(()=>{o.classList.add("rs");o.classList.remove("out");void o.offsetWidth;o.classList.remove("rs")},450)}tb.forEach((x,j)=>{x.setAttribute("aria-selected",String(j===i));x.tabIndex=j===i?0:-1});ps.forEach((p,j)=>{p.hidden=j!==i});if(f)t.focus()};tb.forEach(t=>t.addEventListener("click",()=>sel(t)));el.addEventListener("keydown",e=>{const i=tb.indexOf(document.activeElement);if(i<0)return;const n={ArrowRight:i+1,ArrowDown:i+1,ArrowLeft:i-1,ArrowUp:i-1,Home:0,End:tb.length-1}[e.key];if(n===undefined)return;e.preventDefault();sel(tb[(n+tb.length)%tb.length],1)});
}

export default function NavInkTabs() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#2f5fd0",
          "--c2": "#a8a29e",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq12-it"><div role="tablist" aria-label="Sections"><button type="button" role="tab" id="uvq12-it-t0" aria-selected="true" aria-controls="uvq12-it-p0" tabIndex={0}><span>Essays</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 7c18-4 30 3 48 0s32-3 48 1" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t1" aria-selected="false" aria-controls="uvq12-it-p1" tabIndex={-1}><span>Notes</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M3 8c10-5 22 2 34-1s30-4 60 0" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t2" aria-selected="false" aria-controls="uvq12-it-p2" tabIndex={-1}><span>Letters</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 6c20 3 40-3 60 0s25 2 36-1" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t3" aria-selected="false" aria-controls="uvq12-it-p3" tabIndex={-1}><span>Poems</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 8c15-3 25 1 45-2s35 3 51 0" pathLength="1" /></svg></button></div><div className="pn" role="tabpanel" id="uvq12-it-p0" aria-labelledby="uvq12-it-t0">Twelve short pieces about the city and its noise.</div><div className="pn" role="tabpanel" id="uvq12-it-p1" aria-labelledby="uvq12-it-t1" hidden={true}>Loose notes, lists and lines overheard on the train.</div><div className="pn" role="tabpanel" id="uvq12-it-p2" aria-labelledby="uvq12-it-t2" hidden={true}>Letters to friends who live far away.</div><div className="pn" role="tabpanel" id="uvq12-it-p3" aria-labelledby="uvq12-it-t3" hidden={true}>Short verses written before dawn.</div></div>
      </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 “Fountain pen underline tabs” block (Navigation) from AIMRAN Library to my project.

## What it is
Italic serif tabs where an ink stroke draws itself under the chosen one and wipes away from the previous one.

## Chosen settings
- Main color: #2f5fd0
- Secondary color: #a8a29e
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Secciones"

## 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
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq12-it {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 21em;
}

.uvq12-it [role="tablist"] {
  display: flex;
  gap: 1.2em;
  padding: 0 .2em .55em;
  border-bottom: 1px solid color-mix(in srgb,var(--fg) 12%,transparent);
}

.uvq12-it [role="tab"] {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  padding: .2em .1em .5em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-style: italic;
  font-size: 1.3em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq12-it [role="tab"]:hover,.uvq12-it [role="tab"][aria-selected="true"] {
  color: var(--fg);
}

.uvq12-it [role="tab"]:active {
  transform: translateY(1px);
}

.uvq12-it [role="tab"]:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
  border-radius: .2em;
}

.uvq12-it svg {
  position: absolute;
  left: -.15em;
  bottom: 0;
  width: calc(100% + .3em);
  height: .55em;
  overflow: visible;
}

.uvq12-it path {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq12-it [role="tab"]:not([aria-selected="true"]):hover path {
  stroke: var(--c2);
  stroke-dashoffset: .55;
  opacity: .7;
}

.uvq12-it [aria-selected="true"] path {
  stroke-dashoffset: 0;
}

.uvq12-it .out path {
  stroke-dashoffset: -1;
  transition-duration: calc(0.4s / var(--k));
}

.uvq12-it .rs path {
  transition: none;
}

.uvq12-it .pn {
  margin: .9em .2em 0;
  min-height: 3em;
  font-family: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  font-size: 1em;
  line-height: 1.5;
  color: color-mix(in srgb,var(--fg) 78%,transparent);
  animation: uvq12-it calc(0.5s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq12-it {
  from {
    opacity: 0;
    filter: blur(3px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq12-it,.uvq12-it *,.uvq12-it *::before,.uvq12-it *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const ps=[...el.querySelectorAll('[role="tabpanel"]')];const tb=[...el.querySelectorAll('[role="tab"]')];const sel=(t,f)=>{const i=tb.indexOf(t);const o=tb.find(x=>x!==t&&x.getAttribute("aria-selected")==="true");if(o){o.classList.add("out");setTimeout(()=>{o.classList.add("rs");o.classList.remove("out");void o.offsetWidth;o.classList.remove("rs")},450)}tb.forEach((x,j)=>{x.setAttribute("aria-selected",String(j===i));x.tabIndex=j===i?0:-1});ps.forEach((p,j)=>{p.hidden=j!==i});if(f)t.focus()};tb.forEach(t=>t.addEventListener("click",()=>sel(t)));el.addEventListener("keydown",e=>{const i=tb.indexOf(document.activeElement);if(i<0)return;const n={ArrowRight:i+1,ArrowDown:i+1,ArrowLeft:i-1,ArrowUp:i-1,Home:0,End:tb.length-1}[e.key];if(n===undefined)return;e.preventDefault();sel(tb[(n+tb.length)%tb.length],1)});
}

export default function NavInkTabs() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#2f5fd0",
          "--c2": "#a8a29e",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq12-it"><div role="tablist" aria-label="Sections"><button type="button" role="tab" id="uvq12-it-t0" aria-selected="true" aria-controls="uvq12-it-p0" tabIndex={0}><span>Essays</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 7c18-4 30 3 48 0s32-3 48 1" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t1" aria-selected="false" aria-controls="uvq12-it-p1" tabIndex={-1}><span>Notes</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M3 8c10-5 22 2 34-1s30-4 60 0" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t2" aria-selected="false" aria-controls="uvq12-it-p2" tabIndex={-1}><span>Letters</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 6c20 3 40-3 60 0s25 2 36-1" pathLength="1" /></svg></button><button type="button" role="tab" id="uvq12-it-t3" aria-selected="false" aria-controls="uvq12-it-p3" tabIndex={-1}><span>Poems</span><svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true"><path d="M2 8c15-3 25 1 45-2s35 3 51 0" pathLength="1" /></svg></button></div><div className="pn" role="tabpanel" id="uvq12-it-p0" aria-labelledby="uvq12-it-t0">Twelve short pieces about the city and its noise.</div><div className="pn" role="tabpanel" id="uvq12-it-p1" aria-labelledby="uvq12-it-t1" hidden={true}>Loose notes, lists and lines overheard on the train.</div><div className="pn" role="tabpanel" id="uvq12-it-p2" aria-labelledby="uvq12-it-t2" hidden={true}>Letters to friends who live far away.</div><div className="pn" role="tabpanel" id="uvq12-it-p3" aria-labelledby="uvq12-it-t3" hidden={true}>Short verses written before dawn.</div></div>
      </div>
    </>
  );
}
```

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