shadcn.io is not affiliated with official shadcn/ui
Alert Rules Settings Block for React
An alert rules panel where each rule is a sentence you edit in place with menus and a number field, beside a framed chart of its metric with the threshold line and a computed count of how often it would have fired.
Installation
Overview
Let people write what should wake them, and see what it would have done, with this alert rules panel for React with Base UI. Inside a hairline frame with a plus mark on each corner, a list holds the rules as sentences ("When p95 latency is above 800 ms for 30 min, page the on-call."), each with a Switch and a line saying how often it would have fired in the last six hours. Choosing a rule opens it below as the sentence itself: the metric, the duration and the action are Native Select menus and the threshold is a Number Input. Beside the sentence a framed chart draws that metric's 24 samples as bars, the threshold as a line and every firing as a numbered mark, with the count worked out from the samples, so moving the threshold or lengthening the duration re-counts it on the spot. The last band counts unsaved changes in a status line beside a Shine Button to save them and an outline Button to discard them; both stay in place and focusable while there is nothing to do. On a phone the chart sits under the sentence and the save bar stays pinned to the bottom of the screen. It's built from Switch, Native Select, Number Input, Button, Shine Button and Guides, with hand-drawn bars and a CSS entrance only. For a monitoring or observability product, an on-call tool or any setting with a threshold.
FAQ
How do I fill it with my own metrics and rules?
Edit the constants at the top. Each entry of METRICS has an id, a label, a unit, the range its threshold may take, the value it starts at when someone chooses that metric and its series: the samples, one every 15 minutes from 09:00 UTC. SAVED is the list of rules the account has stored when the page opens, each with its metric, threshold, duration and action. DURATIONS and ACTIONS fill the two menus. Replace the typed series with the last hours of your own data, keeping the 24 samples, or change SAMPLE_MINUTES and the ruler to match.
How is the number of firings worked out?
A rule fires when its metric stays above the threshold for as many samples in a row as the duration covers (30 minutes is two samples), and it fires once per such run: the sample that completes the run is the one marked on the chart, and the rule doesn't fire again until the metric has dropped back under the line. Everything is computed from the typed samples when the page renders, in plain functions, so the chart, the count in the list and the sentence beside the chart always agree, and the numbers are checked against the same code. Nothing is sent when a rule would fire.
Why is the rule edited as a sentence?
Because the sentence is what the rule means, and it is also the label of the controls: "When", "is above", "for" and the commas sit between the menus and the number field, so the order is the reading order and no control needs a separate caption. Each control still has its own name for a screen reader (Metric, Threshold, Duration, Action), the group is a fieldset named for the metric, and changing the metric resets the threshold to that metric's starting value, since 800 means nothing for an error rate.
What happens when I press Save, and what stays local?
Nothing leaves the page. The block keeps two copies of the rules, the saved one and the one being edited, and counts how many settings differ, so the status line can say "3 changes not saved yet." Save makes the edited copy the saved one and says it was saved in this demo; Discard puts the saved copy back. To make it real, send the edited copy to your API in the save handler and update the saved copy from the response, showing the error in the same status line if it fails. Save and Discard are marked aria-disabled rather than disabled while nothing changed, so they keep their place and focus.
Is the chart accessible?
The bars are decoration: the plot is one image named with what it shows (the metric, the period, the peak, the threshold and how many times the rule would have fired), and the same facts are written beside it as text, the count in large figures and the period in the caption. The ruler is drawn left to right in every language, since time on it runs one way. Bars over the threshold are solid and the others a quiet tint, so the chart reads without colour, and every firing carries its number.
How does it look on a phone?
The rules stack as rows with their switch at the end, the sentence's menus and number field wrap onto as many lines as they need, and the chart follows under the count at full width with the same 24 bars. The save bar stays pinned to the bottom of the screen while you scroll.
Related
- Pro
Incident Escalation Settings
Alerts and auditAn escalation policy on a vertical rail whose axis is the clock: tiers with a target, a channel group and a timeout, cumulative minutes on every node, add, move and remove, and a re-page switch.
- Pro
Notification Preferences Settings
NotificationsA notification settings panel: a channel strip with all-or-nothing checkboxes, a matrix of switches by activity and channel with a locked security email, quiet hours, and a save bar that counts unsaved changes.
- Pro
Notification Channels Settings
Alerts and auditA destinations window for alerts: a rail of Slack, email, PagerDuty, webhook and SMS destinations with a status word, beside the chosen one's routing by severity, a pause switch and a simulated test.
- Pro
Alert Rules Changelog
Incidents and uptimeSix changed alert rules as cells on shared hairlines, each with a threshold track showing the old marker hollow and the new one solid, the figures in words, the channels it reaches and its severity, with a channel toggle that steps back the rules that never reach it.
- Pro
Usage Alerts Billing
Plan and usageUsage alert settings: percentage thresholds as switches with number inputs, recipients as email chips, and a choice between email and a webhook, with a save that checks them.
- Pro
Audit Log Settings
Alerts and auditA settings change history in a fixed-height window: changes grouped by area in folds with counts, an actor filter, and a detail pane with the before and after values, who and when, and a Revert that undoes only the latest change to a setting, marks the original and adds a revert event at the top.