Skip to content

Read-only form

A form a read-only visitor can press but not send, with the reason shown in place.

<div data-mount="demo"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/read-only-form.css";

Usage

import { ReadOnlyForm } from "capsomer/react/read-only-form";

<ReadOnlyForm form={Form} method="post" readOnly={isDemo} message="This is a demo: changes are not saved.">...</ReadOnlyForm>

Examples

The same refusal as an inline confirm's last step

<div data-mount="confirm"></div>

API reference

ReadOnlyForm

PropTypeRequiredDoes
actionstring
method"get" | "post"
encType"application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain"
readOnlybooleanYes
messageReactNodeYesWhy nothing was sent ("This is a demo: changes are not saved.").
formComponentType<ComponentProps<FormComponent> & { ref?: Ref<HTMLFormElement> }>The app's form (React Router's Form); a plain form by default. It is given the ref.
refRef<HTMLFormElement>

And every attribute of <form>.

Parts and data attributes

ClassIs
.cap-read-only-formthe root