Skip to contentKino
Skip to Content

Alert

A message in the page, with an icon for its type, a title, a description and actions. One that opens or closes after the page has loaded makes room as it goes, and a change of type rolls its icon to the next.

npx shadcn add https://kinoui.com/r/alert.json
Share on

Examples

Kino 4.2 is rolling out
Offline edits on iPad reach your workspace this week.
Payment received
$1,280 for 16 seats, paid on 12 Nov.
Your card expires on 30 Nov
Update it to keep Kino Pro after then.

Types

Each type has its own icon, so it reads without its colour: info, and success, warning and error, which take the success, warning and destructive tints.

Your trial ends in 3 days
Pick a plan to keep your 12 notebooks and the team’s comments.

Actions

Buttons or links go under the description in AlertActions.

Notebooks now sort by last edit
Change it from the menu beside each section.
  • Launch plan2 min ago
  • Research notesYesterday
  • Hiring loop3 Nov

Close button

showCloseButton adds a button that closes it. It shrinks away and what is below moves up; opened again, it grows back.

1,240 contacts imported
They’re in People, tagged “Imported 15 Nov”.

Changing type

A new type rolls the icon to the next, so the loading spinner turns into the result, and the box glides to the new text’s height.

Installation

npx shadcn@latest add https://kinoui.com/r/alert.json
Files
components/kino/spinner.tsxlib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxlib/notice.tsxlib/controllable.tscomponents/kino/button.tsxcomponents/kino/alert.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Alert

PropTypeDefaultDescription
type'info''success''warning''error''loading''info'Its kind, which picks its icon, its colour and how soon it is read out. A change rolls the icon and crossfades the colours.
iconReactNodeNoneAn icon in place of the type’s own, or null for none.
showCloseButtonbooleanfalseAdds a button at its end that closes it.
openbooleanNoneWhether it shows, when you hold it yourself. Opening or closing it after the page has loaded grows or shrinks it, and while it closes it keeps what it last said.
defaultOpenbooleantrueWhether it shows at first, when it holds that itself.
onOpenChange(open: boolean) => voidNoneCalled with false when its close button is pressed.

Data attributes

AttributeOnDescription
data-typeAlertIts type.
data-openAlertPresent while it shows; data-closed once it has closed.

Accessibility

  • It is a live region from the start, so what it says when it opens, or when its text changes, is read out: an error as an alert, at once, and any other type as a status. What it says as the page loads is read where it sits, never announced.
  • To announce a message that arrives later, render the alert closed and open it, rather than adding it, so the region is there before its text.
  • Its type never relies on colour alone: each one has its icon, and the title says what happened. The icon is hidden from screen readers.
  • The close button is named Close. Once the alert has gone, Tab carries on from where it was.
  • In forced colours it keeps an outline, so its edge still shows.