Shapeshift
An input that becomes what you mean, made to take your own components. Give each one the words it answers to and a reader for its data, then type a sentence: it works out which one you meant, opens it over the field and fills it in. It's the idea behind my Shapeshift and the bar at the foot of anishfn.ink, as a component you can install, with eight shapes to start from.
bunx --bun shadcn@latest add https://lab.anishfn.ink/r/shapeshift.jsonGive it your own components
A shape is a component of yours and two things about it: the words it answers to, and a reader that pulls its data out of a sentence. Shapeshift does the rest. Here it is with a tip card.
1. Your component. Any component with props. This one takes a percent and a bill.
15% of 80.00
12.00
Total
92.00
<TipCard percent={15} bill={80} />2. Make it a shape. Say what it answers to and how to read its props from a sentence. It's live on the right: try gratuity 20% on 64.50.
Change the numbers, or press Enter to see what onSubmit gets.
What it does for you
- Decides calmly
- A shape opens once its words are in the sentence and its reader has found the data. Mid-word it holds its last reading instead of closing. When two shapes fit, the one that reads more of the sentence wins, then the one you listed first.
- Lists and keys
- Focus the field, or press / anywhere, and every shape is listed, narrowing as you type. Arrows move, Enter picks one or hands its data to onSubmit, Esc clears.
- One button
- Give a shape an action and the field grows a button for it, the same as Enter. If your component is a form, that button submits the form.
- Your theme
- Written in shadcn's own colors (popover, muted, primary, border, ring), so it takes your palette and your dark mode. Every part takes a class of yours too.
- A model, if you like
- Pass classify and a model picks the shape from the sentence. Your readers still fill in the data, so it decides and the code computes.
- Where it opens
- Upward by default, for a bar at the foot of a page. side="bottom" opens it downward, and restWidth lets it rest narrow and widen when it's used.
- Comes from
- Shapeshift, my input that becomes what you mean, and the bar at the foot of anishfn.ink, which is this with my own panels in it.
- Made with
- React, Tailwind and Motion. No model and no other library: matching and reading are plain code you can read.