Skip to content

Styling

The Plain renderer puts an rf-* class on every element it draws and ships plain.css to style them. The stylesheet is driven by custom properties, so matching a design means setting variables, not rewriting rules.

Using the stylesheet

The package carries it under fable/assets/, so Fable copies it into fable_modules next to the package's sources, in a folder named after the package and its version:

@import "./fable_modules/Fable.Ripple.Form.Plain.1.0.0/assets/plain.css";

:root {
    --rf-color-accent: #0b7285;
    --rf-radius: 0;
}

Use the version you installed in the path. Set the variables after the import, on :root or on any ancestor of a form.

The variables

VariableDefaultUsed for
--rf-gap0.75remspace between fields; inside sections, lists and wizard steps
--rf-gap-small0.25remlabel to control; vertical padding of controls and buttons
--rf-font-size1remcontrols, checkboxes, radios
--rf-font-size-label0.875remlabels, buttons, status line, wizard steps
--rf-font-size-help0.75remhelp text under a control
--rf-font-familyinheriteverything
--rf-radius6pxcontrols, buttons, sections
--rf-color-text#1a1a1atext
--rf-color-muted#62626ehelp text, inactive steps, drag handles
--rf-color-bg#ffffffcontrols and buttons
--rf-color-border#d6d6ddcontrols, buttons, list items
--rf-color-border-faint#e4e4e8sections, inactive steps, sortable rows
--rf-color-accent#3b45ffsubmit button, focus, active and done steps, checked boxes
--rf-color-accent-hover#2a33e0submit button on hover
--rf-color-accent-contrast#fffffftext on the accent
--rf-color-accent-wash#eef0fffocus ring, sortable row bar
--rf-color-error#c0392berror text, invalid control's border
--rf-color-error-wash#fdf3f2invalid control's background
--rf-color-success#008350success status line

The classes

For your own stylesheet, or to override a rule:

ClassElement
rf-formthe form
rf-field, rf-field--validatingone field: label, control, help
rf-labelthe label
rf-input, rf-select, rf-textarea, rf-input--invalidthe control
rf-help, rf-help--errorthe help line under a control
rf-checkboxa label around a checkbox and its text
rf-radios, rf-radioa radio group and each label in it
rf-section, rf-section__titlefieldset and legend
rf-groupthe fields of Form.group
rf-list, rf-list__items, rf-list__itema list, its rows, one row
rf-button, rf-button--primary, rf-button--small, rf-button--loadingsubmit, add and remove buttons
rf-actionsthe row holding the buttons
rf-status, rf-status--successthe success message; errors use rf-help rf-help--error
rf-steps, rf-steps__segment, --active, --donethe wizard's step list
rf-wizard-step, rf-wizard-step__titlethe current step
rf-sortable, rf-sortable__row, rf-sortable__bar, ...the sortable list

Layout

Form.section "Title" wraps a sub-form in a fieldset with a legend; Form.group puts its fields side by side. Anything else is a Form.wrap: a function that receives the fields and places them in your own markup.

let card (title: string) (form: Form<'A>) : Form<'A> =
    form
    |> Form.wrap (fun context items ->
        Html.div
            [
                attr.className "card"
                Html.h3 title
                yield! context.RenderItems context items
            ]
    )

Another look for a field kind

Keep the field's attributes and change its markup: see Customize the view.

Edit this page