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";import "capsomer/tokens.css";
import "capsomer/read-only-form.css";
import { ReadOnlyForm } from "capsomer/react/read-only-form";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
| Prop | Type | Required | Does |
|---|---|---|---|
action | string | ||
method | "get" | "post" | ||
encType | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | ||
readOnly | boolean | Yes | |
message | ReactNode | Yes | Why nothing was sent ("This is a demo: changes are not saved."). |
form | ComponentType<ComponentProps<FormComponent> & { ref?: Ref<HTMLFormElement> }> | The app's form (React Router's Form); a plain form by default. It is given the ref. | |
ref | Ref<HTMLFormElement> |
And every attribute of <form>.
Parts and data attributes
| Class | Is |
|---|---|
.cap-read-only-form | the root |