Keyframery

Input Group

Icons, text, buttons and a count around an input or textarea, in one field: the focus ring closes in on the whole group, the count rolls as you type and a send button pops in with the first character.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/input-group

This adds components/keyframery/input-group.tsx and its primitive to your project, and installs UI SDK, along with button, input, textarea, which it builds on. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Search } from "lucide-react"

import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/keyframery/input-group"

export default function Usage() {
  return (
    <InputGroup>
      <InputGroupAddon>
        <Search />
      </InputGroupAddon>
      <InputGroupInput aria-label="Search" placeholder="Search" />
    </InputGroup>
  )
}

Anatomy

How the parts fit together:

InputGroup
├── InputGroupAddon
└── InputGroupInput

Examples

Text on both sides

Addons sit before (inline-start) or after (inline-end) the input. Pressing their text focuses it.

Composer

A textarea with a row under it (block-end). The count rolls as you type, and the send button, marked data-show="filled", pops in with the first character.

With a button

InputGroupButton is Keyframery's Button, sized to sit inside the field. Here it copies a link.

Motion

MoveWhat you see
SpringThe focus ring belongs to the group: it starts out wide and closes onto the field on a spring.
RollThe count rolls its digits up or down as the text grows and shrinks.
PopAnything marked data-show="filled", like a send button, pops in with the first character and shrinks away when the field is empty.
PressButtons in the group sink and spring back.

Timing and springiness follow the motion style you set. To change how fast this input group moves, pass speed:

<InputGroup speed="fast">
  …
</InputGroup>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--input-group-faceField surfacebg-background
--input-group-inkField texttext-foreground
--input-group-mutedAddon texttext-muted-foreground
--input-group-radiusField cornersrounded-[10px]
--input-group-fontInput sizetext-[13px]
--input-group-heightInput heighth-9
--input-group-inset-xSide paddingpx-3

API reference

Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.

InputGroup

Renders a <div>, and takes its props too.

Prop

Type

InputGroupAddon

Renders a <div>, and takes its props too.

Prop

Type

InputGroupInput

Renders a <input>, and takes its props too.

Prop

Type

InputGroupButton

Renders a <button>, and takes its props too.

Prop

Type

InputGroupCount

Renders a <span>, and takes its props too.

Prop

Type

InputGroupTextarea

Renders a <textarea>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • InputGroupText: a <span>

Keyboard

KeyWhat it does
TabMoves between the field and the buttons in the group; each is its own tab stop.
EnterPresses the focused button.
SpacePresses the focused button.

Accessibility

Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.

Built on UI SDK's core

UI SDK doesn't ship a input group, so this one is defined with its core: one definePrimitive in components/keyframery/core/input-group-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/input-group.

Questions

How does the animated Input Group for UI SDK move?

Spring: The focus ring belongs to the group: it starts out wide and closes onto the field on a spring. Roll: The count rolls its digits up or down as the text grows and shrinks. Pop: Anything marked data-show="filled", like a send button, pops in with the first character and shrinks away when the field is empty. Press: Buttons in the group sink and spring back.

Do I need Motion or Framer Motion for the animated Input Group?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

UI SDK has no input group. How is this one built on UI SDK?

Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/input-group-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.

What happens to the Input Group when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page