← Back to Pull requests

Document form action buttons in the design system guide #4313

Closed
unknown closed this pull request without merging on Oct 21, 2026 00:25 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 10:05 UTC
Author

@jjmata this writes down the answer to your question on #4184 (question, answer), like I offered there.

Problem

Nothing in the guide says whether a form's buttons go wide or get told apart by variant. Main mostly answers it by how many actions the form has, but the cost basis editor shows how easy that is to miss. Main's popover passes small-button classes to f.submit, which ignores class:, so its Save comes out full width. #4184's first take on a Cancel + Save pair then used size: :sm, which makes 28px buttons on a phone. Your other question, how amounts sit inside an input, isn't written down either.

Change

A ## Form actions section in docs/llm-guides/design-system.md, right after ## Tables and in the same shape (rule, one snippet, bullets). A form with one action ends in f.submit, which is always a full-width primary DS::Button. A form with Cancel and a primary action ends in a right-aligned pair of natural-width buttons at the default size, Cancel first, and the variant carries the hierarchy: Cancel is :secondary or :ghost (a DS::Link with the same variant when it leaves the page).

The bullets cover the two traps from #4184 (f.submit ignores class:, and size: :sm text buttons are 28px with no coarse-pointer bump, which only icon-only buttons get) and point at DS::Dialog#with_action for dialogs whose buttons don't submit a form. A destructive action takes variant: :destructive in the primary's place, as a full-width DS::Button when it's the only action, since f.submit is always primary (Codex caught that one). The last bullet answers your other question: amount inputs stay left-aligned like money_field renders them, and right alignment with tabular digits is for displayed figures and for inputs inside a column of them, like the budget grid.

Docs only, so no screenshots.

Follow-ups (not in this PR)

I went through every Cancel on main (at 9884e617b, so line numbers will drift). 22 Cancel + primary pairs follow the rule and 50 don't, most of them provider pages copied from each other. Grouped by how they break it:

1. Primary first and stretched (class: "flex-1"), with Cancel after it. The provider generator seeds this (lib/generators/provider/family/templates/setup_accounts.html.erb.tt:85), so I'd fix the template first. Then setup_accounts.html.erb for akahu, binance, brex, coinbase, coinspot, enable_banking, fio, ibkr, indexa_capital, kraken, lunchflow, mercury, monobank, questrade, redbark, simplefin, snaptrade, sophtron, trade_republic, trading212 and up, plus indexa_capital_items/select_accounts, simplefin_items/edit and wise_items/select_profiles.
2. Right-aligned, but the primary comes first and Cancel last: select_existing_account.html.erb for binance, coinbase, coinspot, enable_banking, ibkr, kraken, simplefin, trade_republic and trading212.
3. A hand-built Cancel (link_to with button-bg-secondary classes) instead of DS::Link, in an otherwise fine row: select_accounts and select_existing_account for brex, lunchflow and mercury, plus plaid_items/select_existing_account.
4. f.submit inside a pair, so the primary fills the row:
- holdings/show.html.erb:69, the remap security form (its Cancel is a hand-built <button> too)
- onchain_wallet_items/_token_review_form.html.erb:55
- admin/sso_providers/_form.html.erb:297 (hand-built Cancel, and the class: on form.submit is ignored)
- family_exports/new.html.erb:31 (plain form_with, so both buttons are hand-built and split the row in half)
- doorkeeper/applications/_form.html.erb:54 (stock Doorkeeper markup with Bootstrap btn classes we don't define)
5. A stacked full-width pair: import/confirms/show.html.erb:33.
6. An :outline Cancel: splits/new.html.erb:93, splits/edit.html.erb:102, transactions/convert_to_trade.html.erb:173, settings/ai_prompts/show.html.erb:92 and the DS::Dialog Lookbook preview. This is the one group I'm not sure about, since the preview itself does it. If you'd rather allow :outline for Cancel, it's a one-word change in the guide. WDYT?
7. A right-aligned amount input outside a column of figures: the move amount in budget_categories/_move_dialog.html.erb:45.

I left out the cost basis editor (#4184 fixes it), the per-row size: :sm Link buttons in the provider pickers (row actions, not form actions), the OIDC sign-up and link pages (a full-width submit with a way back to sign-in, like password_resets/new), and empty states with Refresh + Cancel.

Validation

  • I checked every claim in the section against main. StyledFormBuilder#submit hard-codes full_width: true and only reads data: from its options. DS::Buttonish::SIZES gives sm text buttons py-1 (28px) and md py-2 (36px), and only the icon-only classes have pointer-coarse:. The DS::Dialog actions slot is flex items-center gap-2 justify-end, and shared/_money_field sets no alignment. All the links in the section resolve.

  • bin/rails test: 12,435 runs, 0 failures, 0 errors on both commits. RuboCop, erb_lint, Biome and Brakeman are clean. No app code changed, so system tests don't apply.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Documentation
    Added guidance for form actions, covering single-action buttons, Cancel and primary button pairs, alignment, sizing, button variants, destructive actions, dialog actions, and amount inputs. Examples clarify how to structure actions and use button hierarchy to distinguish their importance.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: gariasf Review duration: 2299m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4313"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%