Skip to main content

Button

import { Button } from "tawuniya/components";

👉 View in Storybook


Props​

PropTypeDefaultDescription
variant"default" | "primary" | "secondary" | "destructive" | "warning" | "info" | "success" | "outline" | "outline_muted" | "plain" | "ghost" | "smooth" | "smooth_destructive" | "solid_smooth" | "solid_smooth_destructive""primary"Visual style of the button.
size"default" | "sm" | "md" | "lg" | "icon""default"Size of the button.
rounded"sm" | "md" | "lg" | "xl" | "full""lg"Border radius of the button.
shadow"sm" | "md" | "lg" | "xl"—Shadow depth of the button.
fullWidthbooleanfalseIf true, the button will take the full width of its container.
asChildbooleanfalseIf true, renders the button as a child component using Radix UI's Slot.
...propsReact.ButtonHTMLAttributes<HTMLButtonElement>—Any other standard button props.
badgeReactNode (optional)—Displays a badge or notification dot on the button. Can be any React node, e.g., a number, icon, or small element.
badgeClassNamestring (optional)—Additional classes applied to the badge element for custom styling.
wrapperClassNamestring (optional)—Additional classes applied to the wrapper element for custom styling.
loadingbooleanfalseIf true, the button will show a loading spinner.

Variants​

Variant​

ValuePreview
defaultNeutral background with default text color.
primaryPrimary background and foreground color.
secondarySecondary background and foreground color.
destructiveRed destructive background and foreground.
warningYellow warning background.
infoBlue informational background.
successGreen success background.
outlineTransparent background with border.
outline_mutedTransparent background with muted border.
plainTransparent background, colored text.
ghostTransparent background, subtle text.
smoothLow-opacity background, hover effect.
smooth_destructiveLow-opacity red background.
solid_smoothSolid but soft background color.
solid_smooth_destructiveSolid but soft red background.

Size​

ValueHeight / Padding
defaulth-10, medium padding.
smh-[38px], smaller text & padding.
mdh-12, medium size.
lgh-14, larger text & padding.
iconh-10 w-10, square icon button.

Rounded​

ValueRadius Class
smrounded
mdrounded-md
lgrounded-lg
xlrounded-xl
fullrounded-full

Shadow​

ValueTailwind Class
smshadow
mdshadow-md
lgshadow-lg
xlshadow-xl

Usage Examples​

Basic Button​

<Button>Click Me</Button>

Primary Large Button​

<Button variant="primary" size="lg">
Submit
</Button>

Full Width Button​

<Button fullWidth>Continue</Button>

Icon Button​

<Button size="icon">
<Icon name="search" />
</Button>

Button with Shadow & Rounded​

<Button shadow="lg" rounded="full">
Rounded Shadow
</Button>

Button with Badge​

<Button badge={<CustomIcon />}>Rounded Shadow</Button>

AsChild Example​

<Button asChild>
<a href="/profile">Go to Profile</a>
</Button>

Loading Button​

<Button loading>Click Me</Button>

Accessibility​

  • Always provide a clear label for buttons.
  • Use aria-label for icon-only buttons.
  • Disabled state prevents interaction and applies reduced opacity.