Urgent.News

What's breaking now, across thousands of outlets.

Tech

A verification code is six slots in shadcn, so plan paste and submit

A verification-code field looks like one input. In shadcn it is an InputOTP built from slots, and the paste behavior comes with the component, so the real work is in the submit and resend steps. What the shadcn page covers The page describes the component as "Accessible one-time password component with copy-paste functionality." The install command is pnpm dlx shadcn@latest add input-otp , with…

The verification-code field in shadcn is an accessible one-time password component with copy-paste functionality. The install command is pnpm dlx shadcn@latest add input-otp, and the component can be imported from "@/components/ui/input-otp". To use the component, import InputOTP, InputOTPGroup, InputOTPSeparator, and InputOTPSlot. Set maxLength={6} on the root InputOTP component.

The component can be built with various patterns, including a digits-only pattern using the REGEXP_ONLY_DIGITS regex. The code should be six digits, divided into two groups of three with a separator in between. Use InputOTPSlot components with indices from 0 to 5 to create the groups. The separator is purely visual, and the root's maxLength property determines when the field is full.

To control the input, use the value and onChange props with React state. The form can then check the code before submission. A Verify button should be disabled until six characters are present. The component can also display errors on slots by setting aria-invalid when the server rejects the code. Clear the error when the user edits the field again.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

CORS Explained: Why Browsers Block Cross-Origin API Requests

Anyone who has wired up a browser-side call to an API on a different domain has probably hit the red has been blocked by CORS policy message in the console — even though the server responded just…

  • Browsers block cross-origin API requests due to same-origin policy
  • CORS allows trusted origins to access resources via specific headers
  • Simple requests (GET, HEAD, POST) are handled directly by browser

2027 Budget will boost digital ecosystem

KUALA LUMPUR: The 2027 Budget reinforces Malaysia’s commitment to strengthening its digital economy through investments in connectivity, artificial intelligence (AI) and cybersecurity, the Malaysian…

I Made the Oracle Fail First

A fluent patch is not a pass. A free server that happens to boot is not a pass either. If I cannot make a local oracle fail on a bug I planted myself, I do not get to blame the model, and I do not get…

  • The article emphasizes the need for a mechanism to deliberately cause oracle failure during testing.
  • Free access to the model and use of a free server should be disclosed to avoid biased evaluations.
  • A simple test checks if a function doesn't overshoot a boundary to ensure oracle reliability.

shadcn's accordion shows one item at a time until you set multiple

A single-open accordion makes readers close one answer before they can read the next. The shadcn basic example works that way, and a multiple prop changes it.

  • shadcn accordion displays one item at a time by default
  • multiple prop enables viewing multiple items simultaneously
  • prop allows users to open and view several items together

More from Tuesday 13 October →