Components Data display

Alert

A message in the page, in its tone, with an optional action or close.

import { Alert } from '@kition/tessera-ui'
Playground

Props

What is shown
import { Alert } from '@kition/tessera-ui'

<Alert
  tone="warning"
  title="Your trial ends in 3 days"
  description="Add a payment method to keep your workspace."
/>

When to use

  • A state of the account or page the person should know about.

When not to

  • A short confirmation after an action: use a toast.

Examples

Tones, action, close
Password sign-in is turned off
People sign in with GitHub or Google until you turn it back on.
Credits added
alert.tsx
import { useState } from 'react'
import { Alert, Button } from '@kition/tessera-ui'

export default function Demo() {
  const [shown, setShown] = useState(true)
  return (
    <div style={{ display: 'grid', gap: 8 }}>
      <Alert title="Password sign-in is turned off" description="People sign in with GitHub or Google until you turn it back on." />
      <Alert tone="success" title="Credits added" />
      <Alert tone="warning" title="Your plan renews in 3 days" action={<Button size="sm">Manage</Button>} />
      {shown ? <Alert tone="danger" title="The last payment failed" description="Update the card to keep syncing." onClose={() => setShown(false)} /> : null}
    </div>
  )
}

Props

Alert

A message in the page: what happened or what to know, in its tone, with an optional action.

PropTypeDefaultDescription
toneExclude<Tone, 'neutral'>'info'
titlerequiredReactNode—
descriptionReactNode—
actionReactNode—A button or link at the end (Retry, Upgrade).
onClose() => void—Shows a close button that calls it.
classNamestring—
testIdstring—