"use client";
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
import { cn } from "@/lib/cn";
export type LinenTabButtonProps = Readonly<
{
children?: ReactNode;
} & ComponentPropsWithoutRef<"button">
>;
const LINEN_BODY =
"linear-gradient(180deg, #f8f4ee 0%, #ebe4d8 55%, #dfd6c8 100%)";
const LINEN_WEAVE =
"repeating-linear-gradient(90deg, rgba(120,113,108,0.04) 0 1px, transparent 1px 4px), repeating-linear-gradient(0deg, rgba(120,113,108,0.03) 0 1px, transparent 1px 5px)";
export const LinenTabButton = forwardRef<
HTMLButtonElement,
LinenTabButtonProps
>(
(
{
children = "View details",
className,
type = "button",
disabled,
...props
},
ref,
) => {
return (
<button
ref={ref}
type={type}
disabled={disabled}
data-slot="linen-tab-button"
className={cn(
"relative isolate overflow-hidden rounded-lg border border-[#d4cbc0] px-6 py-3 text-[1rem] ring-0 outline-none",
"font-sans font-medium tracking-tight text-neutral-800",
"shadow-[0_1px_0_rgba(255,255,255,0.85),0_6px_14px_rgba(120,113,108,0.16),inset_0_1px_0_rgba(255,255,255,0.65)]",
"transition-[transform,box-shadow,filter] duration-200 ease-out",
"hover:brightness-[1.02] active:translate-y-px active:brightness-[0.98]",
"motion-reduce:transition-none motion-reduce:hover:brightness-100 motion-reduce:active:translate-y-0",
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600",
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
style={{ background: LINEN_BODY }}
{...props}
>
<span
aria-hidden="true"
data-layer="linen-weave"
className="pointer-events-none absolute inset-0 opacity-80"
style={{ background: LINEN_WEAVE }}
/>
<span
aria-hidden="true"
data-layer="linen-stitch-top"
className="pointer-events-none absolute inset-x-3 top-1.5 border-t border-dashed border-[#c4b8aa]/80"
/>
<span
aria-hidden="true"
data-layer="linen-stitch-bottom"
className="pointer-events-none absolute inset-x-3 bottom-1.5 border-b border-dashed border-[#c4b8aa]/80"
/>
<span
aria-hidden="true"
data-layer="linen-fold"
className="pointer-events-none absolute inset-0"
style={{
background:
"linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 28%, rgba(87,83,78,0.05) 100%)",
}}
/>
<span data-layer="linen-label" className="relative z-1">
{children}
</span>
</button>
);
},
);
LinenTabButton.displayName = "LinenTabButton";
Linen Tab Button
By Bidyut
Try the interaction, copy the React source files, or download the complete example.
About Linen Tab Button
Linen Tab Button is an animated React and Tailwind CSS button by Bidyut. Try the interaction, copy the React source, or download the example with creator credit.
- Effects and categories
- Hover effects, Animated
- Using this example
- Copy a TSX file or download the original source and standalone demo. Test keyboard focus, motion and contrast in your own project.
Usage, Tailwind and licensing questions
Read the source files
import-examples/linen-tab-button.tsx
import {LinenTabButton} from "@/components/buttons/linen-tab-button";
export default function Demo(){return (<LinenTabButton>View details</LinenTabButton>);}components/buttons/linen-tab-button.tsx
"use client";
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
import { cn } from "@/lib/cn";
export type LinenTabButtonProps = Readonly<
{
children?: ReactNode;
} & ComponentPropsWithoutRef<"button">
>;
const LINEN_BODY =
"linear-gradient(180deg, #f8f4ee 0%, #ebe4d8 55%, #dfd6c8 100%)";
const LINEN_WEAVE =
"repeating-linear-gradient(90deg, rgba(120,113,108,0.04) 0 1px, transparent 1px 4px), repeating-linear-gradient(0deg, rgba(120,113,108,0.03) 0 1px, transparent 1px 5px)";
export const LinenTabButton = forwardRef<
HTMLButtonElement,
LinenTabButtonProps
>(
(
{
children = "View details",
className,
type = "button",
disabled,
...props
},
ref,
) => {
return (
<button
ref={ref}
type={type}
disabled={disabled}
data-slot="linen-tab-button"
className={cn(
"relative isolate overflow-hidden rounded-lg border border-[#d4cbc0] px-6 py-3 text-[1rem] ring-0 outline-none",
"font-sans font-medium tracking-tight text-neutral-800",
"shadow-[0_1px_0_rgba(255,255,255,0.85),0_6px_14px_rgba(120,113,108,0.16),inset_0_1px_0_rgba(255,255,255,0.65)]",
"transition-[transform,box-shadow,filter] duration-200 ease-out",
"hover:brightness-[1.02] active:translate-y-px active:brightness-[0.98]",
"motion-reduce:transition-none motion-reduce:hover:brightness-100 motion-reduce:active:translate-y-0",
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600",
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
style={{ background: LINEN_BODY }}
{...props}
>
<span
aria-hidden="true"
data-layer="linen-weave"
className="pointer-events-none absolute inset-0 opacity-80"
style={{ background: LINEN_WEAVE }}
/>
<span
aria-hidden="true"
data-layer="linen-stitch-top"
className="pointer-events-none absolute inset-x-3 top-1.5 border-t border-dashed border-[#c4b8aa]/80"
/>
<span
aria-hidden="true"
data-layer="linen-stitch-bottom"
className="pointer-events-none absolute inset-x-3 bottom-1.5 border-b border-dashed border-[#c4b8aa]/80"
/>
<span
aria-hidden="true"
data-layer="linen-fold"
className="pointer-events-none absolute inset-0"
style={{
background:
"linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 28%, rgba(87,83,78,0.05) 100%)",
}}
/>
<span data-layer="linen-label" className="relative z-1">
{children}
</span>
</button>
);
},
);
LinenTabButton.displayName = "LinenTabButton";
lib/cn.ts
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
demo.tsx
export { default as default } from "@/import-examples/linen-tab-button";CSS
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties;
@layer theme, base, components, utilities;
@layer theme {
:root, :host {
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, Monaco,
Consolas, monospace;
--color-amber-600: oklch(66.6% 0.179 58.318);
--color-neutral-800: oklch(26.9% 0 none);
--spacing: 0.25rem;
--font-weight-medium: 500;
--tracking-tight: -0.025em;
--ease-out: cubic-bezier(0, 0, 0.2, 1);
--default-transition-duration: 150ms;
--default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
--default-font-family: var(--font-sans);
--default-mono-font-family: var(--font-mono);
}
}
@layer base {
*, ::after, ::before, ::backdrop, ::file-selector-button {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0 solid;
}
html, :host {
line-height: 1.5;
-webkit-text-size-adjust: 100%;
tab-size: 4;
font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
font-feature-settings: var(--default-font-feature-settings, normal);
font-variation-settings: var(--default-font-variation-settings, normal);
-webkit-tap-highlight-color: transparent;
}
hr {
height: 0;
color: inherit;
border-top-width: 1px;
}
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
h1, h2, h3, h4, h5, h6 {
font-size: inherit;
font-weight: inherit;
}
a {
color: inherit;
-webkit-text-decoration: inherit;
text-decoration: inherit;
}
b, strong {
font-weight: bolder;
}
code, kbd, samp, pre {
font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
font-feature-settings: var(--default-mono-font-feature-settings, normal);
font-variation-settings: var(--default-mono-font-variation-settings, normal);
font-size: 1em;
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
table {
text-indent: 0;
border-color: inherit;
border-collapse: collapse;
}
:-moz-focusring:where(:not(iframe)) {
outline: auto;
}
progress {
vertical-align: baseline;
}
summary {
display: list-item;
}
ol, ul, menu {
list-style: none;
}
img, svg, video, canvas, audio, iframe, embed, object {
display: block;
vertical-align: middle;
}
img, video {
max-width: 100%;
height: auto;
}
button, input, select, optgroup, textarea, ::file-selector-button {
font: inherit;
font-feature-settings: inherit;
font-variation-settings: inherit;
letter-spacing: inherit;
color: inherit;
border-radius: 0;
background-color: transparent;
opacity: 1;
}
:where(select:is([multiple], [size])) optgroup {
font-weight: bolder;
}
:where(select:is([multiple], [size])) optgroup option {
padding-inline-start: 20px;
}
::file-selector-button {
margin-inline-end: 4px;
}
::placeholder {
opacity: 1;
}
@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {
::placeholder {
color: currentcolor;
@supports (color: color-mix(in lab, red, red)) {
color: color-mix(in oklab, currentcolor 50%, transparent);
}
}
}
textarea {
resize: vertical;
}
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-date-and-time-value {
min-height: 1lh;
text-align: inherit;
}
::-webkit-datetime-edit {
display: inline-flex;
}
::-webkit-datetime-edit-fields-wrapper {
padding: 0;
}
::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {
padding-block: 0;
}
::-webkit-calendar-picker-indicator {
line-height: 1;
}
:-moz-ui-invalid {
box-shadow: none;
}
button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button {
appearance: button;
}
::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
height: auto;
}
[hidden]:where(:not([hidden="until-found"])) {
display: none !important;
}
}
@layer utilities {
.pointer-events-none {
pointer-events: none;
}
.absolute {
position: absolute;
}
.relative {
position: relative;
}
.inset-0 {
inset: 0px;
}
.inset-x-3 {
inset-inline: calc(var(--spacing) * 3);
}
.top-1\.5 {
top: calc(var(--spacing) * 1.5);
}
.bottom-1\.5 {
bottom: calc(var(--spacing) * 1.5);
}
.isolate {
isolation: isolate;
}
.z-1 {
z-index: 1;
}
.overflow-hidden {
overflow: hidden;
}
.rounded-lg {
border-radius: var(--radius);
}
.border {
border-style: var(--tw-border-style);
border-width: 1px;
}
.border-t {
border-top-style: var(--tw-border-style);
border-top-width: 1px;
}
.border-b {
border-bottom-style: var(--tw-border-style);
border-bottom-width: 1px;
}
.border-dashed {
--tw-border-style: dashed;
border-style: dashed;
}
.border-\[\#c4b8aa\]\/80 {
border-color: color-mix(in oklab, #c4b8aa 80%, transparent);
}
.border-\[\#d4cbc0\] {
border-color: #d4cbc0;
}
.px-6 {
padding-inline: calc(var(--spacing) * 6);
}
.py-3 {
padding-block: calc(var(--spacing) * 3);
}
.font-sans {
font-family: var(--font-sans);
}
.text-\[1rem\] {
font-size: 1rem;
}
.font-medium {
--tw-font-weight: var(--font-weight-medium);
font-weight: var(--font-weight-medium);
}
.tracking-tight {
--tw-tracking: var(--tracking-tight);
letter-spacing: var(--tracking-tight);
}
.text-neutral-800 {
color: var(--color-neutral-800);
}
.opacity-80 {
opacity: 80%;
}
.shadow-\[0_1px_0_rgba\(255\,255\,255\,0\.85\)\,0_6px_14px_rgba\(120\,113\,108\,0\.16\)\,inset_0_1px_0_rgba\(255\,255\,255\,0\.65\)\] {
--tw-shadow: 0 1px 0 var(--tw-shadow-color, rgba(255,255,255,0.85)), 0 6px 14px var(--tw-shadow-color, rgba(120,113,108,0.16)), inset 0 1px 0 var(--tw-shadow-color, rgba(255,255,255,0.65));
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
.ring-0 {
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
.transition-\[transform\,box-shadow\,filter\] {
transition-property: transform,box-shadow,filter;
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
transition-duration: var(--tw-duration, var(--default-transition-duration));
}
.duration-200 {
--tw-duration: 200ms;
transition-duration: 200ms;
}
.ease-out {
--tw-ease: var(--ease-out);
transition-timing-function: var(--ease-out);
}
.outline-none {
--tw-outline-style: none;
outline-style: none;
}
@media (hover: hover) {
.hover\:brightness-\[1\.02\]:hover {
--tw-brightness: brightness(1.02);
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
}
.focus-visible\:outline-2:focus-visible {
outline-style: var(--tw-outline-style);
outline-width: 2px;
}
.focus-visible\:outline-offset-2:focus-visible {
outline-offset: 2px;
}
.focus-visible\:outline-amber-600:focus-visible {
outline-color: var(--color-amber-600);
}
.active\:translate-y-px:active {
--tw-translate-y: 1px;
translate: var(--tw-translate-x) var(--tw-translate-y);
}
.active\:brightness-\[0\.98\]:active {
--tw-brightness: brightness(0.98);
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
.disabled\:pointer-events-none:disabled {
pointer-events: none;
}
.disabled\:cursor-not-allowed:disabled {
cursor: not-allowed;
}
.disabled\:opacity-50:disabled {
opacity: 50%;
}
@media (prefers-reduced-motion: reduce) {
.motion-reduce\:transition-none {
transition-property: none;
}
@media (hover: hover) {
.motion-reduce\:hover\:brightness-100:hover {
--tw-brightness: brightness(100%);
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
}
.motion-reduce\:active\:translate-y-0:active {
--tw-translate-y: 0px;
translate: var(--tw-translate-x) var(--tw-translate-y);
}
}
}
:root {
--background: #fff;
--foreground: #111;
--primary: #171717;
--primary-foreground: #fff;
--secondary: #eee;
--secondary-foreground: #171717;
--muted: #eee;
--muted-foreground: #666;
--accent: #eee;
--accent-foreground: #171717;
--border: #ddd;
--input: #ddd;
--ring: #777;
--destructive: #dc2626;
--destructive-foreground: #fff;
--popover: #fff;
--popover-foreground: #111;
--success: #15803d;
--success-foreground: #fff;
--radius: .625rem;
--hairline: 1px;
}
.dark {
--background: #090909;
--foreground: #fafafa;
--primary: #fafafa;
--primary-foreground: #171717;
--secondary: #262626;
--secondary-foreground: #fafafa;
--muted: #262626;
--muted-foreground: #a3a3a3;
--accent: #262626;
--accent-foreground: #fafafa;
--border: #333;
--input: #333;
--popover: #171717;
--popover-foreground: #fafafa;
}
@keyframes code-panel-shift {
0%, 100% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
}
@keyframes caret-blink {
0%, 49% {
opacity: 1;
}
50%, 100% {
opacity: 0;
}
}
@keyframes wave-hand {
0%, 100% {
transform: rotate(0deg);
}
50% {
transform: rotate(-12deg);
}
}
@keyframes marketing-go-back-in {
from {
opacity: 0;
transform: translateX(-6px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes showcase-fade-in {
from {
opacity: 0;
transform: translateY(3px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes watch-ring-draw-outer {
from {
stroke-dasharray: 0 163;
}
to {
stroke-dasharray: 121 163;
}
}
@keyframes watch-ring-draw-middle {
from {
stroke-dasharray: 0 119;
}
to {
stroke-dasharray: 74 119;
}
}
@keyframes watch-ring-draw-inner {
from {
stroke-dasharray: 0 75;
}
to {
stroke-dasharray: 66 75;
}
}
@keyframes watch-brand-line {
from {
opacity: 0;
transform: translateY(5px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes showcase-progress {
0% {
transform: scaleX(0.12);
}
100% {
transform: scaleX(0.96);
}
}
@keyframes showcase-art-zoom {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.07);
}
}
@keyframes ipod-bar {
0%, 100% {
transform: scaleY(0.28);
}
50% {
transform: scaleY(1);
}
}
@property --tw-border-style {
syntax: "*";
inherits: false;
initial-value: solid;
}
@property --tw-font-weight {
syntax: "*";
inherits: false;
}
@property --tw-tracking {
syntax: "*";
inherits: false;
}
@property --tw-shadow {
syntax: "*";
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-shadow-color {
syntax: "*";
inherits: false;
}
@property --tw-shadow-alpha {
syntax: "<percentage>";
inherits: false;
initial-value: 100%;
}
@property --tw-inset-shadow {
syntax: "*";
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-inset-shadow-color {
syntax: "*";
inherits: false;
}
@property --tw-inset-shadow-alpha {
syntax: "<percentage>";
inherits: false;
initial-value: 100%;
}
@property --tw-ring-color {
syntax: "*";
inherits: false;
}
@property --tw-ring-shadow {
syntax: "*";
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-inset-ring-color {
syntax: "*";
inherits: false;
}
@property --tw-inset-ring-shadow {
syntax: "*";
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-ring-inset {
syntax: "*";
inherits: false;
}
@property --tw-ring-offset-width {
syntax: "<length>";
inherits: false;
initial-value: 0px;
}
@property --tw-ring-offset-color {
syntax: "*";
inherits: false;
initial-value: #fff;
}
@property --tw-ring-offset-shadow {
syntax: "*";
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-duration {
syntax: "*";
inherits: false;
}
@property --tw-ease {
syntax: "*";
inherits: false;
}
@property --tw-blur {
syntax: "*";
inherits: false;
}
@property --tw-brightness {
syntax: "*";
inherits: false;
}
@property --tw-contrast {
syntax: "*";
inherits: false;
}
@property --tw-grayscale {
syntax: "*";
inherits: false;
}
@property --tw-hue-rotate {
syntax: "*";
inherits: false;
}
@property --tw-invert {
syntax: "*";
inherits: false;
}
@property --tw-opacity {
syntax: "*";
inherits: false;
}
@property --tw-saturate {
syntax: "*";
inherits: false;
}
@property --tw-sepia {
syntax: "*";
inherits: false;
}
@property --tw-drop-shadow {
syntax: "*";
inherits: false;
}
@property --tw-drop-shadow-color {
syntax: "*";
inherits: false;
}
@property --tw-drop-shadow-alpha {
syntax: "<percentage>";
inherits: false;
initial-value: 100%;
}
@property --tw-drop-shadow-size {
syntax: "*";
inherits: false;
}
@property --tw-outline-style {
syntax: "*";
inherits: false;
initial-value: solid;
}
@property --tw-translate-x {
syntax: "*";
inherits: false;
initial-value: 0;
}
@property --tw-translate-y {
syntax: "*";
inherits: false;
initial-value: 0;
}
@property --tw-translate-z {
syntax: "*";
inherits: false;
initial-value: 0;
}
@layer properties {
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
*, ::before, ::after, ::backdrop {
--tw-border-style: solid;
--tw-font-weight: initial;
--tw-tracking: initial;
--tw-shadow: 0 0 #0000;
--tw-shadow-color: initial;
--tw-shadow-alpha: 100%;
--tw-inset-shadow: 0 0 #0000;
--tw-inset-shadow-color: initial;
--tw-inset-shadow-alpha: 100%;
--tw-ring-color: initial;
--tw-ring-shadow: 0 0 #0000;
--tw-inset-ring-color: initial;
--tw-inset-ring-shadow: 0 0 #0000;
--tw-ring-inset: initial;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-offset-shadow: 0 0 #0000;
--tw-duration: initial;
--tw-ease: initial;
--tw-blur: initial;
--tw-brightness: initial;
--tw-contrast: initial;
--tw-grayscale: initial;
--tw-hue-rotate: initial;
--tw-invert: initial;
--tw-opacity: initial;
--tw-saturate: initial;
--tw-sepia: initial;
--tw-drop-shadow: initial;
--tw-drop-shadow-color: initial;
--tw-drop-shadow-alpha: 100%;
--tw-drop-shadow-size: initial;
--tw-outline-style: solid;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-translate-z: 0;
}
}
}