🔍 Cloth Button
Elevate your interface with the Cloth Button, a texture-inspired React component designed for a tactile user experience. Ideal for primary actions, form submissions, or interactive elements, this button enhances visual appeal with its fabric-like appearance—whether it's used for navigation, confirmations, or key user interactions. The subtle textile styling adds dimension and uniqueness to your application.
Meet the Designer
Preview
Follow below steps 👇🏻
Install dependencies
1npm i clsx tailwind-merge
Utils
Create a lib/utils.ts file and paste this code
1import { ClassValue, clsx } from 'clsx';2import { twMerge } from 'tailwind-merge';34export function cn(...inputs: ClassValue[]) {5return twMerge(clsx(inputs));6}
Component
Create a file cloth-button.tsx in your components folder and paste this code
1import React from 'react';2import { ClassValue } from 'clsx';3import { cn } from '@/lib/utils';45type ClothButtonProps = {6children: React.ReactNode;7className?: ClassValue;8} & React.ButtonHTMLAttributes<HTMLButtonElement>;910const ClothButton = ({ children, className, ...props }: ClothButtonProps) => {11return (12<button13{...props}14className={cn('bg-slate-100/95 rounded-full overflow-hidden relative', className)}15>16<div17className={cn(18'absolute inset-0',19'[background-size:3px_3px]',20'[background-image:linear-gradient(45deg,rgba(255,255,255,0.4)_1px,transparent_1px),linear-gradient(135deg,rgba(255,255,255,0.4)_1px,transparent_1px)]'21)}22style={{23transformOrigin: 'center center'24}}25/>2627<div28className={cn(29'absolute inset-0',30'[background-size:3px_3px]',31'[background-image:linear-gradient(45deg,transparent_45%,rgba(0,0,0,0.1)_45%,rgba(0,0,0,0.1)_55%,transparent_55%),linear-gradient(135deg,transparent_45%,rgba(0,0,0,0.1)_45%,rgba(0,0,0,0.1)_55%,transparent_55%)]'32)}33style={{34transformOrigin: 'center center'35}}36/>3738<div39className={cn(40'absolute inset-0',41'[background-size:6px_6px]',42'[background-image:radial-gradient(circle,rgba(255,255,255,1)_0.3px,transparent_0.2px)]'43)}44/>4546<div47className={cn(48'absolute inset-0',49'[background-size:3px_3px]',50'[background-image:radial-gradient(circle,rgba(0,0,0,0.3)_0.3px,transparent_0.2px)]'51)}52/>5354<div55style={{56boxShadow: 'inset 0px 0px 4px 1px rgba(0, 0, 0, 1)'57}}58className="absolute inset-0 rounded-full"59/>6061<div62className={cn(63'm-0.5 px-6 py-3 rounded-full relative overflow-hidden',64'group hover:shadow-black/50 hover:shadow-md transition-all duration-200'65)}66>67<div68className={cn(69'absolute inset-0',70'[background-size:3px_3px]',71'[background-image:linear-gradient(45deg,rgba(255,255,255,0.4)_1px,transparent_1px),linear-gradient(135deg,rgba(255,255,255,0.4)_1px,transparent_1px)]'72)}73style={{74transformOrigin: 'center center'75}}76/>7778<div79className={cn(80'absolute inset-0',81'[background-size:3px_3px]',82'[background-image:linear-gradient(45deg,transparent_45%,rgba(0,0,0,0.1)_45%,rgba(0,0,0,0.1)_55%,transparent_55%),linear-gradient(135deg,transparent_45%,rgba(0,0,0,0.1)_45%,rgba(0,0,0,0.1)_55%,transparent_55%)]'83)}84style={{85transformOrigin: 'center center'86}}87/>8889<div90className={cn(91'absolute inset-0',92'[background-size:6px_6px]',93'[background-image:radial-gradient(circle,rgba(255,255,255,1)_0.3px,transparent_0.2px)]'94)}95/>9697<div98className={cn(99'absolute inset-0',100'[background-size:3px_3px]',101'[background-image:radial-gradient(circle,rgba(0,0,0,0.3)_0.3px,transparent_0.2px)]'102)}103/>104105<div className="absolute inset-0 rounded-full shadow-inner shadow-black/30 border-[1px] border-transparent border-dashed group-hover:border-white/10 group-hover:shadow-white/40 group-active:shadow-black transition-all duration-200 bg-gradient-to-r from-[#111e29]/60 to-[#041624]/60" />106107<div className="absolute inset-0 rounded-full border-[1px] border-dashed border-white/10" />108109<div className="relative inline-block ">110<div111style={{112textShadow: '0px 0.5px 1px rgba(0, 0, 0, 1)',113color: 'rgba(50, 50, 50, 0.9)',114position: 'absolute',115filter: 'blur(0.5px)',116top: '1px',117left: '0px',118zIndex: 1119}}120className="font-semibold"121>122{children}123</div>124125<div126style={{127position: 'absolute',128top: '-0.5px',129left: '0.1px',130zIndex: 2131}}132className="text-white/50 font-semibold whitespace-nowrap"133>134{children}135</div>136137<div138style={{139position: 'relative',140zIndex: 3141}}142className="bg-clip-text text-transparent bg-gradient-to-r from-[#d7e3ef] via-[#6E818F] to-[#4e606e] font-semibold"143>144{children}145</div>146</div>147</div>148</button>149);150};151152export default ClothButton;
Usage
1<ClothButton>2<p>Cloth Button</p>3</ClothButton>
⭐️ Got a question or feedback?
Feel free to reach out!