# Button

A native button with Zenos variants, sizing, icons, and loading feedback.

A native button with Zenos variants, sizing, icons, and loading feedback.

```tsx
import { Button, Stack } from "@zentara-co/zenos-ui";

function ButtonPreviewExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap" className="justify-center">
      <Button variant="primary">Primary</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
    </Stack>
  );
}
```

```tsx
import { Button } from "@zentara-co/zenos-ui";
```

## With icons

Use `startIcon` and `endIcon` to place a decorative icon on either side of the label.

```tsx
import { ArrowRightIcon, PlusIcon } from "@phosphor-icons/react";
import { Button, Stack } from "@zentara-co/zenos-ui";

function ButtonIconsExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <Button variant="primary" startIcon={<PlusIcon />}>
        Create project
      </Button>
      <Button variant="outline" endIcon={<ArrowRightIcon className="rtl:rotate-180" />}>
        Continue
      </Button>
    </Stack>
  );
}
```

### Left or right: a UX rule

Placement is not decorative. In a left-to-right interface, the eye enters at the start of the button and exits at the end. A leading icon identifies the action; a trailing icon signals direction, disclosure, or what comes next.

Directional meaning overrides the default. A back arrow belongs at the inline start because it points where the action travels. In right-to-left interfaces, think in **start** and **end** rather than fixed left and right positions; Zenos handles the visual order through `startIcon` and `endIcon`.

## Sizes

Buttons use the shared Zenos `sm`, `md`, and `lg` control scale.

```tsx
import { Button, Stack } from "@zentara-co/zenos-ui";

function ButtonSizesExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <Button size="sm">Small</Button>
      <Button size="md">Medium</Button>
      <Button size="lg">Large</Button>
    </Stack>
  );
}
```

## Variants

Choose a variant that reflects the action's visual priority and meaning. Neutral, semantic, and accent variants use deeper surfaces in dark mode instead of inheriting the palette's pastel emphasis colors.

```tsx
import { Button, Stack } from "@zentara-co/zenos-ui";

const buttonVariants = [
  "default",
  "primary",
  "ghost",
  "outline",
  "warning",
  "destructive",
  "link",
  "secondary",
  "grey",
  "green",
  "blue",
  "purple",
  "orange",
  "teal",
  "pink",
] as const;

type CatalogVariantProps = { limit?: number };

const limited = <T,>(items: readonly T[], limit?: number) =>
  limit === undefined ? items : items.slice(0, limit);

function ButtonVariantsExample({ limit }: CatalogVariantProps = {}) {
  if (limit !== undefined) {
    return (
      <Stack direction="row" gap="3" align="center" wrap="wrap" className="justify-center">
        {limited(buttonVariants, limit).map((variant) => (
          <Button key={variant} variant={variant}>
            {variant}
          </Button>
        ))}
      </Stack>
    );
  }

  return (
    <Stack direction="row" gap="3" wrap="wrap" className="w-full">
      {buttonVariants.map((variant) => (
        <Button key={variant} variant={variant}>
          {variant}
        </Button>
      ))}
    </Stack>
  );
}
```

## Custom styling

Use the usual `className` prop for your own appearance. You do not need to supply `variant` or `variantClassName`. Your classes apply last and override conflicting built-in styles while preserving sizing, focus, disabled, loading, icon, and native button behavior.

Define the surface, border, foreground, and any hover or active treatments you want to replace. Prefer semantic tokens for theme-aware colors. A layout-only class such as `w-full` keeps the default appearance; `className` does not implicitly remove styles you have not overridden.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { Button, IconButton, Stack } from "@zentara-co/zenos-ui";

function CustomButtonVariantExample() {
  const campaignButtonClassName =
    "rounded-full border border-transparent bg-background-accent-purple-bolder-hover text-text-contrary hover:bg-background-accent-purple-bolder-pressed active:bg-background-accent-purple-bolder-pressed";

  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <Button className={campaignButtonClassName}>Launch campaign</Button>
      <IconButton aria-label="Campaign options" className={campaignButtonClassName}>
        <PlusIcon />
      </IconButton>
    </Stack>
  );
}
```

## States

Disabled and loading buttons cannot be activated. Loading buttons expose `aria-busy` to assistive technology.

```tsx
import { Button, Stack } from "@zentara-co/zenos-ui";

function ButtonStatesExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <Button variant="primary">Default</Button>
      <Button variant="primary" disabled>
        Disabled
      </Button>
      <Button variant="primary" isLoading>
        Loading
      </Button>
    </Stack>
  );
}
```

## Motion

Buttons use a short scale transition while pressed to reinforce activation. The transition is removed automatically when the user prefers reduced motion.

Set `disableMotion` when a button sits inside another animated control, when a surrounding interaction already supplies feedback, or when the button must respond without movement. Hover, pressed colors, focus visibility, and activation behavior remain unchanged.

```tsx
import { Button, Stack, Text } from "@zentara-co/zenos-ui";

function ButtonMotionExample() {
  return (
    <Stack direction="row" gap="6" align="center" wrap="wrap" className="justify-center">
      <Stack gap="2" align="center">
        <Button variant="primary">Default motion</Button>
        <Text size="s" color="subtle">
          Press and hold
        </Text>
      </Stack>
      <Stack gap="2" align="center">
        <Button variant="primary" disableMotion>
          Motion disabled
        </Button>
        <Text size="s" color="subtle">
          Color feedback only
        </Text>
      </Stack>
    </Stack>
  );
}
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| variant | ButtonVariant \| custom string | default | Visual intent. |
| className | string | — | Custom styling and instance overrides. No variant prop is required. |
| variantClassName | string | — | Optional classes for existing named-variant integrations. Use className for custom styling. |
| size | 'sm' \| 'md' \| 'lg' | md | Control height and padding. |
| isLoading | boolean | false | Shows progress and disables activation. |
| disableMotion | boolean | false | Disables the pressed-state scale and transition for this button. |
| startIcon / endIcon | ReactNode | — | Icons around the label. |
| type | ButtonHTMLAttributes.type | button | Native button type. |

Button forwards native button props and its ref. Loading state sets `aria-busy`; supply a clear `loadingLabel` when there is no visible label.

Source: https://zenos-ui.pages.dev/components/button/