Input
A single-line text field. Use it for names, emails, tokens, numbers, dates, times, and inline searches.
Installation
pnpm dlx shadcn@latest add https://sprout.tulipfarm.ai/r/input.jsonCopies Input and the components it uses (Field) into your app, installs the packages, and adds the styles. Then import it from @/components/ui/input. Needs Tailwind CSS 4 and a components.json from shadcn init.
Install the following dependencies:
pnpm add clsx tailwind-merge @base-ui/reactAdd Sprout base once per app: the
cn()helper and the design tokens.lib/sprout/classes.ts- Design tokens, for your global CSS
Add the components it uses: Field.
Copy and paste the following code into your project.
'use client'; import { Input as BaseInput } from '@base-ui/react/input'; import { cn, stateClassName } from '@/lib/sprout/classes'; import { useFieldControl } from '@/components/ui/field'; export const inputScaleNames = ['md', 'sm', 'lg'] as const; export type InputScale = (typeof inputScaleNames)[number]; export type InputState = BaseInput.State; export interface InputProps extends BaseInput.Props { scale?: InputScale | null; } export function Input({ scale, className, ...rest }: InputProps) { const props = useFieldControl(rest); const size = scale ?? 'md'; return ( <BaseInput data-slot="input" data-scale={size} {...props} className={stateClassName<InputState>(cn('sprout-input', `sprout-input-scale-${size}`), className)} /> ); }Add the styles to your global CSS, after
@import "tailwindcss".@layer components { .sprout-input { box-sizing: border-box; width: 100%; min-width: 0; height: var(--sprout-control-height); border: 1px solid var(--sprout-input); border-radius: var(--sprout-radius-control); background-color: var(--sprout-surface); color: var(--sprout-text); font-family: inherit; font-size: var(--sprout-text-sm); outline-offset: 0; outline: 0 solid #0000; margin: 0; padding: 4px 12px; font-weight: 400; line-height: 20px; } .sprout-input::placeholder { color: var(--sprout-muted); opacity: 1; } .sprout-input:focus-visible { border-color: var(--sprout-border); outline: var(--sprout-focus-width) solid var(--sprout-focus-ring); } .sprout-input:disabled, .sprout-input[data-disabled] { cursor: not-allowed; background-color: var(--sprout-hover); opacity: .5; } .sprout-input[aria-invalid="true"], .sprout-input[data-invalid] { border-color: var(--sprout-danger); } .sprout-input[aria-invalid="true"]:focus-visible, .sprout-input[data-invalid]:focus-visible { outline-color: var(--sprout-danger); } .sprout-input[type="file"] { line-height: calc(var(--sprout-control-height) - 2px); cursor: pointer; padding-block: 0; } .sprout-input[type="file"]:disabled { cursor: not-allowed; } .sprout-input::file-selector-button { height: 24px; color: var(--sprout-text); font: inherit; font-size: var(--sprout-text-sm); cursor: inherit; background: none; border: 0; align-items: center; margin: 0 8px 0 0; padding: 0; font-weight: 500; display: inline-flex; } .sprout-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; } .sprout-input-scale-sm { height: calc(var(--sprout-control-height) - 4px); border-radius: min(var(--sprout-radius-control), 12px); font-size: var(--sprout-text-xs); padding-inline: 8px; line-height: 16px; } .sprout-input-scale-lg { height: calc(var(--sprout-control-height) + 4px); padding-inline: 12px; } .sprout-input-scale-sm[type="file"] { line-height: calc(var(--sprout-control-height) - 6px); } .sprout-input-scale-lg[type="file"] { line-height: calc(var(--sprout-control-height) + 2px); } @media (prefers-reduced-motion: no-preference) { .sprout-input { transition: color var(--sprout-motion-fast, .12s) ease-out, background-color var(--sprout-motion-fast, .12s) ease-out, border-color var(--sprout-motion-fast, .12s) ease-out, outline-color var(--sprout-motion-fast, .12s) ease-out; } } @media (forced-colors: active) { .sprout-input { border-color: fieldtext; } .sprout-input:focus-visible { outline-color: highlight; } } }Import it from
@/components/ui/input. Update the paths if your@/alias points elsewhere.
pnpm add @tulipfarm/sprout@import "tailwindcss";
@import "@tulipfarm/sprout/styles.css";The package keeps the source and ships fixes with each release. Import from @tulipfarm/sprout/input.
Scales
md fits dense forms. lg is for sign-in and onboarding. Each scale shows the fields Cloud uses it for.
Medium
32px · settings, dialogs, builders17/120
Channel ID, like C0123456789.
Large
36px · sign-in and onboardingStates
Empty with a placeholder, filled, read-only, disabled, and invalid, at both scales. Field.Root passes disabled and invalid to the input.
Read-only. Select it to copy.
Read-only. Select it to copy.
Types
Each native type Cloud uses. Date, time, and number inputs keep the browser picker and take min, max, and step.
Paste a comma-separated list to add many.
Stored encrypted. You can rotate it later.
Minutes, from 1 to 1440.
Tokens before older turns are summarised.
Letters, numbers, and dashes.
Your time zone.
Labels without a field
Pair id with a label's htmlFor and point aria-describedby at help and error text. Inline searches use aria-label.
The part before .atlassian.net.
- Customers
- Invoices
- Purchase orders
- Suppliers
- Support tickets
Create workspace
Large inputs in a form. Submit empty to see a field error. The URL acme is taken, so the server error lands on the slug. Inputs are disabled while saving.
Inline rename
autoFocus and aria-label for a title edited in place. Enter saves and Escape cancels. The input is read-only while it saves, so focus stays put.
Hidden file chooser
A hidden file input with a ref, opened by a button. tabIndex={-1} and aria-hidden keep it out of focus and the accessibility tree.
Compositions
SidebarInput is the sidebar search field. Override data-slot and className to set an Input inside your own bordered group.
The group draws the border and focus ring.
Usage
import { Field } from "@base-ui/react/field";
import { Input } from "@tulipfarm/sprout/input";
const [name, setName] = useState("");
<Field.Root invalid={!name.trim()}>
<Field.Label>Agent name</Field.Label>
<Input
value={name}
maxLength={120}
placeholder="People Ops helper"
onChange={(event) => setName(event.target.value)}
/>
<Field.Error match>Enter a name.</Field.Error>
</Field.Root>
<label htmlFor="site">Site ID</label>
<Input id="site" aria-describedby="site-help" />
<Input scale="lg" type="email" placeholder="[email protected]" autoComplete="email" />Input renders a native input and takes every input prop:value or defaultValue, onChange(or Base UI's onValueChange), ref,required, maxLength, pattern,autoComplete, inputMode, and event handlers such as onKeyDown and onPaste.
Props
scale is "sm" (28px, 12px text), "md" (32px, the default, 14px text), or"lg" (36px, 14px text). Use lg for sign-in and onboarding forms.
type can be any native type. Cloud uses text, email, password, number, url, date, time, datetime-local, and file. A visible file input styles its button to match. A hidden file input (hidden, tabIndex={-1},aria-hidden) can be opened with ref.current.click().
disabled dims the input and blocks edits.readOnly keeps it focusable and selectable, which suits copy fields and saving states. aria-invalid draws a danger border and focus ring. The input sets data-slot="input" anddata-scale; you can pass your own data-slot andclassName to set it inside another control.
With a field
Input is a Base UI Input, so it works inside Base UIField.Root. The field gives it an id, labels it withField.Label, describes it with Field.Descriptionand Field.Error, and passes disabled andinvalid. Without a field, pair id with a label's htmlFor, or use aria-label.
SidebarInput
import { SidebarHeader, SidebarInput } from "@tulipfarm/sprout/sidebar";
<SidebarHeader>
<SidebarInput aria-label="Search sample sidebar" placeholder="Search locally…" />
</SidebarHeader>SidebarInput is a default-scale Input on the canvas color, withdata-slot="sidebar-input" anddata-sidebar="input".
Accessibility
Every input needs a name: a field label, a label withhtmlFor, or aria-label. Pointaria-describedby at help and error text. A focused input shows a 2px focus ring, red when invalid. Read-only inputs stay in the tab order; disabled ones leave it.
Color changes take 120ms and stop when reduced motion is requested. In forced colors mode the input keeps a system border and a highlight focus ring.
Theme tokens
The border uses --sprout-input, the fill--sprout-surface, text --sprout-text, and the placeholder --sprout-muted. Focus uses--sprout-focus, invalid --sprout-danger, and disabled --sprout-hover. Radius follows--sprout-radius-control. The opt-in TulipFarm theme tints the focus ring through these tokens.