PeakUI

CloseButton

An icon-only dismiss control with a built-in glyph and label

Usage

Renders an icon-only dismiss button: the X glyph and the accessible name Close are built in.

import {CloseButton} from "@peakui/react";

Examples

With a Custom Icon

Children replace the default glyph; the name still comes from aria-label.

Interactive

onPress fires on click and on Enter and Space alike.

Disabled State

Customization

Tailwind CSS

Pass utilities through className. They are merged with the button's own classes.

<CloseButton className="rounded-full" />

Global CSS

Override the button's classes in the components layer.

@layer components {
  .close-button--default {
    @apply bg-danger-soft text-danger-soft-foreground;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The CloseButton component uses these CSS classes (view source styles):

Base Classes

  • .close-button - Base styles: a 24px square icon-only button

Variant Classes

  • .close-button--default - Default fill: bg-default background with a muted glyph

Slots

  • [data-slot="close-button"] - The button element
  • [data-slot="close-button-icon"] - The default X glyph, an svg

Interactive States

The button supports both CSS pseudo-classes and data attributes:

  • Hover: :hover or [data-hovered]
  • Pressed: :active or [data-pressed]
  • Focus: :focus-visible or [data-focus-visible] (shows the focus ring)
  • Disabled: :disabled, [data-disabled] or [aria-disabled="true"]
  • Pending: [data-pending="true"]

API Reference

CloseButton

PropTypeDefaultDescription
variant'default''default'Visual variant
childrenReactNode | (values: ButtonRenderProps) => ReactNodebuilt-in X glyphButton content, or a function of the button's state
classNamestring | (values: ButtonRenderProps) => string-Additional classes, or a function of the button's state

aria-label defaults to Close and a consumer value overrides it. type defaults to button. Every other React Aria Button prop is accepted.

Render Props

When children or className is a function, it receives:

PropTypeDescription
isPendingbooleanWhether the button is waiting on an action
isPressedbooleanWhether the button is currently pressed
isHoveredbooleanWhether the button is hovered
isFocusedbooleanWhether the button is focused
isFocusVisiblebooleanWhether the button is focused by keyboard
isDisabledbooleanWhether the button is disabled

On this page