# Button · JGuang UI

> Displays a button or a component that looks like a button.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/base/button
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `button-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install @base-ui/react
```


### Copy and paste the following code into your project.


[View complete source: components/ui/button.tsx](/r/jguang-ui/base/button.json)


### Update the import paths to match your project setup.


## Usage

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

```tsx
<Button variant="outline">Button</Button>
```

## Cursor

Tailwind v4 [switched](https://tailwindcss.com/docs/upgrade-guide#buttons-use-the-default-cursor) from `cursor: pointer` to `cursor: default` for the button component.

If you want to keep the `cursor: pointer` behavior, add the following code to your CSS file:

You can also enable this during project setup with `JGuang UI Registry`.

```css showLineNumbers title="globals.css"
@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}
```

## Size

Use the `size` prop to change the size of the button.


> Example `button-size`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Default


> Example `button-default`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Outline


> Example `button-outline`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Secondary


> Example `button-secondary`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Ghost


> Example `button-ghost`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Destructive


> Example `button-destructive`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Link


> Example `button-link`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Icon


> Example `button-icon`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## With Icon

Remember to add the `data-icon="inline-start"` or `data-icon="inline-end"` attribute to the icon for the correct spacing.


> Example `button-with-icon`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Rounded

Use the `rounded-full` class to make the button rounded.


> Example `button-rounded`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Spinner

Render a `` component inside the button to show a loading state. Remember to add the `data-icon="inline-start"` or `data-icon="inline-end"` attribute to the spinner for the correct spacing.


> Example `button-spinner`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## Button Group

To create a button group, use the `ButtonGroup` component. See the [Button Group](/systems/jguang-ui/docs/components/base/button-group) documentation for more details.


> Example `button-group-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## As Link

You can use the `buttonVariants` helper to make a link look like a button.

**Do not use `} nativeButton={false} />` for links.** The Base UI `Button` component always applies `role="button"`, which overrides the semantic link role on `<a>` elements. Use `buttonVariants` with a plain `<a>` tag instead.


> Example `button-render`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `button-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/button


## API Reference

### Button

The `Button` component is a wrapper around the `button` element that adds a variety of styles and functionality.

| Prop      | Type                                                                                 | Default     |
| --------- | ------------------------------------------------------------------------------------ | ----------- |
| `variant` | `"default" \| "outline" \| "ghost" \| "destructive" \| "secondary" \| "link"`        | `"default"` |
| `size`    | `"default" \| "xs" \| "sm" \| "lg" \| "icon" \| "icon-xs" \| "icon-sm" \| "icon-lg"` | `"default"` |

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
