Rule Cascade
ProA set of rules in the order they are checked, each one a numbered step on a rail that ends in what happens when nothing matches.
- Priority 2When a requestwherethen4 decisions3.3% of 123 in 30 daysJordi Serra21 days ago
- Priority 10When a requestwhereandthen3 decisions2.4% of 123 in 30 daysMarta Puig2 days ago
- Priority 12When a requestwhereandthen25 would match20.3% of 123 in 30 daysJordi SerraYesterday
- Priority 20When a requestwherethenNot runningMarta Puig1 hour ago
- Nothing above matches?Then
Installation#
Usage#
Use it where the order of the rules is the point: the first one that matches decides, so a table that sorts by any column hides how they really run. Sort by priority yourself and end with the fallback.
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
import {
RuleCascade,
RuleCascadeItem,
RuleCascadeStep,
RuleCascadeContent,
RuleCascadeHeader,
RuleCascadeTitle,
RuleCascadeCode,
RuleCascadeMeta,
RuleCascadeStat,
RuleCascadeFallback,
} from "@/components/ui/rule-cascade"Status#
The step says whether a rule takes part. Active rules sit raised on the rail, shadow and draft rules are dashed because they decide nothing, and a rule that is off sinks and dims.
- Priority 10Active ruleActive
- Priority 20Shadow ruleShadow
- Priority 30Draft ruleDraft
- Priority 40Paused ruleOff
- Nothing above matches?Then
Density#
- Priority 2When a requestwherethen4 decisions3.3% of 123 in 30 daysJordi Serra21 days ago
- Priority 10When a requestwhereandthen3 decisions2.4% of 123 in 30 daysMarta Puig2 days ago
- Priority 12When a requestwhereandthen25 would match20.3% of 123 in 30 daysJordi SerraYesterday
- Priority 20When a requestwherethenNot runningMarta Puig1 hour ago
- Nothing above matches?Then
API reference#
RuleCascade
The ordered list and the context every part reads. Renders an ol, so the order is read out. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| density | "comfortable" | "compact" | - | Row padding and the gap to the rail. Reads DensityProvider when unset. |
RuleCascadeItem
One rule. It lays out the step, the content and the meta, and moves the meta beside the content once the list is wider than 42rem.
| Prop | Type | Default | Description |
|---|---|---|---|
| status | "active" | "shadow" | "draft" | "off" | "active" | Draws the step: a raised marker for an active rule, a dashed one for a shadow or a draft, a sunken one for a rule that is off. An off rule's content dims. |
| Data attribute | Description |
|---|---|
| data-status | The status. |
RuleCascadeStep
The marker on the rail, usually the priority. The rail starts at the first marker and stops at the last.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "Priority" | Read before the number by a screen reader. |
RuleCascadeContent
The main column: the header and the rule itself, usually a RuleSentence.
RuleCascadeHeader
The title row. Holds the title, the code and badges such as RuleStatus and RuleVersion.
RuleCascadeTitle
The rule's name. With asChild and a link inside, the whole row opens the rule and takes the hover and the focus ring.
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Renders the child, usually a Link, and stretches it over the row. |
| Data attribute | Description |
|---|---|
| data-link | Present when the title is the row's link. |
RuleCascadeCode
A short identifier beside the title, in tabular numerals.
RuleCascadeMeta
Figures about the rule. Under the content on a narrow list, right-aligned beside it on a wide one.
RuleCascadeStat
One figure with a quieter line under it.
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | ReactNode | - | The figure, such as 12 decisions. |
| detail | ReactNode | - | Context under it, such as the share or a time. |
RuleCascadeFallback
The last step: what happens when no rule above matches. Put it after the items.
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | ReactNode | <ArrowElbowDownRight /> | Drawn in the marker. |
| label | string | "Fallback" | Names the marker for a screen reader. |