Skip to content

Button

The Button component allows users to trigger actions or events. They are essential interactive elements in any user interface.

Add the Button component to your project using the OrbitUI CLI:

Terminal window
npx orbitkit@latest add button

Import the Button component and use it in your Astro components or pages. Place the content you want inside the button as children of the <Button> tag. This can be text, icons (like SVGs), or a combination.

If you provide an href prop to the Button component, it will automatically render as an <a> element, making it a link. This is useful for navigation links that should have the appearance of a button.

index.astro
---
import { Button } from "@/components/ui/button";
---
<Button href="/about">Learn More</Button>

Alternatively, You can use the buttonVariants helper to create a link that looks like a button.

index.astro
---
import { buttonVariants } from "@/components/ui/button";
---
<a href="/some-page" class={buttonVariants({ variant: "outline", size: "lg" })}>
Link with Button Outline Styles
</a>

The Button component accepts the following props, which are based on the buttonVariants defined using class-variance-authority, plus standard button attributes:

PropTypeDefault
variantdefault, outline, ghostdefault
roundednone, xs, sm, md, lg, xl, fullsm
sizexs, sm, md, lg, xlxs
disabledbooleanfalse

Accepts all standard HTML attributes for a <button> element (if href is not provided) or an <a> element (if href is provided).