Costs Agreement
The costs agreement builder's parts: badges for how an answer resolves and where a value comes from, rule pills and kinds, the question list, the review checks, the template library row and the builder popover.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
LEAP CRMBuilt for the CRM from the core library. It knows about the CRM's own records, so it isn't a general building block.
import { CaBadge, CaRulePill, CaRuleKind, CaQuestionRow, CaQuestionsHeader, CaReceiptCheck, CaTemplateRow, CaPopover } from "@leap-crm/design-system";Playground
Change a prop and the component follows. Its code is under Props.
Props
Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use each CaBadge tone for its one meaning: known, derived or ask for how an answer resolves, and contact, opportunity, firm or external for where a value comes from. Use Badge for labels outside the builder. |
| Do | Set open on a CaRulePill while its popover is open, so the pill keeps the focus ring and screen readers hear it as expanded. |
| Do | Pass the current question's answer controls as CaQuestionRow children, like a Field with Save and Leave blank, and give open and answered rows onSelect so the lawyer can go back to one. |
| Do | Return focus to the pill or field that opened a CaPopover when onClose runs. The builder places the popover itself, so nothing else moves focus back. |
| Do | Use width="xwide" (680 px) for the field popover and the default 340 px for a rule. wide is 520 px for content in between. |
| Don't | Tint a section of the agreement to show a rule applies to it. Put the rule's CaRulePill in the page margin and its CaRuleKind in the popover, so colour stays in the pill and the icon. |
Props
CaBadge
| Prop | Type | Default | Description |
|---|---|---|---|
| tone | | "known" | "derived" | "ask" | "tag" | "rule" | "contact" | "opportunity" | "firm" | "external" | "known" | Where the value comes from: known, derived or asked, each with its own colour. |
| children * | ReactNode | — | What it shows inside. |
CaRulePill
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | false | Its popover is open: the pill takes the focus ring. |
| children * | ReactNode | — | What it shows inside. |
CaRuleKind
| Prop | Type | Default | Description |
|---|---|---|---|
| kind * | CaRuleKind | — | show_when, hide_when, repeat or else: the rule's icon, colour and label. |
CaStatusCircle
| Prop | Type | Default | Description |
|---|---|---|---|
| state * | "open" | "current" | "done" | — | Where the question stands; the circle fills as it moves on. |
CaReceiptCheck
| Prop | Type | Default | Description |
|---|---|---|---|
| status * | "fine" | "look" | — | fine in the known green, or look in the ask amber when it needs attention. |
| title * | ReactNode | — | What was checked, like "Fees match the matter type". |
| detail | ReactNode | — | A grey line under the title on why, or what to look at. |
| children | ReactNode | — | What it shows inside. |
CaTemplateRow
| Prop | Type | Default | Description |
|---|---|---|---|
| title * | string | — | The template's name. |
| meta | string | — | What it covers, like "Family law · 12 questions". |
CaQuestionRow
| Prop | Type | Default | Description |
|---|---|---|---|
| state * | "open" | "done" | "current" | — | open, current (the one being answered) or done. |
| question * | ReactNode | — | The question as the client will read it. |
| answer | ReactNode | — | The answer, shown in green once done. |
| meta | ReactNode | — | A note under the current question, like "Used in 3 places". |
| children | ReactNode | — | The current question's answer controls: a Field with Save and Leave blank, or Yes / No toggles. |
| onSelect | () => void | — | Makes an open or answered question the current one. |
CaQuestionsHeader
| Prop | Type | Default | Description |
|---|---|---|---|
| answered * | number | — | How many questions have an answer. |
| total * | number | — | How many questions there are. |
CaPopover
| Prop | Type | Default | Description |
|---|---|---|---|
| label * | string | — | Names the popover for screen readers. |
| header | ReactNode | — | What leads the header, like a rule pill and its kind. |
| description | ReactNode | — | A muted line under the header, like what the rule does. |
| children | ReactNode | — | The popover's fields. |
| footer | ReactNode | — | The action row at the foot, like Remove rule and Save. |
| onClose * | () => void | — | Runs when the popover's close button is pressed. |
| width | "default" | "wide" | "xwide" | "default" | 340 px by default, 520 wide, 680 for the field dialog. |
Code
What the playground shows, ready to copy.
import { CaBadge } from "@leap-crm/design-system";
<CaBadge>Known</CaBadge>Rules
A rule's name in the page margin opens its popover; open, it takes the focus ring. Each kind has its action hue and icon.
Questions
The sticky header with progress, then each question in document order: open, answered in green with its answer, or current in navy with its answer controls.
Review checks
One check on the review step: fine in the known green, or needs a look in the ask amber. Screen readers hear which.
Fine: Every question answered
9 answers written into the agreement
Needs a look: 2 sections removed by rules
Show when · Matter type is Family law
Template row
A template in the library: a page thumbnail, its title and what it covers. Hover for the subtle fill.
Popover
Every builder popover: the rule pill and kind, a Close, what the rule does, its fields, and an action row. 340, 520 or 680 px wide.
What the examples share
The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.
import { useState } from "react";
import { ActionRow, Button, CaBadge, CaPopover, CaQuestionRow, CaQuestionsHeader, CaReceiptCheck, CaRuleKind, CaRulePill, CaStatusCircle, CaTemplateRow, Field, Input, caRuleKindHints, type CaBadgeTone } from "@leap-crm/design-system";
const tones: CaBadgeTone[] = [
"known",
"derived",
"ask",
"tag",
"rule",
"contact",
"opportunity",
"firm",
"external",
];
function RulePillDemo() {
const [open, setOpen] = useState(false);
return (
<CaRulePill open={open} onClick={() => setOpen(value => !value)}>
Hourly rates
</CaRulePill>
);
}Keyboard
The keys it answers to. Tab moves between components, arrows move within them.
| Keys | What they do |
|---|---|
| Tab | Moves through its buttons in order. |
| EnterSpace | Presses the focused button. |





