--- title: CloseButton description: "`CloseButton` is a component used primarily to trigger the close functionality of a component." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/close-button/close-button.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/close-button - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-closebutton--basic --- # CloseButton `CloseButton` is a component used primarily to trigger the close functionality of a component. ```tsx ``` ## Usage ```tsx import { CloseButton } from "@yamada-ui/react" ``` ```tsx import { CloseButton } from "@/components/ui" ``` ```tsx import { CloseButton } from "@workspaces/ui" ``` ```tsx ``` ### Change Variant ```tsx {(variant, index) => } ``` ### 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) => } ``` ## Props | 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` | - | `"2xl" \| "2xs" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | - | `"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. | | `icon` | - | `string \| number \| bigint \| boolean \| ReactElement> \| Iterable \| ReactPortal \| Promise<...>` | The icon to be used in the button. | | `loading` | `false` | `boolean` | If `true`, the loading state of the button is represented. | | `type` | `"button"` | `"button" \| "reset" \| "submit"` | The type of button. Accepts `button`, `reset`, or `submit`. | ## Accessibility `CloseButton` follows the [WAI-ARIA - Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) for accessibility. ### Keyboard Navigation | Key | Description | State | | ---------------- | ------------------------------------- | ----- | | `Enter`, `Space` | When element has focus, activates it. | - | ### ARIA Roles and Attributes | Element | Roles and Attributes | Usage | | ------------------------ | -------------------- | ------------------ | | `button.ui-close-button` | `aria-label` | Sets to `"Close"`. | ## Similar Components - [Button](https://yamada-ui.com/docs/components/button.md): `Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals. - [IconButton](https://yamada-ui.com/docs/components/icon-button.md): `IconButton` is a component that displays an icon within a button. - [FileButton](https://yamada-ui.com/docs/components/file-button.md): `FileButton` is a button component used for users to select files. - [Toggle](https://yamada-ui.com/docs/components/toggle.md): `Toggle` is a component that has two states: on or off. ## Uses Components & Hooks - [Button](https://yamada-ui.com/docs/components/button.md): `Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals. - [Icon](https://yamada-ui.com/docs/components/icon.md): `Icon` is a general icon component that can be used in your projects. ## Used By Components & Hooks - [ActionBar](https://yamada-ui.com/docs/components/action-bar.md): `ActionBar` is a component that is used to display a bottom action bar with a set of actions. - [Drawer](https://yamada-ui.com/docs/components/drawer.md): `Drawer` is a component for a panel that appears from the edge of the screen. - [Modal](https://yamada-ui.com/docs/components/modal.md): `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information. - [Snacks](https://yamada-ui.com/docs/components/snacks.md): `Snacks` is a component for controlling notifications used in forms and other similar situations.