Warning
Nothing is broken yet — act before it is.
import { Alert } from '@usefragments/ui';
<Alert tone="warning">
<Alert.Icon />
<Alert.Body>
<Alert.Title>Storage almost full</Alert.Title>Highlights information, warnings or errors inline, with context and a clear next action.
import { Alert } from '@usefragments/ui';
<Alert tone="info">
<Alert.Icon />
<Alert.Body>
<Alert.Content>pnpm add @usefragments/uiThe npm package stays managed by your package manager. Import styles once from @usefragments/ui/styles. See the installation guide for framework and theme setup.
Import Alert once, then compose its parts with dot notation.
Alert.IconAlert.BodyAlert.TitleAlert.ContentAlert.ActionsAlert.ActionAlert.CloseNeutral context — nothing went wrong, nothing needs doing.
import { Alert } from '@usefragments/ui';
<Alert tone="info">
<Alert.Icon />
<Alert.Body>
<Alert.Content>
Your session will expire in 15 minutes. Save your work to avoid losing changes.
</Alert.Content>
</Alert.Body>
</Alert>Nothing is broken yet — act before it is.
import { Alert } from '@usefragments/ui';
<Alert tone="warning">
<Alert.Icon />
<Alert.Body>
<Alert.Title>Storage almost full</Alert.Title>Something failed; say what to do about it.
import { Alert } from '@usefragments/ui';
<Alert tone="danger">
<Alert.Icon />
<Alert.Body>
<Alert.Title>Upload failed</Alert.Title>One small soft button; a second verb wraps beside it, never more.
import { Alert } from '@usefragments/ui';
<Alert tone="warning">
<Alert.Icon />
<Alert.Body>
<Alert.Title>Update available</Alert.Title>A close button suits news the user can safely ignore.
import { Alert } from '@usefragments/ui';
<Alert tone="info">
<Alert.Icon />
<Alert.Body>
<Alert.Content>open and onOpenChange let the page bring a dismissed alert back.
import { Alert } from '@usefragments/ui';
const [open, setOpen] = React.useState(true);
<Alert tone="info" open={open} onOpenChange={setOpen}>
<Alert.Icon />Prop | Type | Default | Description |
|---|---|---|---|
Action.children | React.ReactNode | Not set | The label. Optional only so a Button can be the `render` element of a trigger (`<Dialog.Trigger render={<Button />}>Open</Dialog.Trigger>`), where the trigger's children become the label. |
Action.focusableWhenDisabled | boolean | undefined | Not set | Keep a disabled button in the tab order (`aria-disabled` instead of `disabled`), so keyboard and screen reader users can still reach it and read why it is unavailable. |
Action.fullWidth | boolean | undefined | Not set | Fill the parent's width. Without it a button is as wide as its label in every parent, a column stack or a grid cell included. |
Action.nativeButton | boolean | undefined | Not set | Whether the rendered element is a native `<button>`. Inferred from an element passed to `render` (a `<button>`, or a component without `href`); pass it when `render` is a function or a component that renders an anchor without an `href` prop. |
Action.pending | boolean | undefined | Not set | Work started by this button is running. The button sets `aria-busy` and ignores further presses at once; after a second (`--fui-pending-delay`) its label fades and a spinner takes its place, and its width holds. |
Action.render | useRender.RenderProp<Record<string, unknown>> | undefined | Not set | Replace the rendered element, e.g. `render={<a href="/docs" />}` or a router link. A rendered anchor keeps its link semantics (no button role); the button's look, pending and disabled behaviour move onto it. |
Actions.childrenRequired | React.ReactNode | Not set | — |
Body.childrenRequired | React.ReactNode | Not set | — |
childrenRequired | React.ReactNode | Not set | Alert content - use Alert.Icon, Alert.Body, Alert.Title, Alert.Content, Alert.Actions, Alert.Close sub-components |
Close.children | React.ReactNode | Not set | A replacement glyph. Defaults to a cross. |
Close.defaultPressed | boolean | undefined | Not set | Initial pressed state of an uncontrolled toggle. |
Close.nativeButton | boolean | undefined | Not set | Whether the rendered element is a native `<button>`. Inferred from an element passed to `render` (a `<button>`, or a component without `href`). |
Close.onPressedChange | ((pressed: boolean) => void) | undefined | Not set | Called with the next pressed state when the toggle is pressed. |
Close.pending | boolean | undefined | Not set | Work started by this button is running: `aria-busy`, presses ignored, and after a second the icon gives way to a spinner. |
Close.pressed | boolean | undefined | Not set | Controlled pressed state. Passing `pressed`, `defaultPressed` or `onPressedChange` makes the button a toggle: it sets `aria-pressed` and paints the selection wash and ring while pressed. |
Close.render | useRender.RenderProp<Record<string, unknown>> | undefined | Not set | Replace the rendered element, e.g. `render={<a href="/settings" />}` or a router link. A rendered anchor keeps its link semantics (no button role); the look, pending and disabled behaviour move onto it. |
Close.value | string | undefined | Not set | Form value of the button, or the toggle's value inside a group. |
Content.childrenRequired | React.ReactNode | Not set | — |
Icon.children | React.ReactNode | Not set | A replacement glyph. Defaults to the tone's icon. |
onOpenChange | ((open: boolean) => void) | undefined | Not set | Called with false when Alert.Close is pressed |
open | boolean | undefined | Not set | Controlled visibility. Leave unset and the alert hides itself once Alert.Close is pressed. |
Title.childrenRequired | React.ReactNode | Not set | — |
tone | AlertTone | undefinedinfowarningdanger | info | Tone; sets the tint fill, the icon, the title ink and the live-region role |