Components

CloseButton

An accessible dismiss control with a generous touch target.

Preview

Usage

import { CloseButton } from "@fwenthehunter/friendly-ui";

<CloseButton label="Close settings" />

A server-compatible Button with a themed cross icon and a 44px default touch target. Set label for its accessible name. Define onClick in a client wrapper when adding dismissal behavior. Modal, Toast, and Drawer use this control internally.

Customize this component

  1. Choose a name.
  2. Add its CSS to your app’s theme.css, imported after the package styles.
  3. Pass the same name to the prop. No registration, provider, or package edits are needed. Built-in TypeScript suggestions remain available.

A custom name alone does not create styles: until its CSS is loaded, it inherits the component’s base appearance. The examples below are application styles, not additional package defaults.

Add a variant

The same variant mechanism as Button. Give every icon-only close control an accessible label.

/* app/theme.css — import after @fwenthehunter/friendly-ui/styles.css */
@layer components {
  .fui-close-button[data-variant="soft"] {
    background: var(--fui-subtle);
    color: var(--fui-foreground);
  }
}
import { CloseButton } from "@fwenthehunter/friendly-ui";

<CloseButton variant="soft" label="Close settings" />

Add a size

CloseButton keeps a 44px target for its normal sizes. Custom sizes should keep at least that touch target. Its icon is sized separately from the button.

/* app/theme.css — import after @fwenthehunter/friendly-ui/styles.css */
@layer components {
  .fui-close-button[data-size="xl"] {
    width: 3.5rem; min-width: 3.5rem;
    height: 3.5rem; min-height: 3.5rem;
  }
  .fui-close-button[data-size="xl"] svg {
    width: 2rem; height: 2rem;
  }
}
import { CloseButton } from "@fwenthehunter/friendly-ui";

<CloseButton size="xl" variant="soft" label="Close settings" />

Props

Components accept native HTML props, className, and style. Server-compatible primitives also forward React 19 refs; Modal manages its own dialog ref.

PropTypeDefault
labelstringClose
variantprimary | secondary | ghost | custom stringghost
sizesm | md | lg | custom stringmd