# Button

A clear action at the right moment.

## How to use it

Use Button for actions and asChild with a link for navigation. In forms, set type="button" when the action should not submit data.



## Import


```tsx
import { Button } from "@kivora/nextjs";
```


Examples run in a Client Component. Also import the hooks, icons and dependencies used. This is the web API; consult the native guide for React Native.

## Example


```tsx
<Button variant="default" size="default">Create project</Button>
```


## Variants

```tsx
<div style={{ display: "flex", alignItems: "center", gap: 12, flexWrap: "wrap" }}>
  {(["default", "secondary", "outline", "ghost", "destructive", "link"] as const).map(variant => <Button key={variant} variant={variant}>{variant}</Button>)}
</div>
```


## With state

```tsx
function Example() {
  const [saved, setSaved] = useState(false);
  return <Button onClick={() => setSaved(!saved)}>{saved ? "Saved ✓" : "Save changes"}</Button>;
}
```


## API: Button


```typescript
Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>
```


| Property | Type | Required | Description |
| --- | --- | --- | --- |
| aria-label | string | No | Accessible name of the control. |
| asChild | boolean | No | Apply props and behavior to a single compatible child element. |
| children | ReactNode | No | Content or child elements of the component. |
| className | string | No | Additional CSS classes to customize the element. |
| defaultChecked | boolean | No | Initial selection of the control. |
| defaultValue | string \| number \| readonly string[] | No | Initial value when the component manages its own state. |
| disabled | boolean | No | Disable interaction with the control. |
| id | string | No | Element identifier; associates labels and descriptions. |
| name | string | No | Name used to identify the control in forms. |
| onChange | ChangeEventHandler<HTMLButtonElement, Element> | No | Change event. Check the type: some controls return an object, others a DOM event. |
| onClick | MouseEventHandler<HTMLButtonElement> | No | Action performed when the element is activated. |
| onSubmit | SubmitEventHandler<HTMLButtonElement> | No | Form submission event. |
| role | AriaRole | No | Semantic role of the element. Keep the default role unless a change is justified. |
| size | "default" \| "sm" \| "lg" \| "icon" \| null | No | Visual size of the component. |
| style | CSSProperties | No | React inline styles. |
| tabIndex | number | No | Keyboard focus order and availability. |
| title | string | No | Title or supplementary information. |
| type | "button" \| "submit" \| "reset" | No | Operation type or mode; values depend on the component. |
| value | string \| number \| readonly string[] | No | Controlled value. Update it from the change callback. |
| variant | "default" \| "link" \| "destructive" \| "secondary" \| "outline" \| "ghost" \| null | No | Visual variant. Use a value supported by this component. |

Source: https://kivora.pro/docs/componentes/button
