runway

Runway

Button

A versatile button component with support for color, size, shape, etc.



The Button component can be customized with various colors, sizes, and shapes, has built-in loading states, hover effects, and supports icons. It can be rendered as either a button or a Next.js Link (if you provide the href prop).



Usage

jsx

1import Button from "@/components/atoms/Button";
2
3<Button
4  color="primary"
5  size="md"
6  onClick={() => alert("Button clicked!")}
7>
8    Click Me
9</Button>


Props

PropTypeDefaultDescription
childrenReactNode-The content of the button.
size"sm" | "md" | "lg""md"The size of the button.
colorstring"primary"The base color (use tailwind.config).
borderRadiusstring"md"The border radius of the button (uses Tailwind border radius to shape component).
hoverBgbooleantrueIf true, applies a hover background color.
scalebooleanfalseIf true, gently scales up on hover.
liftbooleanfalseIf true, lifts on hover.
activebooleantrueIf true, the button has an active press-down scale effect.
borderbooleanfalseIf true, adds a border.
shadowbooleanfalseIf true, adds a subtle box-shadow.
loadingbooleanfalseIf true, shows a spinner instead of children.
disabledbooleanfalseIf true, disables the button.
iconReactNode-If provided, the button will render an icon.
iconSrcstring-If provided, the button will render an image as an icon.
hrefstring""If provided, the button becomes a Link instead of a button.
onClickfunction-The click handler for the button.
classNamestring""Additional Tailwind utility classes.
...propsobject-Any other valid HTML attributes for the button or Link.

Extend or override styles with the className prop if you need custom colors or advanced styling.



Examples

Basic Usage

You can use the Button component like this:


Disabled & Loading

When disabled or loading is set, the button cannot be clicked, loading also shows a Loader.


Icons

Pass a React icon component (icon) or an external image (iconSrc).


As a Link

If you pass an href prop, the button renders as a Next.js Link.

Combine href with a target="_blank" for external links if desired.

Avoid using href and onClick together if they lead to conflicting actions. href takes precedence.


Custom Style

Using Tailwind utility classes, you can create a custom button.