CloseButton

The standard dismiss control for sheets, dialogs and banners.

  • Composed
  • Liquid Glass on iOS 26
  • New in 0.1
import { CloseButton, closeButtonPrimitive } from "nitro-ui-sdk/close-button";
HeroUI Native
CloseButton
Expo UI
No counterpart
  • CloseButton example screen, light appearance
    Light
  • CloseButton example screen, dark appearance
    Dark
  • CloseButton example screen, liquid glass appearance
    Liquid Glass
On this page

The standard dismiss control for sheets, popovers, banners and media viewers: an IconButton preset with the xmark glyph. It draws iOS 26 glass by default and needs a localized label (“Close”, “Fermer”), which is its only name. Use Button with a word (“Cancel”, “Done”) when the dismiss also decides something.

Anatomy

import { CloseButton } from "nitro-ui-sdk/close-button";

export function Anatomy() {
  return (
    <CloseButton.Root label="Close" onPress={() => {}}>
      <CloseButton.Icon />
      <CloseButton.BusyIndicator />
    </CloseButton.Root>
  );
}
Part Description
CloseButton.Root The native pressable host with the xmark glyph.
CloseButton.Icon The decorative xmark.
CloseButton.BusyIndicator The spinner over the glyph while busy.

Usage

import { CloseButton } from "nitro-ui-sdk/close-button";

export function SheetHeader({ dismiss }: { dismiss: () => void }) {
  return <CloseButton.Root label="Close" onPress={dismiss} />;
}

Variants and sizes

Variant Look
glass (default) Liquid Glass with a foreground glyph; falls back to the neutral default fill.
plain Neutral default fill with a muted glyph, for opaque headers and cards.
Size Side Glyph
sm 36 12
md (default) 44 15
lg 52 18

The glyph is smaller than other icon buttons, as in iOS. Every size keeps a 44 × 44 pt touch area.

States

  • Disabled: dims and refuses every press.
  • Busy: an async onPress (for example saving a draft before closing) shows the spinner over the glyph; busyLabel is spoken.
  • Pressed: plain scales; live glass reacts by itself; Reduce Motion dims instantly.

Liquid Glass

glass draws an interactive MaterialView when the theme has glass on, the OS supports Liquid Glass (iOS 26) and Reduce Transparency is off. Otherwise it draws the default fill and scales on press.

import { View } from "nitro-ui-renderer";
import { CloseButton } from "nitro-ui-sdk/close-button";

export function ViewerChrome({ dismiss }: { dismiss: () => void }) {
  return (
    <View layout={{ position: "absolute", top: 16, right: 16 }}>
      <CloseButton.Root label="Close" size="lg" onPress={dismiss} />
    </View>
  );
}

Props

CloseButton.Root

Prop Type Default Description
label string required Localized name, e.g. “Close”.
onPress (details) => void | PromiseLike<unknown> required Dismisses. A returned promise shows the busy state.
variant "glass" | "plain" "glass" See Variants.
size "sm" | "md" | "lg" "md" See Sizes.
iconFallback ImageLoader — Image for Android.
disabled boolean false Refuses every press.
busy boolean false Shows the pending state.
busyLabel string — Spoken while busy.
hint string — Accessibility hint.
haptic "light" | "medium" | "heavy" | "none" "light" Impact on a touch press.
api Controller<CloseButtonActions> — From closeButtonPrimitive.createApi().
agentId string — Stable agent identity.
confirm { message, approveLabel, cancelLabel } — Asks before an agent closes, e.g. when unsaved work would be lost.
styles CloseButtonStyles — Per-part style resolvers.
layout LayoutProps — Layout of the host.
children ReactNode — Custom anatomy.

CloseButton.Icon

Prop Type Default Description
children IconButtonGlyph "xmark" Decorative dismiss glyph.
part CloseButtonPart "icon" Selects the style resolver.

CloseButton.BusyIndicator

Prop Type Default Description
children ReactNode platform spinner Content to show while busy.
part CloseButtonPart "busyIndicator" Selects the style resolver.

Controller API

import { useState } from "react";
import { CloseButton, closeButtonPrimitive } from "nitro-ui-sdk/close-button";

export function Banner({ dismiss }: { dismiss: () => void }) {
  const [api] = useState(closeButtonPrimitive.createApi);
  return <CloseButton.Root label="Dismiss" variant="plain" size="sm" api={api} onPress={dismiss} />;
}
Action Signature Result
press (source?: ActionSource) => ActionStatus accepted, disabled or refused.

Styles

import { CloseButton, type CloseButtonStyles } from "nitro-ui-sdk/close-button";

const styles: CloseButtonStyles = {
  icon: ({ tokens }) => ({ text: { color: tokens.colors.danger } }),
};

export function Danger() {
  return <CloseButton.Root label="Close" variant="plain" styles={styles} onPress={() => {}} />;
}

Parts: root, icon, busyIndicator. The resolver receives { tokens, variant, size, state } with variant: "glass" | "plain" and state: { disabled, busy, shape }.

Accessibility

  • One button element named by label; VoiceOver reads “Close, button”. The xmark is never spoken.
  • Disabled and busy add notEnabled.
  • A 44 × 44 pt touch area at every size.

Agent API

Action Arguments Notes
press none Same controller as touch. Use confirm when closing discards work.

The entry has component: "CloseButton" and role: "button".

Platform notes

iOS Android
Host KitPressable, shared with IconButton. PressableGroup.
Glyph SF Symbol xmark. Pass iconFallback.
Glass Liquid Glass on iOS 26, opaque fallback otherwise. Opaque fallback.
Verification Unit, type and iOS harness tests. Kotlin implementation is unbuilt here (no Android NDK).