mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
Both old names are owned by a different npm account (artemis-prime), so publishing them returns 403 — which is how this surfaced: the 8.0.0 run shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a version that cannot be published and therefore does not exist. Those two were uninstallable. @hanzo/gui and @hanzogui/* are ours, so the framework now carries the name it is imported by everywhere downstream, and the loader moves under the scope we control. The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')` is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting either would change behaviour, so both are untouched. Co-authored-by: Hanzo Dev <[email protected]>
212 lines
5.0 KiB
Plaintext
212 lines
5.0 KiB
Plaintext
---
|
|
title: Alert Dialog
|
|
description: Show an alert prompt in a dialog
|
|
name: alert-dialog
|
|
component: AlertDialog
|
|
package: alert-dialog
|
|
demoName: AlertDialog
|
|
---
|
|
|
|
<HeroContainer showAnimationDriverControl>
|
|
<AlertDialogDemo />
|
|
</HeroContainer>
|
|
|
|
```tsx hero template=AlertDialog
|
|
|
|
```
|
|
|
|
<Highlights
|
|
features={[
|
|
`Comes with styling, completely customizable and themeable.`,
|
|
`Accepts animations, themes, size props and more.`,
|
|
`Accessible with dev-time checks to ensure ARIA props.`,
|
|
]}
|
|
/>
|
|
|
|
AlertDialog is a modal dialog that interrupts the user with important content and expects a response. It's built on Dialog with stricter accessibility requirements, and [automatically stacks](/ui/z-index) above other content.
|
|
|
|
## Installation
|
|
|
|
Alert Dialog is already installed in `hanzogui`, or you can install it independently:
|
|
|
|
```bash
|
|
npm install @hanzogui/alert-dialog
|
|
```
|
|
|
|
## Anatomy
|
|
|
|
```tsx
|
|
import { AlertDialog } from '@hanzo/gui' // or '@hanzogui/alert-dialog'
|
|
|
|
export default () => (
|
|
<AlertDialog>
|
|
<AlertDialog.Trigger />
|
|
<AlertDialog.Portal>
|
|
<AlertDialog.Overlay />
|
|
<AlertDialog.Content>
|
|
<AlertDialog.Title />
|
|
<AlertDialog.Description />
|
|
<AlertDialog.Cancel />
|
|
{/* ... */}
|
|
</AlertDialog.Content>
|
|
</AlertDialog.Portal>
|
|
</AlertDialog>
|
|
)
|
|
```
|
|
|
|
## API Reference
|
|
|
|
### AlertDialog
|
|
|
|
Contains every component for the AlertDialog. Shares all [Dialog Props](/docs/components/dialog#api), except modal which is on by default. Adds:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'native',
|
|
type: 'boolean',
|
|
required: false,
|
|
description: `When true, on iOS it will render as a native AlertDialog.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Trigger
|
|
|
|
Just [Gui Props](/docs/intro/props).
|
|
|
|
### AlertDialog.Portal
|
|
|
|
Renders AlertDialog into appropriate container. Beyond [Gui Props](/docs/intro/props), adds:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'forceMount',
|
|
type: 'boolean',
|
|
required: false,
|
|
description: `Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Content
|
|
|
|
Main container for AlertDialog content, this is where you should apply animations.
|
|
|
|
Beyond [Gui Props](/docs/intro/props), adds:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'forceMount',
|
|
type: 'boolean',
|
|
required: false,
|
|
description: `Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Overlay
|
|
|
|
Displays behind Content. Beyond [Gui Props](/docs/intro/props), adds:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'forceMount',
|
|
type: 'boolean',
|
|
required: false,
|
|
description: `Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Title
|
|
|
|
Required. Can wrap in VisuallyHidden to hide.
|
|
|
|
Defaults to H2, see [Headings](/docs/components/headings).
|
|
|
|
### AlertDialog.Description
|
|
|
|
Required. Can wrap in VisuallyHidden to hide.
|
|
|
|
Defaults to Paragraph, see [Paragraph](/docs/components/text).
|
|
|
|
### AlertDialog.Cancel
|
|
|
|
Closes the AlertDialog, accepts all YStack props. Recommended to use with your own component and `asChild`.
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'displayWhenAdapted',
|
|
type: 'boolean',
|
|
description: `By default Cancel elements hide when Adapt is active. If set to true, they will show when adapted.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Action
|
|
|
|
Confirms the AlertDialog action, accepts all YStack props. Recommended to use with your own component and `asChild`.
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'displayWhenAdapted',
|
|
type: 'boolean',
|
|
description: `By default Action elements hide when Adapt is active. If set to true, they will show when adapted.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### AlertDialog.Destructive
|
|
|
|
A destructive action button for the AlertDialog. When using `native` mode on iOS, this renders with the native red destructive button style. Accepts all YStack props.
|
|
|
|
```tsx
|
|
<AlertDialog native>
|
|
<AlertDialog.Trigger asChild>
|
|
<Button>Delete Account</Button>
|
|
</AlertDialog.Trigger>
|
|
<AlertDialog.Portal>
|
|
<AlertDialog.Overlay />
|
|
<AlertDialog.Content>
|
|
<AlertDialog.Title>Delete Account?</AlertDialog.Title>
|
|
<AlertDialog.Description>This action cannot be undone.</AlertDialog.Description>
|
|
<AlertDialog.Cancel asChild>
|
|
<Button>Cancel</Button>
|
|
</AlertDialog.Cancel>
|
|
<AlertDialog.Destructive asChild>
|
|
<Button theme="red">Delete</Button>
|
|
</AlertDialog.Destructive>
|
|
</AlertDialog.Content>
|
|
</AlertDialog.Portal>
|
|
</AlertDialog>
|
|
```
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'displayWhenAdapted',
|
|
type: 'boolean',
|
|
description: `By default Destructive elements hide when Adapt is active. If set to true, they will show when adapted.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### PortalProvider
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'shouldAddRootHost',
|
|
type: 'boolean',
|
|
required: false,
|
|
description: `Defines whether to add a default root host or not.`,
|
|
},
|
|
]}
|
|
/>
|