Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions apps/docs/content/1.component/ink-stroke-button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: Ink Stroke Button
description: A teal button with lime ink that flows under the cursor, simulated as a fluid in WebGL.
icon: brush
---

A teal call-to-action with **lime ink that flows under your cursor**. The ink
is a small fluid simulation in WebGL. **The moment the cursor crosses an
edge**, from any side, a pool of ink floods about a quarter of the button
there, holds for a beat and goes. Through a side it fills a full-height
band; through the top or bottom it spreads from where the cursor crossed.
Move and the ink is **pushed along the way you go**; stop and it **curls aside** as teal washes back in
behind it, then fades in about a second. Hold still and nothing new is added.
The label is part of the picture, so it reads lime on teal and **flips to teal
under the ink**. Pressing it scales the button down to 97%, the same press as
the other Tween UI buttons.

::component-preview{name="ink-stroke-button"}
::

## Installation

::tabs
:::tabs-item{label="CLI" icon="i-lucide-terminal"}

::install-tabs{item="ink-stroke-button"}
::

:::
:::tabs-item{label="Manual" icon="i-lucide-clipboard"}

::component-source{name="ink-stroke-button"}
::

:::
::

## Usage

::tabs
:::tabs-item{label="React" icon="i-lucide-atom"}

```tsx [components/start-project.tsx]
import InkStrokeButton from '@/components/tweenui/ink-stroke-button';

export default function StartProject() {
return <InkStrokeButton onClick={() => {}}>Start a project</InkStrokeButton>;
}
```

:::
::

The canvas matches the button and is rebuilt when its size changes, so a
longer label or a full-width button works. The label is drawn with the
button's own font once fonts have loaded. The pointer is followed across the
page, but the simulation only runs while it is near the button and stops once
the ink has faded, so an idle button costs nothing. It needs WebGL 2.

::note
Each button holds one WebGL context, and browsers allow about 16 per page. A
context is only created once the button scrolls into view, which is plenty for
navbar and hero buttons; don't use it for long lists of buttons.
::

## Props

| Prop | Type | Default | Description |
| ----------- | -------- | ---------- | --------------------------------------------- |
| `children` | `string` | — | The label, drawn into the canvas on one line. |
| `type` | `string` | `'button'` | The native button type. |
| `className` | `string` | — | Extra classes for the `<button>`. |

All other native `<button>` attributes, including `ref`, `onClick` and
`disabled`, are forwarded.

## Accessibility

::note
Under `prefers-reduced-motion: reduce` no WebGL is used: on hover or focus the
button switches straight to lime with teal text, and switches back when you
leave. The same fallback is used if WebGL 2 isn't available.
::

It is a real `<button>`, named by its DOM label, which stays in place and is
only made transparent while the canvas draws it. The canvas is hidden from
assistive tech. A keyboard user has no cursor, so `:focus-visible` sweeps one
across the button for them. A focus ring sits
outside the button. Touch doesn't move the ink. In Windows high-contrast mode
the canvas is hidden and the plain label shows.
17 changes: 17 additions & 0 deletions apps/docs/public/r/ink-stroke-button-demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "ink-stroke-button-demo",
"type": "registry:example",
"title": "Ink Stroke Button Demo",
"description": "Usage examples for Ink Stroke Button.",
"registryDependencies": [
"https://tween-ui.vercel.app/r/ink-stroke-button.json"
],
"files": [
{
"path": "examples/ink-stroke-button-demo.tsx",
"type": "registry:example",
"content": "import InkStrokeButton from '@/components/tweenui/ink-stroke-button';\n\nexport default function StartProject() {\n return <InkStrokeButton onClick={() => {}}>Start a project</InkStrokeButton>;\n}"
}
]
}
24 changes: 24 additions & 0 deletions apps/docs/public/r/ink-stroke-button.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions apps/docs/public/r/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,30 @@
}
]
},
{
"name": "ink-stroke-button",
"type": "registry:ui",
"title": "Ink Stroke Button",
"description": "A teal button with lime ink that flows under the cursor. The ink is a small fluid simulation in WebGL: a pool floods in from whichever edge the cursor crosses, the ink is pushed along the way you move, curls aside when you stop and fades back to teal in about a second. The label flips colour under the ink.",
"files": [
{
"path": "components/tweenui/ink-stroke-button.tsx",
"type": "registry:component"
}
]
},
{
"name": "ink-stroke-button-demo",
"type": "registry:example",
"title": "Ink Stroke Button Demo",
"description": "Usage examples for Ink Stroke Button.",
"files": [
{
"path": "examples/ink-stroke-button-demo.tsx",
"type": "registry:example"
}
]
},
{
"name": "pricing-plan-switch",
"type": "registry:block",
Expand Down
1 change: 1 addition & 0 deletions apps/docs/registry/__index__.generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const demos: Record<string, ComponentType> = {
'theme-toggle-reveal:spiral': dynamic(() => import('./demos/theme-toggle-reveal-spiral')),
'elastic-slider:default': dynamic(() => import('./demos/elastic-slider')),
'package-command:default': dynamic(() => import('./demos/package-command')),
'ink-stroke-button:default': dynamic(() => import('./demos/ink-stroke-button')),
'pricing-plan-switch:default': dynamic(() => import('./demos/pricing-plan-switch')),
'process-card-reveal:default': dynamic(() => import('./demos/process-card-reveal')),
'process-sticky-steps:default': dynamic(() => import('./demos/process-sticky-steps')),
Expand Down
12 changes: 12 additions & 0 deletions apps/docs/registry/__sources__.generated.ts

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions apps/docs/registry/demos/ink-stroke-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client';

import InkStrokeButton from '@/registry/tweenui/ink-stroke-button';

const InkStrokeButtonDemo = () => {
return (
<div className="flex w-full justify-center px-4 py-16">
<InkStrokeButton>Start a project</InkStrokeButton>
</div>
);
};

export default InkStrokeButtonDemo;
33 changes: 33 additions & 0 deletions apps/docs/registry/registry-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,39 @@ export default function Example() {

export default function Example() {
return <PackageCommand packages={['gsap', '@gsap/react']} />;
}`,
},
},
{
name: 'ink-stroke-button',
type: 'component',
addedAt: '2026-11-08',
title: 'Ink Stroke Button',
description:
'A teal button with lime ink that flows under the cursor. The ink is a small fluid simulation in WebGL: a pool floods in from whichever edge the cursor crosses, the ink is pushed along the way you move, curls aside when you stop and fades back to teal in about a second. The label flips colour under the ink.',
media: {},
dependencies: ['gsap', '@gsap/react'],
registryDependencies: [],
cssVars: {},
files: [
{
path: 'registry/tweenui/ink-stroke-button.tsx',
target: 'components/tweenui/ink-stroke-button.tsx',
kind: 'react',
},
],
variants: [
{
id: 'default',
label: 'Preview',
reactSource: 'registry/tweenui/ink-stroke-button.tsx',
},
],
usage: {
react: `import InkStrokeButton from '@/components/tweenui/ink-stroke-button';

export default function Example() {
return <InkStrokeButton onClick={() => {}}>Start a project</InkStrokeButton>;
}`,
},
},
Expand Down
Loading
Loading