Exclusivobeta
Balance Sheet <mv-balance-sheet>
Balanço estruturado de decisão em duas colunas (prós e contras, construir ou comprar, contratar ou não, escolha de fornecedor, uma mudança) apresentado como um livro-razão em que os pontos ficam frente a frente. Cada ponto é uma linha curta editável com um peso de 1 a 5 definido num range nativo desenhado como cinco pontos (teclado, arraste ou clique) e uma confiança opcional (certain, likely, unsure) que o pondera. Qualquer ponto pode ser respondido por um ponto da outra coluna por meio de um menu “Answer with…” (escolha um ponto sem par ou escreva um novo): o par passa para a mesma linha, é ligado por um conector com letra através da margem central, e os dois pontos são parcialmente compensados (o atributo offset, 50% da menor pontuação por padrão), de modo que o ruído já respondido sai dos totais e o que continua em aberto pesa de forma mais fiel. As objeções que ninguém respondeu são destacadas como as verdadeiras questões em aberto, reunidas sob um separador “Not yet answered” e contadas numa linha de veredito simples (“Leaning yes · 17.6 vs 11.9 · 3 unanswered concerns”) cujo contador salta de uma objeção em aberto para a próxima. Um travessão sobre um fulcro se inclina com uma mola para o lado mais pesado (um ângulo fixo com movimento reduzido). Várias opções podem ser pesadas, uma folha por aba, cada aba mostrando o seu saldo, mais uma aba Compare que as classifica numa tabela com barras de saldo divergentes e uma marca “Best balance”. Exporta Markdown (área de transferência) e JSON (download) por um mv-export cancelável, pode persistir em localStorage e é integrado a formulários: o valor JSON inclui os resultados de cada opção, e required e require-answers (toda objeção respondida) determinam a validade. mv-change informa cada edição, mv-verdict dispara quando a inclinação muda de lado, e mv-remove e mv-pair são canceláveis.
| Categoria | Formulários |
|---|---|
| Tipo | Web Component (<mv-balance-sheet>) |
| Status | beta |
| Também instala | button |
| Keywords | exclusive, culture, decision, pros-and-cons, decision-matrix, trade-off, weighted, comparison, vendor-selection, build-vs-buy, risk, verdict, ledger, scale, balance, form, export, markdown, json, adr |
When to use
- A team must decide yes or no on a proposal (a 4-day week, a rewrite, a hire) and wants the reasoning written down and weighed
- Several vendors, tools or offers must be compared on strengths and risks before one is picked
- Every concern raised in a review should be explicitly answered or left visibly open before a decision is submitted
- A decision record needs to be exported to a doc, ticket or ADR as Markdown or stored as structured JSON
Avoid when
- The user is picking one of a few ready-made options (plans, shipping) and needs quick help, not a written argument → use Lifelines instead
- Options should be compared on computed numbers from the same inputs (price, rate, term) rather than on arguments → use Fork instead
- The goal is to find a product in a large catalog by answering questions → use Narrow Down instead
Instalação
node scripts/add.mjs balance-sheet --out ./src/marvelousAgente de IA com o servidor MCP do Marvelous UI: install_components({ slugs: ["balance-sheet"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).
Arquivos copiados (dependências incluídas): tokens/tokens.css, core/base.css, core/dismiss.js, core/dom.js, core/element.js, core/focus.js, core/form.js, core/motion.js, core/position.js, components/balance-sheet/balance-sheet.js, components/balance-sheet/balance-sheet.css, components/button/button.css.
Uso
Marcação de referência, para usar como ponto de partida e personalizar com atributos, data-* e variáveis CSS:
<div id="bs-demo" style="width:min(100%,74rem);margin-inline:auto">
<style>
#bs-demo { display:grid; gap:1.5rem; align-content:start }
#bs-demo .bs-layout { display:grid; grid-template-columns:minmax(0,1fr) 15.5rem; gap:1.25rem; align-items:start }
#bs-demo .bs-intro { display:flex; align-items:flex-end; justify-content:space-between; gap:.5rem 1rem; flex-wrap:wrap; margin-bottom:.75rem }
#bs-demo .bs-intro h3 { margin:0; font-size:1rem; letter-spacing:-.01em }
#bs-demo .bs-intro p { margin:.1875rem 0 0; color:var(--mv-fg-muted); font-size:.8125rem }
#bs-demo .bs-side { position:sticky; top:1rem; display:grid; gap:.875rem; padding:1rem; border:1px solid var(--mv-border); border-radius:var(--mv-radius-xl); background:var(--mv-surface-raised); box-shadow:var(--mv-shadow-sm); font-size:.8125rem }
#bs-demo .bs-side h4 { display:flex; align-items:center; justify-content:space-between; gap:.5rem; margin:0; font-size:.8125rem; font-weight:600 }
#bs-demo .bs-side p { margin:0; color:var(--mv-fg-muted); font-size:.75rem; line-height:1.45 }
#bs-demo .bs-side .mv-choice { font-size:.8125rem }
#bs-demo .bs-sep { height:1px; background:var(--mv-border) }
#bs-demo .bs-log { display:grid; gap:.3125rem; margin:0; padding:0; list-style:none; font:.6875rem/1.45 var(--mv-font-mono); color:var(--mv-fg-muted) }
#bs-demo .bs-log li { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
#bs-demo .bs-log b { color:var(--mv-fg); font-weight:500 }
#bs-demo .bs-form { display:flex; align-items:center; justify-content:space-between; gap:.75rem; flex-wrap:wrap; margin-top:.75rem; color:var(--mv-fg-muted); font-size:.75rem }
#bs-demo .bs-hint { margin:0; color:var(--mv-fg-muted); font-size:.75rem; text-align:center }
@media (max-width:56rem) {
#bs-demo .bs-layout { grid-template-columns:minmax(0,1fr) }
#bs-demo .bs-side { position:static }
}
</style>
<div class="bs-layout">
<section aria-labelledby="bs-week-title">
<div class="bs-intro">
<div>
<h3 id="bs-week-title">Leadership offsite · People & Ops</h3>
<p>Decision due Friday, October 16 · Product team of 14 across Lisbon, Toronto and Singapore</p>
</div>
<span class="mv-badge" data-variant="outline" id="bs-verdict-badge">Leaning yes</span>
</div>
<form id="bs-week-form">
<mv-balance-sheet id="bs-week" name="four-day-week" confidence require-answers
question="Move the product team to a 4-day week?">
<ul>
<li data-side="for" data-weight="5" data-id="retention">Two engineers cited burnout in exit interviews this year; replacing each costs about $48,000</li>
<li data-side="for" data-weight="5" data-confidence="likely" data-id="pilot">Lisbon pilot (Q2): shipped output flat, sick days down 30%</li>
<li data-side="for" data-weight="3" data-id="stagger">Staggered days off (Mon or Fri) keep five-day coverage</li>
<li data-side="for" data-weight="4" data-confidence="likely" data-id="hiring">4-day roles draw roughly 3× more applicants in our markets</li>
<li data-side="for" data-weight="4" data-id="meetings">Forces us to cut recurring meetings (11 h per person per week today)</li>
<li data-side="for" data-weight="3" data-confidence="unsure" data-id="raise">Cheaper than the 8% raise the team asked for in the spring</li>
<li data-side="against" data-weight="3" data-confidence="likely" data-pair="pilot" data-id="cadence">Release cadence could slip during the transition quarter</li>
<li data-side="against" data-weight="4" data-pair="stagger" data-id="support">Customer support needs full coverage on Fridays</li>
<li data-side="against" data-weight="4" data-id="sla">Two enterprise contracts promise a 5-business-day response SLA</li>
<li data-side="against" data-weight="2" data-id="payroll">Payroll and time-off policies must be rewritten in 3 countries</li>
<li data-side="against" data-weight="3" data-confidence="likely" data-id="reverse">Hard to walk back once it is announced</li>
</ul>
</mv-balance-sheet>
<div class="bs-form">
<span id="bs-form-status" role="status">Every concern must be answered before this can be submitted.</span>
<button class="mv-button" data-size="sm" type="submit">Submit decision</button>
</div>
</form>
</section>
<aside class="bs-side" aria-label="Demo controls">
<h4>Options</h4>
<label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" id="bs-conf" checked> Confidence per point</label>
<label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" id="bs-ro"> Read-only record</label>
<div class="bs-sep"></div>
<h4>Try it</h4>
<p>Answer “Hard to walk back” with a new point, or drag a weight: the beam tilts and the verdict line follows.</p>
<button class="mv-button" data-variant="outline" data-size="sm" type="button" id="bs-answer">Answer the SLA concern</button>
<button class="mv-button" data-variant="secondary" data-size="sm" type="button" id="bs-reset">Reset the sheet</button>
<div class="bs-sep"></div>
<h4>Events</h4>
<ol class="bs-log" id="bs-log"><li>-</li></ol>
</aside>
</div>
<!-- Variant: several options in tabs, compared in a summary table -->
<section aria-labelledby="bs-vendor-title">
<div class="bs-intro">
<div>
<h3 id="bs-vendor-title">Vendor review · Platform team</h3>
<p>Three candidates for error monitoring, weighed option by option. Budget: $1,800 / month.</p>
</div>
</div>
<mv-balance-sheet id="bs-vendor" selected="compare" for-label="Strengths" against-label="Risks" for-verdict="in favor" against-verdict="against"
question="Which error-monitoring vendor should we adopt?">
<ul data-option="Lumen Metrics" data-option-id="lumen">
<li data-side="for" data-weight="5" data-id="l1">Source maps and release tracking work out of the box</li>
<li data-side="for" data-weight="4" data-id="l2">EU data residency (Frankfurt) covers our GDPR review</li>
<li data-side="for" data-weight="3" data-id="l3">Annual plan at $1,450 / month for 20 seats</li>
<li data-side="against" data-weight="3" data-pair="l3" data-id="l4">Event overage billed at $0.00028 per event</li>
<li data-side="against" data-weight="2" data-id="l5">No on-prem option if a customer demands one</li>
</ul>
<ul data-option="Tessera Cloud" data-option-id="tessera">
<li data-side="for" data-weight="4" data-id="t1">Already used by the mobile team; one contract</li>
<li data-side="for" data-weight="3" data-id="t2">Best session replay of the three</li>
<li data-side="against" data-weight="5" data-id="t3">US-only hosting blocks two EU customers</li>
<li data-side="against" data-weight="4" data-pair="t1" data-id="t4">Seat price rises to $95 at renewal</li>
<li data-side="against" data-weight="3" data-id="t5">SAML only on the Enterprise tier</li>
</ul>
<ul data-option="Self-hosted stack" data-option-id="self">
<li data-side="for" data-weight="4" data-id="s1">No per-event cost, data never leaves our cloud</li>
<li data-side="for" data-weight="2" data-id="s2">Full control over retention (400 days)</li>
<li data-side="against" data-weight="5" data-pair="s1" data-id="s3">About 0.5 FTE of on-call and upgrades</li>
<li data-side="against" data-weight="4" data-id="s4">Alerting and dashboards to build ourselves</li>
</ul>
</mv-balance-sheet>
</section>
<p class="bs-hint">Open a vendor tab to edit its sheet · the Compare tab ranks the options by net balance · Copy Markdown exports the whole review</p>
<script type="module">
await customElements.whenDefined("mv-balance-sheet");
const $ = (id) => document.getElementById(id);
const sheet = $("bs-week");
const log = $("bs-log");
const badge = $("bs-verdict-badge");
const write = (html) => {
if (log.firstElementChild?.textContent === "-") log.replaceChildren();
const li = document.createElement("li");
li.append(...html);
log.prepend(li);
while (log.children.length > 6) log.lastElementChild.remove();
};
const b = (t) => { const el = document.createElement("b"); el.textContent = t; return el; };
const paintBadge = () => {
const r = sheet.verdict;
badge.textContent = r.verdict.split(" · ")[0];
badge.dataset.variant = r.lean === "for" ? "success" : r.lean === "against" ? "danger" : "secondary";
};
paintBadge();
sheet.addEventListener("mv-change", (e) => {
const { reason, results } = e.detail;
write([b("mv-change "), `${reason} · net ${results[0].net > 0 ? "+" : ""}${results[0].net}`]);
paintBadge();
});
sheet.addEventListener("mv-verdict", (e) => {
write([b("mv-verdict "), `${e.detail.previous} → ${e.detail.lean}`]);
paintBadge();
});
sheet.addEventListener("mv-export", (e) => write([b("mv-export "), e.detail.format]));
$("bs-conf").addEventListener("change", (e) => { sheet.confidence = e.target.checked; paintBadge(); });
$("bs-ro").addEventListener("change", (e) => { sheet.readonly = e.target.checked; });
$("bs-answer").addEventListener("click", () => {
const id = sheet.addItem("for", "Keep a rotating Friday responder for enterprise tickets", { weight: 4, answers: "sla" });
if (id) $("bs-answer").disabled = true;
});
const initial = sheet.value;
$("bs-reset").addEventListener("click", () => { sheet.value = initial; $("bs-answer").disabled = false; paintBadge(); write([b("reset")]); });
const form = $("bs-week-form");
const status = $("bs-form-status");
form.addEventListener("submit", (e) => {
e.preventDefault();
const data = JSON.parse(new FormData(form).get("four-day-week"));
status.textContent = `Submitted: ${data.results[0].verdict}.`;
});
form.addEventListener("invalid", () => { status.textContent = sheet.validationMessage; }, true);
$("bs-vendor").addEventListener("mv-verdict", (e) => write([b("mv-verdict "), `${e.detail.label}: ${e.detail.lean}`]));
</script>
</div>Referência cultural
Robinson Crusoé, Daniel Defoe (1719, livro). Náufrago na ilha, Crusoé põe a sua situação no papel “como devedor e credor”, em duas colunas, cada mal diante de um bem, para julgar a sua condição com sobriedade em vez de se desesperar. A interface transforma isso num livro-razão para decisões: os pontos são pesados em duas colunas, cada argumento pode ser respondido por um contraponto na mesma linha que o compensa em parte, e as objeções que ficam sem resposta se destacam como as verdadeiras questões em aberto, enquanto um travessão e uma linha de veredito simples mostram para que lado a balança pende.
API
Attributes
| Name | Tipo | Default | Description |
|---|---|---|---|
question | string | The decision being weighed, shown as the sheet's heading and used for the export file name. Also stored in the value. | |
for-label / against-label | string | For / Against | Column headings and pan labels (e.g. Pros / Cons, Strengths / Risks, Build / Buy). |
for-verdict / against-verdict | string | yes / no | Words used in the verdict line: “Leaning {word}”, “Clearly {word}”. |
confidence | boolean | Shows a confidence select on every point (Certain ×1, Likely ×0.75, Unsure ×0.5); a point's score is weight × confidence. Unsure pips are hatched, likely pips lighter. | |
offset | number (0..1) | 0.5 | Share of the smaller score that a pair removes from both of its points. 0 = pairing is purely a link; 1 = the smaller point is fully cancelled. Pairing alone never flips the lean; it sharpens the margin. |
tilt | number (deg) | 10 | Maximum beam angle, reached when one side outweighs the other by about 2 to 1. |
multiple | boolean | Shows the option tabs and the Add option button even with a single option. Tabs appear on their own as soon as there are two options. | |
selected | option id | "compare" | Option shown on first render (or the Compare view). Changing the attribute switches tabs. | |
readonly | boolean | Decision record mode: nothing can be edited, added, paired or removed; pairs and verdict stay visible and exports still work. | |
persist | string | localStorage key suffix (mv-balance-sheet:{persist}). The sheet is saved on every change and restored on load before the markup (a value property set by the app wins). clearSaved() forgets it. | |
name / required / disabled | form | Form association: the submitted value is JSON ({ question, options, results }). required = at least one point. | |
require-answers | boolean | The field is invalid while any concern is unanswered (“Answer every concern before submitting (3 open).”), anchored on the first open concern's Answer button. | |
hide-export | boolean | Hides the Copy Markdown / Export JSON buttons (the methods still work). | |
heading-level | 1..6 | 3 | aria-level of the question heading; column headings use the next level. |
locale | BCP 47 | en-US | Number formatting of totals and nets. |
data-side / data-weight / data-confidence / data-id / data-pair | markup | Initial points as <li data-side="for|against"> inside a <ul> child (or directly as children), read once then replaced. data-pair (alias data-answers) names the id of the point it faces. Wrap each option's points in <ul data-option="Label" data-option-id="id">. A <script type="application/json"> child with a value is also accepted. | |
data-lean / data-readonly | set by the component | On the host: for | against | even for the option on screen (empty in the Compare view), and data-readonly while editing is locked. |
Properties
| Name | Tipo | Description |
|---|---|---|
value | { question, options: [{ id, label, items: [{ id, side, text, weight, confidence, pair }] }] } | The whole sheet. Accepts the same shape, { items } for a single option, an array of options or a JSON string; pairs are made symmetric and one-to-one. Setting it emits no event. |
results | Array<{ id, label, for, against, net, ratio, lean, strength, pairs, unanswered: { for, against }, scores, count, verdict }> | Weighed result of every option (read-only). lean: for | against | even; strength: clear | leaning | even | empty; pairs carry their letter and offset; scores are the effective score of each point. |
verdict | result | Result of the option on screen, with its verdict sentence (read-only). |
selectedOption | string | Id of the option on screen, or "compare" (read-only; use select()). |
strings | Partial<Record<string, string>> | Overrides for every visible text and announcement (forLabel, againstLabel, forVerdict, againstVerdict, addFor, addAgainst, answer, answerLabel, pairedLabel, unanswered, verdictLeaning, verdictClear, verdictEven, concernsOne, concernsOther, concernsNone, divider, menuTitle, menuNew, menuUnpair, compare, best, copyMarkdown, exportJSON, announceFlip, requireAnswers…). English defaults. |
question / forLabel / againstLabel / confidence / offset / tilt / readonly / persist … | reflected | Mirror the attributes. |
Methods
| Name | Description |
|---|---|
addItem(side, text, { weight?, confidence?, answers?, option?, id? }) | Adds a point (weight 3 by default) and returns its id; answers pairs it with an existing point of the other side. Emits mv-change (reason "add"). |
removeItem(id, { option? }) | Removes a point (cancelable mv-remove). Returns false if refused. |
pair(a, b, { option? }) / unpair(id, { option? }) | Pairs two points of opposite sides (replacing their previous pairs) or breaks a pair. Cancelable through mv-pair. |
addOption(label?) / removeOption(id) / select(id | "compare") | Manages option sheets and switches tabs. removeOption keeps at least one option and emits a cancelable mv-remove with kind "option". |
toMarkdown() / toJSON() | The decision as Markdown (question, verdict, both columns with weights, answers and unanswered concerns, compare table) or as { question, options, results }. |
copyMarkdown() / downloadJSON() | Same as the footer buttons: clipboard (file fallback) and .json download named after the question. Return Promise<boolean>. |
clearSaved() | Forgets the persisted copy. |
Events
| Name | Description |
|---|---|
mv-change | After every edit. detail: { reason: "add" | "remove" | "edit" | "weight" | "confidence" | "pair" | "unpair" | "option-add" | "option-remove" | "option-rename", value, results (summaries), item, option }. Text edits are reported on commit (blur), not per keystroke. |
mv-verdict | The lean of an option flipped side (for, against or even) after a user action. detail: { option, label, lean, previous, strength, for, against, net, unanswered, verdict }. |
mv-remove | Cancelable, before a point or an option is removed. detail: { kind: "item" | "option", item?, option, label? }. |
mv-pair | Cancelable, before two points are paired or unpaired. detail: { action: "pair" | "unpair", for, against, option }. |
mv-export | Cancelable, before Copy Markdown or Export JSON. detail: { format: "markdown" | "json", text, filename }. preventDefault() to send the text somewhere else (a ticket, an ADR, your API). |
Content structure
| Name | Description |
|---|---|
(content) | Initial data only (<ul>/<li data-side> or a JSON <script>); it is read once and replaced by the sheet. |
CSS classes
| Name | Description |
|---|---|
mv-balance-sheet-head / -question / -scale / -verdict | Head: question heading, the decorative scale (-beam, -arm, -hang[data-side], -cord, -pan, -pan-total, -fulcrum, -pivot, --_tilt) and the verdict line (-lean[data-lean][data-strength], -score, -open). |
mv-balance-sheet-grid / -col / -list / -gutter / -link / -divider | Ledger: three columns sharing rows through subgrid; -link (with -link-badge and -link-offset) joins each pair across the gutter; -divider heads the unanswered rows. Stacks under 38rem of container width. |
mv-balance-sheet-item | A point: data-side, data-paired or data-open, data-hot (hovered or focused with its partner), data-confidence. Parts: -text (textarea), -remove, -weight (-pips, -range), -conf, -tag, -pair (data-letter). |
mv-balance-sheet-add / -answering | Add field under each column and the “Answering …” chip shown while a new point is written as an answer. |
mv-balance-sheet-tabs / -tab / -tab-net / -compare / -table | Option tabs with their net badge, and the Compare view table (-net-bar, -best, -mini-beam). |
mv-balance-sheet-menu | The “Answer with…” menu (Popover API, role="menu"). |
mv-balance-sheet-foot / -note / -export | Footer with the scoring note and export buttons. |
CSS variables
| Name | Default | Description |
|---|---|---|
--mv-balance-sheet-for | var(--mv-success) | Color of the first column, its pan and pips. |
--mv-balance-sheet-against | var(--mv-danger) | Color of the second column, its pan and pips. |
--mv-balance-sheet-open | var(--mv-warning) | Unanswered concerns: edge, tag and verdict count. |
--mv-balance-sheet-link | var(--mv-accent) | Pair connectors, letters and the answering chip. |
--mv-balance-sheet-gutter | 3.5rem | Width of the gutter where pairs meet. |
Accessibility
Each column is a real list (role="list") labelled by its heading (role="heading" with a configurable aria-level, one level below the question), and the heading reads its weighted total (“For, weighted total 17.6”). Every point is made of native controls: a textarea named “Point, For” (Enter moves to the next point, Backspace on an empty point removes it), a Remove button naming the point, a native range labelled “Weight” with aria-valuetext (“4 of 5, major”) driven by arrow keys, Home and End, and a native select for confidence. Pairing never needs dragging: the “Answer” button (aria-haspopup="menu", aria-expanded) names what it answers and opens a menu of the other column's unpaired points plus “Write a new point” and “Unpair”; arrow keys, Home and End move inside it, Escape or Tab closes it and returns focus to the button. A paired button reads “Answered by “…”, pair B”. Writing a new answer shows a visible “Answering …” chip and renames the add field accordingly; Escape cancels it. The beam, pans, gutter connectors and divider are aria-hidden: everything they show is also in text (column totals, the pair letter on both points, the “Unanswered” tag, the verdict line). The verdict line is plain text, and its concern count is a button that moves focus to the next unanswered concern. A polite live region announces additions, removals and pairings; an assertive one announces only when the verdict flips side (“Verdict changed. Leaning no · 12 vs 14.5 · 2 unanswered concerns.”). Tabs follow the tabs pattern (roving tabindex, arrow keys, automatic activation, tabpanel labelled by its tab, each tab named with its verdict); the Compare view is a real table with a caption, column and row headers. Hover or focus on a point highlights its partner. Colors always come with signs and words (+ / −, “Unanswered”, letters, numbers). Reduced motion (OS or data-motion="reduce"): the beam sits at its angle without a spring, rows do not glide when pairs form, the focus pulse becomes a static outline. Forced colors: pips, beam and connectors use CanvasText, unanswered concerns get a dashed border.