Skip to content

Alert (React Native) ​

Static status messages for important information, success confirmations, warnings, and errors. Theme-driven styling via useGrundtoneTheme().


Installation ​

tsx
import { GTAlert } from '@grundtone/react-native';

Usage ​

Basic ​

tsx
<GTAlert variant="info">
  <Text>This is an informational message.</Text>
</GTAlert>

With icon ​

tsx
<GTAlert variant="success" icon="check-circle">
  <Text>Your changes have been saved.</Text>
</GTAlert>

With heading ​

tsx
<GTAlert variant="error" icon="alert-circle" heading="Form errors">
  <Text>Please fix the following errors before submitting.</Text>
</GTAlert>

Dismissible ​

tsx
const [show, setShow] = useState(true);

{show ? (
  <GTAlert
    variant="info"
    icon="info-circle"
    dismissible
    onDismiss={() => setShow(false)}
  >
    <Text>This alert can be dismissed.</Text>
  </GTAlert>
) : null}
tsx
<GTAlert variant="error" icon="alert-circle" heading="2 errors" footer={
  <Text>Fix the errors and try again.</Text>
}>
  <Text>Name is required. Email is not valid.</Text>
</GTAlert>

Props ​

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'error'requiredVisual and semantic variant
headingstring—Optional heading above the body
iconstring—Icon name from the registry (renders GTIcon)
dismissiblebooleanfalseShow close/dismiss button
onDismiss() => void—Called when close button is pressed
accessibilityLabelstring—Accessible label for the alert
childrenReactNoderequiredAlert body content
footerReactNode—Footer content, separated by a line

Accessibility ​

  • accessibilityRole="alert" for screen reader announcements
  • Close button has accessibilityLabel="Close" and accessibilityRole="button"
  • Icons are decorative (no accessibility label)

Theming ​

All colors, spacing, typography, and radii come from useGrundtoneTheme(). The component responds to light/dark mode automatically.

Backgrounds use 12% opacity of the variant color for a transparent effect in both light and dark mode.

VariantBorderBackground
infotheme.colors.infoinfo at 12% opacity
successtheme.colors.successsuccess at 12% opacity
warningtheme.colors.warningwarning at 12% opacity
errortheme.colors.errorerror at 12% opacity