Skip to Content
ARCUI

Modal

Controlled ARCUI bottom-sheet modal with Host rehosting, safe-area geometry, stacking, swipe dismissal, UI-thread motion, and accessibility isolation.

Modal is ARCUI's controlled general-purpose overlay surface. The declaration remains in normal React composition while its rendered content is rehosted into ARCUI's root overlay layer.

Usage

import { Button, Modal, Text } from "react-native-arc-ui";
import { useState } from "react";

export function Example() {
  const [visible, setVisible] = useState(false);

  return (
    <>
      <Button onPress={() => setVisible(true)}>Edit profile</Button>

      <Modal
        visible={visible}
        onClose={() => setVisible(false)}
        title="Edit profile"
      >
        <Text>Profile form content</Text>
      </Modal>
    </>
  );
}

visible is the source of truth. ARCUI animates and hosts the surface, but the consumer owns whether the Modal should remain semantically open.

Controlled lifecycle

onClose means the user requested dismissal.

ARCUI calls it for supported user dismissal paths:

  • backdrop press;
  • drag-handle swipe dismissal;
  • default close button;
  • Android hardware back;
  • accessibility escape.

The normal controlled pattern is:

<Modal
  visible={visible}
  onClose={() => setVisible(false)}
>
  {/* content */}
</Modal>

When the parent itself changes visible from true to false, ARCUI closes the mounted surface but does not call onClose again.

This prevents controlled state synchronization from becoming a callback loop.

Host rehosting

Modal content is declaratively rehosted into ARCUI's root Host layer.

That gives overlays correct stacking and root-level geometry, but it has one important composition rule:

React Context providers mounted below <ARCUI /> are not guaranteed to remain ancestors of rehosted Modal content.

If modal content depends on shared context, place that provider above ARCUI or pass the required data through normal application composition.

<SharedProvider>
  <ARCUI>
    <App />
  </ARCUI>
</SharedProvider>

See Safe area & overlays for the broader Host model.

A header is rendered when title, subtitle, or rightAction is provided.

<Modal
  visible={visible}
  onClose={close}
  title="Account"
  subtitle="Update your public profile"
>
  <AccountForm />
</Modal>

When a header exists and rightAction is omitted, ARCUI renders its built-in close action using the localizable Modal close accessibility label.

Custom right action

rightAction replaces the built-in close button.

<Modal
  visible={visible}
  onClose={close}
  title="Account"
  rightAction={
    <Button type="transparent" onPress={save}>
      Save
    </Button>
  }
>
  <AccountForm />
</Modal>

Custom right-action interaction and accessibility are consumer-owned. rightAction does not implicitly close the Modal.

Even when a custom right action is present, normal top-most backdrop, swipe, back, and accessibility dismissal routes still request onClose.

Height

Modal supports explicit pixel or percentage height.

<Modal visible={visible} onClose={close} height={420}>
  {/* content */}
</Modal>

<Modal visible={visible} onClose={close} height="70%">
  {/* content */}
</Modal>
  • number means logical pixels;
  • percentage strings are relative to the currently available safe sheet height;
  • omitting height uses content-driven sizing constrained by available safe height.

Percentage values must resolve between 0% and 100%. Invalid geometry inputs fail clearly rather than producing unstable overlay layout.

Safe area

ARCUI resolves Modal safe-area geometry through its system context and Modal safe-area tokens.

The backdrop covers the physical screen. The sheet itself uses:

  • top safe area to constrain maximum sheet height;
  • left/right safe area for horizontal padding;
  • bottom safe area as content padding.

Stack offset is included in the available-height calculation.

Scrolling

scrollable defaults to true.

<Modal visible={visible} onClose={close} scrollable>
  <LongForm />
</Modal>

ARCUI wraps content in its internal ScrollView with sensible overlay defaults.

Set scrollable={false} when the consumer owns scrolling or the modal content should remain a fixed non-scrolling surface.

<Modal visible={visible} onClose={close} scrollable={false}>
  <CustomVirtualizedContent />
</Modal>

Stacking

Multiple Modal declarations can be active at once. ARCUI maintains semantic stack order separately from rendered Host-node updates.

Only the top-most Modal accepts dismissal interaction and modal accessibility traversal.

stackOffset controls per-level top offset:

undefined -> tokens.sizings.modal.stackOffset
number    -> explicit per-level offset
false     -> no stack offset
<Modal
  visible={visible}
  onClose={close}
  stackOffset={10}
>
  {/* content */}
</Modal>

useModal

useModal() exposes only public semantic stack state:

import { useModal } from "react-native-arc-ui";

const { activeCount } = useModal();

Internal Host IDs and stack ownership remain implementation details.

Swipe dismissal

The Modal drag handle owns the pan gesture.

During a drag, sheet translation stays on the UI thread. On release ARCUI dismisses when either the configured distance threshold or velocity threshold is reached; otherwise the sheet springs back to its resting position.

Normal behavior comes from tokens.modalAnimations and measured sheet height.

Instance overrides

dismissDistance sets an explicit dismissal distance in pixels.

<Modal
  visible={visible}
  onClose={close}
  dismissDistance={140}
>
  {/* content */}
</Modal>

When omitted, distance resolves from:

rendered sheet height * tokens.modalAnimations.dismissThreshold

dismissVelocity overrides the tokenized velocity threshold for one Modal.

<Modal
  visible={visible}
  onClose={close}
  dismissVelocity={650}
>
  {/* content */}
</Modal>

Styling

style applies to the Modal sheet surface.

<Modal
  visible={visible}
  onClose={close}
  style={{ paddingTop: 8 }}
>
  {/* content */}
</Modal>

ARCUI intentionally keeps safety-critical sheet geometry and motion ownership internal. Consumer style remains an escape hatch for presentation without overriding the overlay invariants that keep the sheet within safe bounds.

Testing

Use testID on the public Modal root.

<Modal
  testID="profile-modal"
  visible={visible}
  onClose={close}
  title="Profile"
>
  <ProfileForm />
</Modal>

Stable descendants include:

profile-modal-backdrop
profile-modal-sheet
profile-modal-handle
profile-modal-header
profile-modal-title
profile-modal-subtitle
profile-modal-close
profile-modal-scroll
profile-modal-content

-scroll exists when scrollable is enabled; -content exists in the non-scrolling branch. Header descendants exist only when their corresponding header content is rendered.

For provider setup and the dedicated react-native-arc-ui/testing entrypoint, see Testing.

API Reference

PropTypeDefaultDescription
visiblebooleanrequiredControls modal visibility.
onClose() => voidrequiredCalled when the user requests dismissal through: - backdrop press - swipe gesture - default close button - Android hardware back - accessibility escape Parent-controlled visible=true -> false does not call onClose.
childrenReactNoderequiredModal content. Modal is declaratively rehosted into ARCUI's root Host layer. Local Context ancestry below <ARCUI /> is therefore not guaranteed to remain available inside rehosted content.
title?string——
subtitle?string——
rightAction?ReactNode—Replaces the default close action. Consumer owns interaction and accessibility behavior of the custom action.
height?TModalHeight—Total bottom-sheet height. number -> pixels percentage -> percentage of currently available safe sheet height
stackOffset?number | false—Per-stack-level top offset. undefined -> tokens.sizings.modal.stackOffset number -> explicit offset false -> no stack offset
scrollable?booleantrueWrap content in ARCUI's internal ScrollView.
dismissDistance?number—Explicit swipe dismissal distance in pixels. When omitted: renderedSheetHeight * tokens.modalAnimations.dismissThreshold
dismissVelocity?number—Explicit swipe dismissal velocity in px/s. Falls back to tokens.modalAnimations.dismissVelocity.
style?StyleProp<ViewStyle>——
testID?string——

Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.

useModal() additionally exposes { activeCount } as semantic overlay state.

Motion

Modal separates controlled visibility from frame-level overlay motion.

React/provider semantics own:

  • visible;
  • Host mount/unmount lifecycle;
  • semantic stack order;
  • which Modal is top-most;
  • the single JS-side close request boundary.

Reanimated/gesture worklets own:

  • backdrop opacity;
  • sheet translation;
  • swipe gesture movement;
  • dismissal threshold evaluation;
  • spring-back motion;
  • theme interpolation.

Active animations are cancelled before reversal/replacement so stale close completions cannot remove a reopened or newer lifecycle.

See Motion.

Performance

Frame-level drag and snap behavior remains on the UI thread. A successful swipe crosses to JS once to request the semantic close; regular movement does not drive React state per frame.

Modal stack semantics are kept separately from hosted node content so ordinary content updates do not create fake stack transitions or invalidate stack consumers.

See Performance.

Accessibility

ARCUI treats active modals as true overlay accessibility boundaries.

  • while any Modal is active, the underlying application layer is removed from VoiceOver/TalkBack traversal;
  • only the top-most Modal exposes modal accessibility semantics;
  • the built-in close action uses a localizable ARCUI-owned label;
  • accessibility escape requests dismissal through the same controlled onClose boundary;
  • when there is no visible built-in close button, the backdrop remains an accessible dismissal action;
  • when the built-in close button exists, the backdrop is removed as a duplicate screen-reader control while remaining touch-dismissable.

Consumer-owned rightAction content is responsible for its own accessible interaction semantics.

See Accessibility.

Theming

Relevant token areas include:

colors.light.modal
colors.dark.modal
border.modal
radius.modal
sizings.modal
typography.modal
safeArea.modal
modalAnimations
springConfig
zIndex.modal
spacing

modalAnimations controls timing/easing fallback, swipe dismissal thresholds, backdrop-tap movement tolerance, and gesture activation distance. Gesture snap-back uses ARCUI spring configuration.

Top-level token overrides are shallow. Compose changed namespaces from defaultTokens.

import { ARCUI, defaultTokens, type TTokensOverride } from "react-native-arc-ui";

const tokens = {
  radius: {
    ...defaultTokens.radius,
    modal: 20,
  },
  modalAnimations: {
    ...defaultTokens.modalAnimations,
    dismissThreshold: 0.25,
  },
} satisfies TTokensOverride;

export function App() {
  return <ARCUI tokens={tokens}>{/* application */}</ARCUI>;
}

See Tokens, Theming, and Safe area & overlays.

Try it live

Explore Modal interactively in Expo Snack.

Open Modal in Expo Snack ↗

On this page