GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — Alert | NativeBase | Universal Components for React and React Native

Alert | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
If you are starting a new project, please try gluestack-ui for better performance and new design.
Alert
Alerts convey a state that can influence a system, feature, or page.
Show Code
Playground
const Example = () => {
return <Alert shadow={2} maxW="400" w="100%" colorScheme="info">
<VStack space={1} flexShrink={1} w="100%">
<HStack flexShrink={1} space={2} alignItems="center" justifyContent="space-between">
<HStack space={2} flexShrink={1} alignItems="center">
<Alert.Icon />
<Heading fontSize="md" fontWeight="medium" color="coolGray.800">
We are going live in July!
</Heading>
</HStack>
<IconButton variant="unstyled" icon={<CloseIcon size="3" color="coolGray.600" />} />
</HStack>
<Box pl="6" _text={{
color: "coolGray.600"
}}>
We are happy to announce that we are going live on July 28th. Get
ready!
</Box>
</VStack>
</Alert>;
};
Import
NativeBase exports 2 Alert related components:
Alert: The wrapper for alert components.
Alert.Icon: The visual icon for the alert that changes based on the status prop.
Copy
import { Alert } from "native-base";
Examples
Basic
Playground
function Example() {
return <Center>
<Alert maxW="400" status="info" colorScheme="info">
<VStack space={2} flexShrink={1} w="100%">
<HStack flexShrink={1} space={2} alignItems="center" justifyContent="space-between">
<HStack flexShrink={1} space={2} alignItems="center">
<Alert.Icon />
<Text fontSize="md" fontWeight="medium" color="coolGray.800">
We are going live in July!
</Text>
</HStack>
<IconButton variant="unstyled" _focus={{
borderWidth: 0
}} icon={<CloseIcon size="3" />} _icon={{
color: "coolGray.600"
}} />
</HStack>
<Box pl="6" _text={{
color: "coolGray.600"
}}>
We are happy to announce that we are going live on July 28th. Get
ready!
</Box>
</VStack>
</Alert>
</Center>;
}
Status
Playground
function Example() {
const statusArray = [{
status: "success",
title: "Selection successfully moved!"
}, {
status: "error",
title: "Please try again later!"
}, {
status: "info",
title: "We are going live in July!"
}, {
status: "warning",
title: "Poor internet connection."
}];
return <Stack space={3} w="100%" maxW="400">
{statusArray.map(status => {
return <Alert w="100%" status={status.status}>
<VStack space={2} flexShrink={1} w="100%">
<HStack flexShrink={1} space={2} justifyContent="space-between">
<HStack space={2} flexShrink={1}>
<Alert.Icon mt="1" />
<Text fontSize="md" color="coolGray.800">
{status.title}
</Text>
</HStack>
<IconButton variant="unstyled" _focus={{
borderWidth: 0
}} icon={<CloseIcon size="3" />} _icon={{
color: "coolGray.600"
}} />
</HStack>
</VStack>
</Alert>;
})}
</Stack>;
}
Variant
Playground
function Example() {
const getTextColor = variant => {
switch (variant) {
case "left-accent":
case "top-accent":
case "subtle":
return "coolGray.800";
case "solid":
return "warmGray.50";
}
};
return <ScrollView mt={5}>
<Stack space={3} maxW="400" mr={5} flexDirection="column" justifyContent="center" alignItems="center">
{["solid", "left-accent", "top-accent", "outline", "subtle", "outline-light"].map(key => {
return <>
<Text bold fontSize="xl" mb="4" textAlign="center">
{key}
</Text>
<Alert w="100%" variant={key} colorScheme="success" status="success">
<VStack space={2} flexShrink={1} w="100%">
<HStack flexShrink={1} space={2} alignItems="center" justifyContent="space-between">
<HStack space={2} flexShrink={1} alignItems="center">
<Alert.Icon />
<Text color={getTextColor(key)}>
Selection successfully moved!
</Text>
</HStack>
</HStack>
</VStack>
</Alert>
<Divider mt="5" mb="2.5" />
</>;
})}
</Stack>
</ScrollView>;
}
Composition
Playground
function Example() {
return <Center>
<VStack space={5} maxW="400">
<Alert w="100%" status="success">
<VStack space={2} flexShrink={1} w="100%">
<HStack flexShrink={1} space={1} alignItems="center" justifyContent="space-between">
<HStack space={2} flexShrink={1} alignItems="center">
<Alert.Icon />
<Text fontSize="md" fontWeight="medium" _dark={{
color: "coolGray.800"
}}>
Application received!
</Text>
</HStack>
<IconButton variant="unstyled" _focus={{
borderWidth: 0
}} icon={<CloseIcon size="3" />} _icon={{
color: "coolGray.600"
}} />
</HStack>
<Box pl="6" _dark={{
_text: {
color: "coolGray.600"
}
}}>
Your application has been received. We will review your
application and respond within the next 48 hours.
</Box>
</VStack>
</Alert>
<Alert w="100%" status="success">
<VStack space={1} flexShrink={1} w="100%" alignItems="center">
<Alert.Icon size="md" />
<Text fontSize="md" fontWeight="medium" _dark={{
color: "coolGray.800"
}}>
Application received!
</Text>
<Box _text={{
textAlign: "center"
}} _dark={{
_text: {
color: "coolGray.600"
}
}}>
Your application has been received. We will review your
application and respond within the next 48 hours.
</Box>
</VStack>
</Alert>
</VStack>
</Center>;
}
Action
Playground
function Example() {
const [show, setShow] = React.useState(true);
return <Box w="100%" alignItems="center">
<Collapse isOpen={show}>
<Alert maxW="400" status="error">
<VStack space={1} flexShrink={1} w="100%">
<HStack flexShrink={1} space={2} alignItems="center" justifyContent="space-between">
<HStack flexShrink={1} space={2} alignItems="center">
<Alert.Icon />
<Text fontSize="md" fontWeight="medium" _dark={{
color: "coolGray.800"
}}>
Please try again later!
</Text>
</HStack>
<IconButton variant="unstyled" _focus={{
borderWidth: 0
}} icon={<CloseIcon size="3" />} _icon={{
color: "coolGray.600"
}} onPress={() => setShow(false)} />
</HStack>
<Box pl="6" _dark={{
_text: {
color: "coolGray.600"
}
}}>
Your coupon could not be processed at this time.
</Box>
</VStack>
</Alert>
</Collapse>
<Button size={"sm"} onPress={() => setShow(true)} mt={8} mx="auto">
Re-Open
</Button>
</Box>;
}
Props
Alert
Alert implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
BorderProps
,
ColorProps
,
LayoutProps
,
TypographyProps
,
ShadowProps
,
PositionProps
status
The status of the alert
Type: "info" | (string & {}) | "error" | "success" | "warning"
Default: info
variant
The variant of the alert style to use.
Type: ResponsiveValue<"subtle" | "solid" | "outline" | "left-accent" | "top-accent" | "outline-light" | (string & {})>
Default: subtle
colorScheme
The color scheme of the Alert.
Type: ColorSchemeType
Alert.Icon
AlertIcon implements
react-native-svg
,
View
,
FlexProps
,
LayoutProps
,
ColorProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
BackgroundProps
,
PlatformProps
Styling
NativeBase ships with a default theme for each component. Check out the default theme of the alert
here
.
Info: We can easily extend the alert component theme using extendTheme function as described in the documentation
here
.
Accessibility
Alert has role set to alert.
Previous
Divider
Next
Progress
Quick Nav
Import
Examples
Basic
Status
Variant
Composition
Action
Props
Alert
Alert.Icon
Styling
Accessibility
MadeWithNativeBase
gluestack-ui
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.