Button

A control for a single action. Six variants across eight colour sets, ten sizes, and `asChild` to render as any element. Destructive is a colour, not a variant.

src/components/ui/button.tsx

About

From the component's own source, where it was written.

Every variant reads the --ui-* set, so color restyles all of them at once.

Press lands instantly: active:duration-0 skips the transition on the way down so the button answers the click, while the release eases back. Colour carries most of it; pressable adds 3% of scale, which is a transform and so costs no layout and cannot reflow the row it sits in.

Install

npx astralyx-ui add button

Usage

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

<Button variant="outline" color="blue" size="lg">
  Click me
</Button>

Composer

Change the props and the source below follows.

Props
tsx
<Button>
  Button
</Button>

Examples

Variants

Colored — solid

Colored — secondary

Colored — outline and ghost

Custom colour via tint

Sizes

Icon sizes

States

With icon

asChild — render as a link

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

Button

Every variant reads the --ui-* set, so color restyles all of them at once.

Extends Omit<ComponentProps<'button'>, 'color'>.

PropTypeDefaultDescription
color'neutral' | 'blue' | 'violet' | 'cyan' | 'green' | 'amber' | 'rose' | 'destructive''neutral'Named colour set. Drives fill, text, tint and border together. Ignored when tint is set.
variant'link' | 'default' | 'colored' | 'secondary' | 'outline' | 'ghost''default'Which treatment to use. All of them read the active colour set.
size'sm' | 'default' | 'xs' | 'lg' | 'xl' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg' | 'icon-xl''default'Height, padding, icon size and corner radius as one step. icon-* sizes are square.
asChildbooleanfalseRender the single child element instead of a <button>, keeping every style. Useful for links.
tintstring—Any CSS colour, used instead of a named set. Fill, text, hover and border are all derived from it.
disabledbooleanfalseNative disabled state; drops opacity and blocks pointer events.

Functions

FunctionSignatureDescription
buttonVariants(props?: { variant?: 'link' | 'default' | 'colored' | 'secondary' | 'outline' | 'ghost'; color?: 'neutral' | 'blue' | 'violet' | 'cyan' | 'green' | 'amber' | 'rose' | 'destructive'; size?: 'sm' | 'default' | 'xs' | 'lg' | 'xl' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg' | 'icon-xl' }) => string—

Types

TypeDefinitionDescription
ColorSet
keyof typeof colorSet
—