Barely Designer

No Green Tick

Forms

About

No green tick on purpose: a shadcn-styled form field with default and error states only. A corrected value returns to neutral, with no green border or success icon. Green is kept for completed actions (Order saved toast). Error = circle icon + text + aria-invalid. Rule proposed, pending clinical sign-off. Demo UI, dummy data.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds No Green Tick to your project and fits it to your theme.

Code

How No Green Tick is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import * as React from "react"
import { CircleAlertIcon, CircleCheckIcon, RotateCcwIcon } from "lucide-react"
import { Toaster } from "sonner"

import { NoGreenTickField, showActionSuccessToast } from "@/components/ui/no-green-tick"

// Demo UI, dummy data. Same 24-field medication order as the "No green tick on purpose" post. Dose is the one error.
const FIELDS: [string, string][] = [
  ["Patient name", "Demo Patient"], ["MRN", "MRN-0000000"], ["Date of birth", "01/01/1970"],
  ["Ward", "Demo Ward 0"], ["Bed", "00"], ["Weight", "70 kg"],
  ["Height", "170 cm"], ["Allergies", "None known"], ["Prescriber", "Dr Demo"],
  ["Drug", "Demodrug"], ["Formulation", "Tablet"], ["Route", "Oral"],
  ["Dose", "1000"], ["Unit", "mg"], ["Frequency", "8-hourly"],
  ["Start date", "24/11/2026"], ["Start time", "08:00"], ["Duration", "5 days"],
  ["Indication", "Demo only"], ["Max doses / 24 h", "3"], ["Dispense qty", "15"],
  ["Pharmacy", "Demo pharmacy"], ["Priority", "Routine"], ["Notes", "With food"],
]
const DOSE = 12
const DOSE_ERROR = "Value must be between 1 and 999"
const check = (i: number, v: string) =>
  i === DOSE ? (/^\d+$/.test(v.trim()) && +v >= 1 && +v <= 999 ? undefined : DOSE_ERROR) : v.trim() ? undefined : "Required"

// Phases follow the post video: 0 blank form, 1 validated, 2 "which one is still wrong?", 3 dose corrected, 4 order saved.
const PHASE_AT = [0, 900, 2700, 4700, 5600]
const CAPTION = ["Same form. Same single error.", "Same form. Same single error.", "Which one is still wrong?", "Success is for completed actions.", "Success is for completed actions."]

const MONO = "font-['Space_Mono',ui-monospace,monospace]"
const SERIF = "font-['IBM_Plex_Serif',Georgia,serif]"
const FOCUS = "outline-none focus-visible:shadow-[0_0_0_2px_#FFFFFF,0_0_0_5px_#304AD5]"

function PanelHead({ n, children }: { n: string; children: React.ReactNode }) {
  return (
    <p className="flex items-center gap-2.5 text-[17px] leading-6 font-semibold text-[#1D1F25]">
      <span className={`${MONO} border border-[#C0C3CD] bg-[#FFFFFF] px-[7px] text-[13px] leading-5 font-normal text-[#5E6477]`}>{n}</span>
      {children}
    </p>
  )
}

function Panel({ checked, children, footer }: { checked: number; children: React.ReactNode; footer: React.ReactNode }) {
  return (
    <div className="rounded-2xl border border-[#C0C3CD] bg-[#FFFFFF] p-5 shadow-[0_20px_40px_rgba(16,24,40,.06)]">
      <div className="mb-4 flex items-baseline justify-between">
        <span className="text-lg font-semibold text-[#1D1F25]">Medication order</span>
        <span className={`${MONO} text-[13px] text-[#5E6477]`}>Checked {checked}/24</span>
      </div>
      <div className="grid grid-cols-2 gap-3 sm:grid-cols-3">{children}</div>
      <div className="mt-5 flex items-center justify-between gap-3">{footer}</div>
    </div>
  )
}

const OrderNo = () => <span className="text-[13px] text-[#5E6477]">Order TEST-0001</span>
const saveClass = `inline-flex h-11 items-center justify-center bg-[#1D1F25] px-[22px] text-[15px] font-semibold text-[#FFFFFF] transition-colors hover:bg-[#434856] ${FOCUS}`

export default function NoGreenTickDemo() {
  const [phase, setPhase] = React.useState(0)
  const [values, setValues] = React.useState(() => FIELDS.map(([, v]) => v))
  const [run, setRun] = React.useState(0)
  const timers = React.useRef<number[]>([])
  const stop = () => { timers.current.forEach(clearTimeout); timers.current = [] }

  React.useEffect(() => {
    // Reduced motion: no walk-through, open on the validated state and let the user fix the dose.
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { setPhase(2); return }
    timers.current = PHASE_AT.slice(1).map((ms, k) => window.setTimeout(() => {
      setPhase(k + 1)
      if (k + 1 === 3) setValues((v) => v.map((x, i) => (i === DOSE ? "10" : x)))
      if (k + 1 === 4) showActionSuccessToast({ title: "Order saved", description: "Demo order TEST-0001" })
    }, ms))
    return stop
  }, [run])

  const replay = () => { stop(); setValues(FIELDS.map(([, v]) => v)); setPhase(0); setRun((r) => r + 1) }

  const save = (e: React.FormEvent) => {
    e.preventDefault()
    stop(); setPhase((p) => Math.max(p, 2))
    const bad = values.findIndex((v, i) => check(i, v))
    if (bad >= 0) return document.getElementById(`ngt-${bad}`)?.focus()
    setPhase(4)
    showActionSuccessToast({ title: "Order saved", description: "Demo order TEST-0001" })
  }

  const validated = phase >= 1
  return (
    <div
      className="min-h-svh w-full bg-[#FFFFFF] px-4 py-8 font-[Inter,ui-sans-serif,system-ui,sans-serif] text-[#1D1F25] sm:px-10"
      style={{ backgroundImage: "radial-gradient(#D7D9DF 1px, transparent 1px)", backgroundSize: "22px 22px" }}
    >
      <div className="mx-auto flex max-w-[1120px] flex-col gap-6">
        <header className="flex flex-wrap items-center justify-between gap-3">
          <span className={`${MONO} border border-[#C0C3CD] bg-[#FFFFFF] px-2.5 py-1 text-[13px] text-[#5E6477]`}>Demo UI, dummy data</span>
          <div className="flex items-center gap-3">
            <span className={`${MONO} hidden bg-[#FFFFFF] text-[13px] text-[#5E6477] md:inline`}>CLINICAL PRECISION DS · FORM FIELD</span>
            <button type="button" onClick={replay} className={`inline-flex h-9 items-center gap-2 border border-[#81889C] bg-[#FFFFFF] px-3 text-sm font-medium text-[#1D1F25] hover:bg-[#F3F4F6] [&_svg]:size-4 ${FOCUS}`}>
              <RotateCcwIcon aria-hidden="true" />
              Replay
            </button>
          </div>
        </header>
        <h1 className={`${SERIF} text-center text-[32px] leading-tight tracking-[-0.02em] text-[#1D1F25]`}>No green tick on purpose.</h1>

        <div className="grid gap-8 lg:grid-cols-2">
          {/* A: the common pattern, shown for comparison only. Static illustration, not the component. */}
          <section className="flex flex-col gap-3" aria-label="A, for comparison: every valid field turns green">
            <PanelHead n="A">Every valid field turns green</PanelHead>
            <Panel checked={validated ? 24 : 0} footer={<><OrderNo /><span aria-hidden="true" className={saveClass}>Save order</span></>}>
              {FIELDS.map(([label, value], i) => {
                const err = validated && i === DOSE
                const ok = validated && i !== DOSE
                return (
                  <div key={label} className="flex min-w-0 flex-col gap-1.5">
                    <span className="truncate text-sm leading-5 font-medium text-[#5E6477]">{label}</span>
                    <div className={`flex h-10 items-center justify-between gap-1 border bg-[#FFFFFF] px-3 text-[15px] transition-colors duration-300 ${err ? "border-[#C34B36]" : ok ? "border-[#3E682B]" : "border-[#81889C]"}`}>
                      <span className="truncate">{value}</span>
                      {ok && <CircleCheckIcon aria-label="valid" className="size-4 shrink-0 text-[#3E682B]" />}
                    </div>
                    {err && (
                      <p className="flex items-start gap-1.5 self-start bg-[#F9EEED] px-1.5 py-0.5 text-sm leading-5 whitespace-nowrap text-[#9C3A2A]">
                        <CircleAlertIcon aria-hidden="true" className="mt-0.5 size-4 shrink-0 text-[#C34B36]" />
                        {DOSE_ERROR}
                      </p>
                    )}
                  </div>
                )
              })}
            </Panel>
          </section>

          {/* B: the No Green Tick field. Valid fields stay neutral; the corrected dose goes back to default. */}
          <section className="flex flex-col gap-3" aria-label="B: valid fields return to neutral">
            <PanelHead n="B">Valid fields return to neutral</PanelHead>
            <form noValidate onSubmit={save}>
              <Panel checked={validated ? 24 : 0} footer={<><OrderNo /><button type="submit" className={saveClass}>Save order</button></>}>
                {FIELDS.map(([label], i) => (
                  <div key={label} className={`-mx-2 -my-1.5 min-w-0 rounded-lg px-2 py-1.5 transition-colors duration-300 ${phase === 2 && i === DOSE ? "bg-[#F9EEED]" : ""}`}>
                    <NoGreenTickField
                      // As in the post: the one-line message runs under the empty space of the next column.
                      className="sm:[&_[role=alert]]:whitespace-nowrap"
                      id={`ngt-${i}`}
                      label={label}
                      value={values[i]}
                      error={validated ? check(i, values[i]) : undefined}
                      inputMode={i === DOSE ? "numeric" : undefined}
                      onChange={(e) => { stop(); setPhase((p) => Math.max(p, 1)); setValues((v) => v.map((x, k) => (k === i ? e.target.value : x))) }}
                    />
                  </div>
                ))}
              </Panel>
            </form>
          </section>
        </div>

        <div className="flex flex-col items-center gap-2 pb-16 text-center">
          <p aria-live="polite" className={`${SERIF} text-[28px] leading-tight tracking-[-0.015em] text-[#1D1F25]`}>{CAPTION[phase]}</p>
          <p className="bg-[#FFFFFF] px-1.5 text-[15px] text-[#5E6477]">DS rule: a corrected field returns to the neutral default state. Proposed, pending clinical sign-off.</p>
        </div>
      </div>
      <Toaster position="bottom-right" theme="light" />
    </div>
  )
}

Dependencies

More by Barely Designer

View all
  • Car sales Dashboard

    Car sales Dashboard

    8
  • ASCII Heart Login

    ASCII Heart Login

    1

More in Forms

View all
  • Premium Auth

    Premium Auth

    577
  • Login 1

    Login 1

    68
  • Contact Card

    Contact Card

    1.1K
  • Form

    Form

    18
  • Login Card

    Login Card

    36
  • Login 2

    Login 2

    15
  • Change Password Form

    Change Password Form

    11
  • Form

    Form

    3

Explore more

Part of Health care — browse the full library on 21st.dev.