Order Form
solanaui/order-formFreeComponent
A take profit and stop loss order form for open trading positions with auto-syncing price/percent fields.
Live preview
live · rendered by the registry
Rendered by solanaui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solanaui.dev/r/order-form.jsonSource
1"use client";23import React from "react";4import { NumericFormat } from "react-number-format";5import { Button } from "@/components/ui/button";6import {7 Card,8 CardContent,9 CardDescription,10 CardHeader,11 CardTitle,12} from "@/components/ui/card";13import { Input } from "@/components/ui/input";14import { Separator } from "@/components/ui/separator";15import type { DetailRow } from "@/registry/lib/types";16import { cn } from "@/lib/utils";1718type OrderFormDetail = DetailRow;1920interface OrderFormProps {21 title?: string;22 description?: string;23 entryPrice?: number;24 details?: OrderFormDetail[];25 onSubmit?: (values: {26 tpPrice: string;27 tpPercent: string;28 slPrice: string;29 slPercent: string;30 }) => void;31 className?: string;32}3334const OrderForm = ({35 title = "Edit TP/SL",36 description = "Adjust the parameters on your order",37 entryPrice,38 details,39 onSubmit,40 className,41}: OrderFormProps) => {42 const [tpPrice, setTpPrice] = React.useState("");43 const [tpPercent, setTpPercent] = React.useState("");44 const [slPrice, setSlPrice] = React.useState("");45 const [slPercent, setSlPercent] = React.useState("");4647 const entryNum = entryPrice ?? 0;4849 const handleTpPriceChange = (value: string) => {50 setTpPrice(value);51 if (entryNum > 0) {52 const priceNum = Number.parseFloat(value);53 if (!Number.isNaN(priceNum)) {54 setTpPercent((((priceNum - entryNum) / entryNum) * 100).toFixed(2));55 } else {56 setTpPercent("");57 }58 }59 };6061 const handleTpPercentChange = (value: string) => {62 setTpPercent(value);63 if (entryNum > 0) {64 const pctNum = Number.parseFloat(value);65 if (!Number.isNaN(pctNum)) {66 setTpPrice((entryNum * (1 + pctNum / 100)).toFixed(2));67 } else {68 setTpPrice("");69 }70 }71 };7273 const handleSlPriceChange = (value: string) => {74 setSlPrice(value);75 if (entryNum > 0) {76 const priceNum = Number.parseFloat(value);77 if (!Number.isNaN(priceNum)) {78 setSlPercent((((entryNum - priceNum) / entryNum) * 100).toFixed(2));79 } else {80 setSlPercent("");81 }82 }83 };8485 const handleSlPercentChange = (value: string) => {86 setSlPercent(value);87 if (entryNum > 0) {88 const pctNum = Number.parseFloat(value);89 if (!Number.isNaN(pctNum)) {90 setSlPrice((entryNum * (1 - pctNum / 100)).toFixed(2));91 } else {92 setSlPrice("");93 }94 }95 };9697 const handleClearTp = () => {98 setTpPrice("");99// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from solanaui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Boxaction-box | solanaui | Components | Free | no deps | |
| Activity Feedactivity-feed | solanaui | Components | Free | 1 dep | |
| Address Displayaddress-display | solanaui | Components | Free | 1 dep | |
| Auth Cardauth-card | solanaui | Components | Free | no deps | |
| Health Barhealth-bar | solanaui | Components | Free | no deps | |
| Leverage Sliderleverage-slider | solanaui | Components | Free | no deps | |
| NFT Cardnft-card | solanaui | Components | Free | no deps | |
| Order Bookorder-book | solanaui | Components | Free | no deps |
