--- title: Button description: "`Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/button/button.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/button - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-button--basic --- ```tsx ``` ## Usage ```tsx import { Button, ButtonGroup } from "@yamada-ui/react" ``` ```tsx import { Button, ButtonGroup } from "@/components/ui" ``` ```tsx import { Button, ButtonGroup } from "@workspaces/ui" ``` ```tsx )} ``` ### Change Size ```tsx {(size, index) => ( )} ``` ### Change Color Scheme ```tsx {(colorScheme, index) => ( )} ``` ### Change Shape To rounded corners, set `fullRounded` to `true`. ```tsx {(variant, index) => ( )} ``` ### Disable To disable, set `disabled` to `true`. ```tsx {(variant, index) => ( )} ``` ### Add Icon To add an icon, set a `ReactNode` to `startIcon` or `endIcon`. ```tsx ``` ### Use Loading Animation To use a loading animation, set `loading` to `true`. If you want to change the text during loading, use `loadingMessage`. ```tsx ``` :::note The loading for `Button` internally uses [Loading](https://yamada-ui.com/docs/components/loading.md). ::: ### Grouping ```tsx Button } /> Button Button Button Button Button Button Button Button Button Button Button Button ``` ## Props ### Button | Prop | Default | Type | Description | | ------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"md"` | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | `"solid"` | `"ghost" \| "outline" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `active` | `false` | `boolean` | If `true`, the button is represented as active. | | `disabled` | `false` | `boolean` | If `true`, the button is disabled. | | `disableRipple` | `false` | `boolean` | If `true`, disable ripple effects when pressing a element. | | `endIcon` | - | `ReactNode` | The icon to display at the end side of the button. | | `fullRounded` | `false` | `boolean` | If `true`, the button is full rounded. Else, it'll be slightly round. | | `iconProps` | - | `ButtonIconProps` | The props of the icon element. | | `loading` | `false` | `boolean` | If `true`, the loading state of the button is represented. | | `loadingIcon` | `"oval"` | `Loading.Scheme \| ReactNode` | The icon to display when the button is loading. | | `loadingMessage` | - | `ReactNode` | The message to display when the button is loading. | | `loadingPlacement` | `"start"` | `"end" \| "start"` | The placement of the loading indicator. Accepts `start` or `end`. | | `loadingProps` | - | `ButtonLoadingProps` | The props of the loading icon element. | | `startIcon` | - | `ReactNode` | The icon to display at the start side of the button. | | `type` | `"button"` | `HTMLProps<"button">["type"]` | The type of button. Accepts `button`, `reset`, or `submit`. | ### ButtonGroup.Root | Prop | Default | Type | Description | | ------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"md"` | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | `"solid"` | `"ghost" \| "outline" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `align` | - | `"-moz-initial" \| "baseline" \| "center" \| "end" \| "flex-end" \| "flex-start" \| "inherit" \| "initial" \| "normal" \| "revert-layer" ...` | The CSS `align-items` property. | | `attached` | `false` | `boolean` | If `true`, the borderRadius of button that are direct children will be altered to look flushed together. | | `basis` | - | `"-moz-fit-content" \| "-moz-initial" \| "-moz-max-content" \| "-moz-min-content" \| "-webkit-auto" \| "0.5" \| "1.5" \| "1" \| "1/12" \| "1/2" ...` | The CSS `flex-basis` property. | | `direction` | - | `"-moz-initial" \| "column-reverse" \| "column" \| "inherit" \| "initial" \| "revert-layer" \| "revert" \| "row-reverse" \| "row" \| "unset" ...` | The CSS `flex-direction` property. | | `disabled` | `false` | `boolean` | If `true`, all wrapped button will be disabled. | | `fullRounded` | `false` | `boolean` | If `true`, the button is full rounded. Else, it'll be slightly round. | | `grow` | `false` | `boolean` | If `true`, the children will grow to fill the available space. | | `justify` | - | `"-moz-initial" \| "center" \| "end" \| "flex-end" \| "flex-start" \| "inherit" \| "initial" \| "left" \| "normal" \| "revert-layer" ...` | The CSS `justify-content` property. | | `orientation` | `"horizontal"` | `"horizontal" \| "vertical"` | The orientation of the group. | | `shrink` | - | `"-moz-initial" \| "inherit" \| "initial" \| "revert-layer" \| "revert" \| "unset" \| number & {} ...` | The CSS `flex-shrink` property. | | `stacking` | - | `"first-on-top" \| "last-on-top"` | The stacking order of the group. | | `wrap` | - | `"-moz-initial" \| "inherit" \| "initial" \| "nowrap" \| "revert-layer" \| "revert" \| "unset" \| "wrap-reverse" \| "wrap" ...` | The CSS `flex-wrap` property. | ### ButtonGroup.Item | Prop | Default | Type | Description | | ------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"md"` | `"2xl" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | `"solid"` | `"ghost" \| "outline" \| "solid" \| "subtle" \| "surface" ...` | The variant of the component. | | `active` | `false` | `boolean` | If `true`, the button is represented as active. | | `disabled` | `false` | `boolean` | If `true`, the button is disabled. | | `disableRipple` | `false` | `boolean` | If `true`, disable ripple effects when pressing a element. | | `endIcon` | - | `ReactNode` | The icon to display at the end side of the button. | | `fullRounded` | `false` | `boolean` | If `true`, the button is full rounded. Else, it'll be slightly round. | | `iconProps` | - | `ButtonIconProps` | The props of the icon element. | | `loading` | `false` | `boolean` | If `true`, the loading state of the button is represented. | | `loadingIcon` | `"oval"` | `Loading.Scheme \| ReactNode` | The icon to display when the button is loading. | | `loadingMessage` | - | `ReactNode` | The message to display when the button is loading. | | `loadingPlacement` | `"start"` | `"end" \| "start"` | The placement of the loading indicator. Accepts `start` or `end`. | | `loadingProps` | - | `ButtonLoadingProps` | The props of the loading icon element. | | `startIcon` | - | `ReactNode` | The icon to display at the start side of the button. | | `type` | `"button"` | `HTMLProps<"button">["type"]` | The type of button. Accepts `button`, `reset`, or `submit`. | ## Accessibility The `Button` follows the [WAI-ARIA - Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) for accessibility. ### Keyboard Navigation | Key | Description | State | | ---------------- | ------------------------------------- | ----- | | `Space`, `Enter` | When element has focus, activates it. | - | ### ARIA Roles and Attributes | Component | Role and Attribute | Usage | | --------- | ------------------ | ------------------------------ | | `Button` | `role="button"` | Indicates that it is a button. |