Calm motion: animations on this site only fade, with no movement
Rule builder
An automation rule: when something happens, if a condition holds, then do an action
Makes a rule for a smart home or a workflow tool. For a filter with many fields and operators, use the query builder.
Basic
triggers,conditions, andactionsare the lists to pick from. Each option has anidand alabel. Write each label so that it reads well in a sentence, such as "the studio door opens".v-modelis the rule:whenis one trigger id,ifis a list of condition ids, andthenis a list of action ids. All the conditions must hold.- Each part is a fieldset of native menus. "Add a condition" and "Add an action" add a row. The ✕ button removes a row, and its name says what it removes. A rule keeps at least one action row.
- A line under the form reads the rule as one sentence. The demo shows an example.
- "Save the rule" emits
savewith the rule, without empty rows. It is off until the rule has a trigger and an action. - Without
conditions, the "Only if" part does not show. - Change the words with
labelsor a label pack:when,if,then,pick,addIf,addThen,save,preview,and, and the functionsremoveandsentence.
Usage
ts
import { BlessRuleBuilder } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
triggers* | BlessRuleOption[] | — | |
conditions | BlessRuleOption[] | — | |
actions* | BlessRuleOption[] | — | |
labels | Partial<{ when: string; if: string; then: string; pick: string; addIf: string; addThen: string; remove: (what: string) => string; save: string; preview: string; sentence: (when: string, ifs: string, thens: string) => string; and: string; }> | — | |
modelValue | BlessRule | { when: "", if: [], then: [""] } |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: BlessRule] | |
save | [rule: BlessRule] |