Button

A button or a component that looks like a button.

Loading...
Loading code...

Installation

pnpm dlx shadcn@latest add @uitopia/button

Usage

import { Button } from "@/components/ui/button"
<Button>Button</Button>

You can use the render prop to make another component look like a button. Here's an example of a link that looks like a button.

import Link from "next/link"

import { Button } from "@/components/ui/button"

export function LinkAsButton() {
  return <Button render={<Link href="/login" />}>Login</Button>
}

Examples

Default

Loading...
Loading code...

Outline

Loading...
Loading code...

Secondary

Loading...
Loading code...

Destructive

Loading...
Loading code...

Destructive Outline

Loading...
Loading code...

Ghost

Loading...
Loading code...
Loading...
Loading code...

Extra-small Size

Loading...
Loading code...

Small Size

Loading...
Loading code...

Large Size

Loading...
Loading code...

Extra-large Size

Loading...
Loading code...

Disabled

Loading...
Loading code...

Icon

Loading...
Loading code...

Icon Small Size

Loading...
Loading code...

Icon Large Size

Loading...
Loading code...

With Icon

Loading...
Loading code...
Loading...
Loading code...

Loading

Loading...
Loading code...

Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with ui/topia quickly.

Quick Checklist

  • Replace asChildrender on Button

Additional Notes

Size Comparison

ui/topia button sizes are more compact compared to shadcn/ui, making them better suited for dense applications. We also introduce new sizes (xs, xl, icon-sm, icon-lg) for more granular control:

SizeHeight (shadcn/ui)Height (ui/topia)
xs-24px
sm32px28px
default36px32px
lg40px36px
xl-40px
icon36px32px
icon-sm-28px
icon-lg-36px

So, for example, if you were using the default size in shadcn/ui and you want to preserve the original height, you should use the lg size in ui/topia.

New Variants

We've added a new destructive-outline variant for better UX patterns:

  • Primary actions: Use destructive (solid red) for the main destructive action
  • Secondary triggers: Use destructive-outline (outline red) to avoid alarming red buttons in the main interface

Comparison Example

shadcn/ui
<Button asChild>
  <Link href="/login">Login</Link>
</Button>
ui/topia
<Button render={<Link href="/login" />}>Login</Button>