Skip to content

Alert

Alert components are Display Fields used to provide contextual feedback or record information for the user. They are non-interactive and purely informational.

alert.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'alert_default',
kind: 'display',
type: 'alert',
props: {
text: 'This is a default alert message.',
},
},
],
});
alert.json
{
"form": [
{
"uid": "alert_default",
"kind": "display",
"type": "alert",
"props": {
"text": "This is a default alert message."
}
}
]
}

Use these props to customize your Alert component.

proptypedescription
textstringRequired. The message to display in the alert
levelstringVisual severity of the alert: default, info, success, warning, error. Defaults to default

Use the level property to change the visual importance and color scheme of the alert.

alert.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'alert_levels',
kind: 'display',
type: 'alert',
props: {
text: 'Operation successful!',
level: 'success',
},
},
{
uid: 'alert_levels_2',
kind: 'display',
type: 'alert',
props: {
text: 'Potential issue detected.',
level: 'warning',
},
},
{
uid: 'alert_levels_3',
kind: 'display',
type: 'alert',
props: {
text: 'Operation failed.',
level: 'error',
},
},
],
});
alert.json
{
"form": [
{
"uid": "alert_levels",
"kind": "display",
"type": "alert",
"props": {
"text": "Operation successful!",
"level": "success"
}
},
{
"uid": "alert_levels_2",
"kind": "display",
"type": "alert",
"props": {
"text": "Potential issue detected.",
"level": "warning"
}
},
{
"uid": "alert_levels_3",
"kind": "display",
"type": "alert",
"props": {
"text": "Operation failed.",
"level": "error"
}
}
]
}

Alerts can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables used to style different severity levels and general appearance.

CSS VariableDescription
--gui-radius-mdBorder radius for the alert box
--gui-font-smFont size of the message
--gui-space-2Vertical margin between alerts
--gui-space-3Vertical internal padding
--gui-space-4Horizontal internal padding
Default Level
--gui-bg-surface-hoverBackground color for default alerts
--gui-border-defaultBorder color for default alerts
--gui-text-defaultText color for default alerts
Info Level
--gui-intent-info-bgBackground color for info alerts
--gui-intent-infoBorder color for info alerts
--gui-intent-info-textText color for info alerts
Success Level
--gui-intent-success-bgBackground color for success alerts
--gui-intent-successBorder color for success alerts
--gui-intent-success-textText color for success alerts
Warning Level
--gui-intent-warning-bgBackground color for warning alerts
--gui-intent-warningBorder color for warning alerts
--gui-intent-warning-textText color for warning alerts
Error Level
--gui-intent-error-bgBackground color for error alerts
--gui-intent-errorBorder color for error alerts
--gui-intent-error-textText color for error alerts

This is the anatomy of the Alert Component in case you want to use your CSS styles.

alert-anatomy.html
<div class="gui-alert">
<div class="gui-widget" id="alert_uid">
<div role="alert" class="gui-alert-notification gui-alert-notification--info">
This is an informational message.
</div>
</div>
</div>