suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Input Group

A text field with icons, text, buttons or keyboard hints attached inside its border.

Input Group is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

import { MagnifyingGlassIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupDemo() {
  return (
    <InputGroup className="w-96">
      <InputGroupInput placeholder="Search..." />
      <InputGroupAddon>
        <MagnifyingGlassIcon />
      </InputGroupAddon>
      <InputGroupAddon align="inline-end">12 results</InputGroupAddon>
    </InputGroup>

InputGroup is the container that draws the field's background, border and focus ring. Inside it, place one control, either InputGroupInput or InputGroupTextarea, and one or more InputGroupAddon elements. An addon can hold icons, InputGroupText, InputGroupButton or a Kbd, and is placed before, after, above or below the control with its align prop.

Use an input group when supporting content belongs inside the field, such as a search icon, a currency symbol, a clear button or a send button. For a plain field, use Input; for a field with a filterable list of options, use Combobox, which is built on this component.

Installation

$ pnpm dlx shadcn@latest add @esuiss/input-group

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add input-group
  1. Install the following dependencies and add the cn helper:
$ pnpm add class-variance-authority
  1. Add the pieces it builds on: Button, Input, Textarea.

  2. Copy and paste the following code into your project.

components/ui/input-group.tsx
"use client"

import { cva, type VariantProps } from "class-variance-authority"
import type * as React from "react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { cn } from "@/lib/utils"

function InputGroup({
  className,
  size = "default",
  ...props
}: React.ComponentProps<"div"> & { size?: "default" | "lg" }) {
  return (
    <div
  1. Update the import paths to match your project setup.

Usage

import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"
<div className="w-96">
  <InputGroup>
    <InputGroupInput placeholder="Search..." />
    <InputGroupAddon>
      <MagnifyingGlassIcon />
    </InputGroupAddon>
    <InputGroupAddon align="inline-end">12 results</InputGroupAddon>
  </InputGroup>
</div>

Composition

Use the following composition to build a InputGroup:

InputGroup
├── InputGroupInput
├── InputGroupAddon
│   ├── InputGroupText
│   └── InputGroupButton
└── InputGroupTextarea

Examples

Search

A search field with a clear button that appears only when there is text.

import { MagnifyingGlassIcon, XCircleIcon } from "@phosphor-icons/react"
import * as React from "react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupSearch() {
  const [query, setQuery] = React.useState("MacBook")
  return (
    <InputGroup className="w-96">
      <InputGroupInput
        aria-label="Search"
        placeholder="Search"

With text

Put short text such as a currency symbol and code, or a URL prefix and suffix, in InputGroupText inside an addon.

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

export default function InputGroupWithText() {
  return (
    <div className="flex w-96 flex-col gap-4">
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>$</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="0.00" />
        <InputGroupAddon align="inline-end">

With buttons

Use InputGroupButton inside an addon for actions such as copying a link, subscribing, and showing information.

import { CheckIcon, CopyIcon, InfoIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupWithButtons() {
  return (
    <div className="flex w-96 flex-col gap-4">
      <InputGroup>
        <InputGroupInput
          defaultValue="https://example.com/invite/x7k2"
          aria-label="Invite link"
          readOnly

Button sizes

Use the size prop on InputGroupButton for the xs, icon-xs, icon-sm and icon sizes, shown here in one addon.

import { ArrowUpIcon, CopyIcon, PaperclipIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupButtonSizes() {
  return (
    <InputGroup className="w-96">
      <InputGroupInput placeholder="Type a command..." />
      <InputGroupAddon align="inline-end">
        <InputGroupButton size="xs">Extra small</InputGroupButton>
        <InputGroupButton size="icon-xs" aria-label="Copy">
          <CopyIcon />

Large

Set size="lg" on InputGroup for the 54px field used in forms such as sign-in pages. Here a country code sits in a start addon and a round icon button submits the number.

import { CaretRightIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
} from "@/components/ui/input-group"

export default function InputGroupLarge() {
  return (
    <InputGroup size="lg" className="w-96">
      <InputGroupAddon>
        <InputGroupText className="text-foreground">+90</InputGroupText>
        <span aria-hidden="true" className="ms-1 me-1.5 h-5.5 w-px bg-border" />
      </InputGroupAddon>

With kbd

Place a Kbd in an inline-end addon for a keyboard shortcut hint.

import { MagnifyingGlassIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Kbd } from "@/components/ui/kbd"

export default function InputGroupWithKbd() {
  return (
    <InputGroup className="w-96">
      <InputGroupInput placeholder="Search documentation..." />
      <InputGroupAddon>
        <MagnifyingGlassIcon />
      </InputGroupAddon>
      <InputGroupAddon align="inline-end">

Block addons

Set align to block-start or block-end to place an addon above or below the input. The group grows to fit.

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

export default function InputGroupBlockAddons() {
  return (
    <div className="flex w-96 flex-col gap-4">
      <InputGroup>
        <InputGroupInput placeholder="Enter a title" />
        <InputGroupAddon align="block-start">
          <InputGroupText>Title</InputGroupText>
        </InputGroupAddon>
      </InputGroup>

With textarea

Use InputGroupTextarea as the control for a chat-style field, with attach and send buttons and usage text in a block-end addon.

import { ArrowUpIcon, PaperclipIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"

export default function InputGroupWithTextarea() {
  return (
    <InputGroup className="w-96">
      <InputGroupTextarea placeholder="Ask, search, or chat..." />
      <InputGroupAddon align="block-end">
        <InputGroupButton size="icon-xs" aria-label="Attach file">
          <PaperclipIcon />

Invalid

Set aria-invalid on the control to show the error style on the whole group.

import { InfoIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupInvalid() {
  return (
    <InputGroup className="w-96">
      <InputGroupInput defaultValue="jane@" aria-label="Email" aria-invalid />
      <InputGroupAddon align="inline-end">
        <InfoIcon className="text-destructive" />
      </InputGroupAddon>
    </InputGroup>
  )

Disabled

Disable the control and set data-disabled="true" on InputGroup to dim the group and its addons.

import { MagnifyingGlassIcon } from "@phosphor-icons/react"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"

export default function InputGroupDisabled() {
  return (
    <InputGroup data-disabled="true" className="w-96">
      <InputGroupInput placeholder="Search..." disabled />
      <InputGroupAddon>
        <MagnifyingGlassIcon />
      </InputGroupAddon>
    </InputGroup>
  )

Accessibility

  • InputGroup and InputGroupAddon have the group role.
  • Give the control an accessible name with a label or aria-label; placeholder text and addon text do not name it.
  • Give icon-only buttons an accessible name with aria-label.
  • Buttons in addons are reachable with Tab after the control.
  • Set aria-invalid on the control to communicate a validation error.

API Reference

InputGroup

The container that draws the field and holds the control and addons.

PropTypeDefault
size"default" | "lg""default"

Also accepts the props of React.ComponentProps<"div">.

size="lg" makes the field 54px tall with 16px side padding and 17px text.

Its rounded corners grow when it contains a textarea or a block addon. Each part sets a data-slot, such as input-group-addon, for styling; the input and textarea use input-group-control.

InputGroupAddon

Holds icons, text or buttons beside, above or below the control.

PropTypeDefault
align"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"

Also accepts the props of React.ComponentProps<"div">.

align places the addon before (inline-start) or after (inline-end) the control, or above (block-start) or below (block-end) it. Addons are positioned with CSS order, so you can place them before or after the control in your markup. Clicking an addon outside its buttons focuses the group's input. The addon sets data-align.

InputGroupButton

A compact button sized to fit inside the field.

PropTypeDefault
size"xs" | "sm" | "icon-xs" | "icon-sm" | "icon""xs"
type"button" | "submit" | "reset""button"

Also accepts the props of React.ComponentProps<typeof Button>.

xs is a small text button, icon-xs and icon-sm are square icon buttons, and icon is a 36px round button for lg groups; sm keeps the base button size. type defaults to button, so the button does not submit a surrounding form unless you set type="submit". The button sets data-size.

InputGroupText

Static text or an icon with text, such as a unit or prefix.

Also accepts the props of React.ComponentProps<"span">.

InputGroupInput

The single-line text control of the group.

Also accepts the props of React.ComponentProps<"input">.

InputGroupTextarea

The multi-line text control of the group.

Also accepts the props of React.ComponentProps<"textarea">.

Web

Web preview

import { CopyIcon, MagnifyingGlassIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
} from "@/components/ui/input-group"
import { Spinner } from "@/components/ui/spinner"

export default function InputGroupDemo() {
  const [value, setValue] = React.useState("")
  return (
import { CopyIcon, MagnifyingGlassIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
} from "@/components/ui/input-group"
import { Spinner } from "@/components/ui/spinner"

export default function InputGroupDemo() {
  const [value, setValue] = React.useState("")
  return (
import PhosphorSwift
import SwiftUI

struct InputGroupIcon: View {
  let image: Image

  var body: some View {
    image.frame(width: 16, height: 16)
  }
}

struct InputGroupSearchDemo: View {
  @State private var value = ""

  var body: some View {
    InputGroup {
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular

InputGroup draws one outlined field and places an InputGroupInput or InputGroupTextarea inside it with addons around. Addons can sit on the start or end of the same line (inline-start, inline-end), or above or below the input (block-start, block-end), which turns the group into a column.

The group shows the focus border while its input is focused, and reads the disabled and invalid state from a surrounding Field. Pressing an addon focuses the input. Add children in any order; the group sorts start addons before the input and end addons after it. Put short labels such as a URL prefix or a unit in InputGroupText, and actions in InputGroupButton, a small rounded Button that defaults to the ghost variant and xs size.

Installation

$ pnpm dlx shadcn@latest add @esuiss/input-group

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add input-group
$ pnpm dlx shadcn@latest add @esuiss/input-group

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add input-group --platform swift
$ pnpm dlx shadcn@latest add @esuiss/input-group

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add input-group --platform kotlin

The CLI also adds what it builds on: Button, Icon, Input, Text, Textarea.

  1. Install the following dependencies:
npx expo install class-variance-authority cn
  1. Add the pieces it builds on: Button, Icon, Input, Text, Textarea.

  2. Copy the primitives it uses into components/primitives:

uniwind/components/primitives/event-details.ts
import type { HostInstance } from "react-native"
import type {
  BaseUIChangeEventDetails,
  BaseUIGenericEventDetails,
  ChangeEvent,
} from "./types"

const REASONS = {
  none: "none",
  triggerPress: "trigger-press",
  triggerLongPress: "trigger-long-press",
  outsidePress: "outside-press",
  itemPress: "item-press",
  closePress: "close-press",
  backPress: "back-press",
  accessibilityEscape: "accessibility-escape",
uniwind/components/primitives/field.tsx
import * as React from "react"
import {
  AccessibilityInfo,
  Text as RNText,
  TextInput,
  View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useFieldsetContext } from "./fieldset"
import { fontFamily } from "./font"
import {
  type Values as FormValues,
  useFormContext,
  type ValidationMode,
} from "./form"
import { useEffectEvent } from "./hooks"
uniwind/components/primitives/fieldset.tsx
import * as React from "react"
import { Text as RNText, View } from "react-native"
import type { BaseUIComponentProps } from "./types"
import { useRender } from "./use-render"

interface RootState {
  disabled: boolean
}

type LegendState = RootState

type RootProps = BaseUIComponentProps<typeof View, RootState> & {
  disabled?: boolean | undefined
}

type LegendProps = BaseUIComponentProps<typeof RNText, LegendState>
uniwind/components/primitives/font.ts
type Fonts = { sans?: string; heading?: string }

const fonts: Fonts = {}

function fontFamily(heading = false) {
  const family = heading ? (fonts.heading ?? fonts.sans) : fonts.sans
  return family ? { fontFamily: family } : undefined
}

export { fontFamily, fonts }
uniwind/components/primitives/form.tsx
import * as React from "react"
import { View } from "react-native"
import { createGenericEventDetails, REASONS } from "./event-details"
import { useEffectEvent } from "./hooks"
import type { BaseUIComponentProps, BaseUIGenericEventDetails } from "./types"
import { useRender } from "./use-render"

type ValidationMode = "onSubmit" | "onBlur" | "onChange"

type Values = Record<string, unknown>

type Errors = Record<string, string | string[]>

type SubmitEventReason = typeof REASONS.none

type SubmitEventDetails = BaseUIGenericEventDetails<SubmitEventReason>
uniwind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
uniwind/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
uniwind/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
uniwind/components/primitives/use-controllable-state.ts
import * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"

interface CancelableDetails {
  readonly isCanceled: boolean
}

interface UseControllableStateParameters<
  T,
  Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
  value?: T | undefined
  defaultValue: T
  onChange?: ((value: T, details: Details) => void) | undefined
}
uniwind/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/input-group.tsx:
uniwind/components/ui/input-group.tsx
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import * as React from "react"
import { Pressable, type TextInput, View, type ViewProps } from "react-native"
import { useFieldRootContext } from "@/components/primitives/field"
import { resolveClassName } from "@/components/primitives/use-render"
import { Button } from "@/components/ui/button"
import { IconClassContext } from "@/components/ui/icon"
import { Input } from "@/components/ui/input"
import { Text, TextClassContext } from "@/components/ui/text"
import { Textarea } from "@/components/ui/textarea"

type InputGroupAlign =
  | "inline-start"
  | "inline-end"
  | "block-start"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install class-variance-authority cn
  1. Add the pieces it builds on: Button, Icon, Input, Text, Textarea.

  2. Copy the primitives it uses into components/primitives:

nativewind/components/primitives/event-details.ts
import type { HostInstance } from "react-native"
import type {
  BaseUIChangeEventDetails,
  BaseUIGenericEventDetails,
  ChangeEvent,
} from "./types"

const REASONS = {
  none: "none",
  triggerPress: "trigger-press",
  triggerLongPress: "trigger-long-press",
  outsidePress: "outside-press",
  itemPress: "item-press",
  closePress: "close-press",
  backPress: "back-press",
  accessibilityEscape: "accessibility-escape",
nativewind/components/primitives/field.tsx
import * as React from "react"
import {
  AccessibilityInfo,
  Text as RNText,
  TextInput,
  View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useFieldsetContext } from "./fieldset"
import { fontFamily } from "./font"
import {
  type Values as FormValues,
  useFormContext,
  type ValidationMode,
} from "./form"
import { useEffectEvent } from "./hooks"
nativewind/components/primitives/fieldset.tsx
import * as React from "react"
import { Text as RNText, View } from "react-native"
import type { BaseUIComponentProps } from "./types"
import { useRender } from "./use-render"

interface RootState {
  disabled: boolean
}

type LegendState = RootState

type RootProps = BaseUIComponentProps<typeof View, RootState> & {
  disabled?: boolean | undefined
}

type LegendProps = BaseUIComponentProps<typeof RNText, LegendState>
nativewind/components/primitives/font.ts
type Fonts = { sans?: string; heading?: string }

const fonts: Fonts = {}

function fontFamily(heading = false) {
  const family = heading ? (fonts.heading ?? fonts.sans) : fonts.sans
  return family ? { fontFamily: family } : undefined
}

export { fontFamily, fonts }
nativewind/components/primitives/form.tsx
import * as React from "react"
import { View } from "react-native"
import { createGenericEventDetails, REASONS } from "./event-details"
import { useEffectEvent } from "./hooks"
import type { BaseUIComponentProps, BaseUIGenericEventDetails } from "./types"
import { useRender } from "./use-render"

type ValidationMode = "onSubmit" | "onBlur" | "onChange"

type Values = Record<string, unknown>

type Errors = Record<string, string | string[]>

type SubmitEventReason = typeof REASONS.none

type SubmitEventDetails = BaseUIGenericEventDetails<SubmitEventReason>
nativewind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
nativewind/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
nativewind/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
nativewind/components/primitives/use-controllable-state.ts
import * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"

interface CancelableDetails {
  readonly isCanceled: boolean
}

interface UseControllableStateParameters<
  T,
  Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
  value?: T | undefined
  defaultValue: T
  onChange?: ((value: T, details: Details) => void) | undefined
}
nativewind/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/input-group.tsx:
nativewind/components/ui/input-group.tsx
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import * as React from "react"
import { Pressable, type TextInput, View, type ViewProps } from "react-native"
import { useFieldRootContext } from "@/components/primitives/field"
import { resolveClassName } from "@/components/primitives/use-render"
import { Button } from "@/components/ui/button"
import { IconClassContext } from "@/components/ui/icon"
import { Input } from "@/components/ui/input"
import { Text, TextClassContext } from "@/components/ui/text"
import { Textarea } from "@/components/ui/textarea"

type InputGroupAlign =
  | "inline-start"
  | "inline-end"
  | "block-start"
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Button, Icon, Input, Text, Textarea.

  2. Copy the primitives it uses into components/primitives:

stylesheet/components/primitives/event-details.ts
import type { HostInstance } from "react-native"
import type {
  BaseUIChangeEventDetails,
  BaseUIGenericEventDetails,
  ChangeEvent,
} from "./types"

const REASONS = {
  none: "none",
  triggerPress: "trigger-press",
  triggerLongPress: "trigger-long-press",
  outsidePress: "outside-press",
  itemPress: "item-press",
  closePress: "close-press",
  backPress: "back-press",
  accessibilityEscape: "accessibility-escape",
stylesheet/components/primitives/field.tsx
import * as React from "react"
import {
  AccessibilityInfo,
  Text as RNText,
  TextInput,
  View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useFieldsetContext } from "./fieldset"
import { fontFamily } from "./font"
import {
  type Values as FormValues,
  useFormContext,
  type ValidationMode,
} from "./form"
import { useEffectEvent } from "./hooks"
stylesheet/components/primitives/fieldset.tsx
import * as React from "react"
import { Text as RNText, View } from "react-native"
import type { BaseUIComponentProps } from "./types"
import { useRender } from "./use-render"

interface RootState {
  disabled: boolean
}

type LegendState = RootState

type RootProps = BaseUIComponentProps<typeof View, RootState> & {
  disabled?: boolean | undefined
}

type LegendProps = BaseUIComponentProps<typeof RNText, LegendState>
stylesheet/components/primitives/font.ts
type Fonts = { sans?: string; heading?: string }

const fonts: Fonts = {}

function fontFamily(heading = false) {
  const family = heading ? (fonts.heading ?? fonts.sans) : fonts.sans
  return family ? { fontFamily: family } : undefined
}

export { fontFamily, fonts }
stylesheet/components/primitives/form.tsx
import * as React from "react"
import { View } from "react-native"
import { createGenericEventDetails, REASONS } from "./event-details"
import { useEffectEvent } from "./hooks"
import type { BaseUIComponentProps, BaseUIGenericEventDetails } from "./types"
import { useRender } from "./use-render"

type ValidationMode = "onSubmit" | "onBlur" | "onChange"

type Values = Record<string, unknown>

type Errors = Record<string, string | string[]>

type SubmitEventReason = typeof REASONS.none

type SubmitEventDetails = BaseUIGenericEventDetails<SubmitEventReason>
stylesheet/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
stylesheet/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
stylesheet/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
stylesheet/components/primitives/use-controllable-state.ts
import * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"

interface CancelableDetails {
  readonly isCanceled: boolean
}

interface UseControllableStateParameters<
  T,
  Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
  value?: T | undefined
  defaultValue: T
  onChange?: ((value: T, details: Details) => void) | undefined
}
stylesheet/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/input-group.tsx:
stylesheet/components/ui/input-group.tsx
import * as React from "react"
import {
  Pressable,
  StyleSheet,
  type TextInput,
  View,
  type ViewProps,
} from "react-native"
import { useFieldRootContext } from "@/components/primitives/field"
import { Button, type ButtonSize } from "@/components/ui/button"
import { IconSizeContext } from "@/components/ui/icon"
import { Input } from "@/components/ui/input"
import { Text, TextStyleContext } from "@/components/ui/text"
import { Textarea } from "@/components/ui/textarea"
import { fontSize, metrics, radius, useTheme } from "@/components/ui/theme"
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/InputGroup.swift
import SwiftUI

public enum InputGroupAddonAlign: CaseIterable, Sendable, Hashable {
  case inlineStart, inlineEnd, blockStart, blockEnd

  var isBlock: Bool {
    self == .blockStart || self == .blockEnd
  }
}

public enum InputGroupSize: CaseIterable, Sendable {
  case `default`, lg

  var height: CGFloat {
    self == .lg ? InputMetrics.largeHeight : Metrics.Height.input
  }
swift/Components/Button.swift
import SwiftUI

public struct VariantButtonStyle: ButtonStyle {
  public enum Variant: CaseIterable, Sendable {
    case `default`, outline, secondary, tinted, ghost, plain, destructive, link
  }

  public enum Size: CaseIterable, Sendable {
    case `default`, xs, sm, lg, xl, form, icon, iconXs, iconSm, iconLg, iconXl

    var height: CGFloat {
      switch self {
      case .xs, .iconXs: Metrics.Height.buttonXs
      case .sm, .iconSm: Metrics.Height.buttonSm
      case .default, .icon: Metrics.Height.button
      case .lg, .iconLg: Metrics.Height.buttonLg
swift/Components/ButtonGroup.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var buttonGroup: Axis? = nil
  @Entry var buttonGroupSize: CGSize = .zero
}

enum ButtonGroupSpace: Hashable {
  case group
}

struct ButtonGroupFrame {
  let bounds: Anchor<CGRect>
  let outlined: Bool
}
swift/Components/Checkbox.swift
import PhosphorSwift
import SwiftUI

extension Shadow {
  static let control = Shadow(color: .black.opacity(0.08), radius: 0.5, y: 0.5)
  static let thumb = Shadow(color: .black.opacity(0.12), radius: 1.5, y: 1)
}

struct SelectionIndicator<Mark: View>: View {
  let checked: Bool
  let pressed: Bool
  let cornerRadius: CGFloat
  let mark: Mark

  @Environment(\.isEnabled) private var isEnabled
  @Environment(\.isInvalid) private var invalid
swift/Components/Field.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var isInvalid = false
  @Entry var fieldInset = false
  @Entry var fieldSize = FieldSize.default
  @Entry var fieldGroupInset = false
  @Entry var fieldSetInset = false
}

extension View {
  public func invalid(_ isInvalid: Bool = true) -> some View {
    environment(\.isInvalid, isInvalid)
  }
}
swift/Components/Haptics.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var hapticsEnabled = true
}

extension View {
  public func haptics(_ enabled: Bool) -> some View {
    environment(\.hapticsEnabled, enabled)
  }

  func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
    modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
  }

  func hapticFeedback<Trigger: Equatable>(
swift/Components/Input.swift
import SwiftUI

public struct InputStyle: TextFieldStyle {
  public enum Size: CaseIterable, Sendable {
    case `default`, md, sm, lg

    var height: CGFloat {
      switch self {
      case .default: Metrics.Height.input
      case .md: 36
      case .sm: 32
      case .lg: InputMetrics.largeHeight
      }
    }

    var horizontalPadding: CGFloat {
swift/Components/Separator.swift
import SwiftUI

public struct Separator: View {
  let orientation: Axis

  public init(_ orientation: Axis = .horizontal) {
    self.orientation = orientation
  }

  public var body: some View {
    Rectangle()
      .fill(EsuissColor.border)
      .frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
      .frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
      .accessibilityHidden(true)
  }
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/InputGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Field.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.LayoutScopeMarker
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/FormSupport.kt
package com.esuiss.ui.components

import android.provider.Settings
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
kotlin/components/Label.kt
package com.esuiss.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Typography
kotlin/components/Separator.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Separator(
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { CopyIcon, MagnifyingGlassIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText } from "@/components/ui/input-group"
import { Spinner } from "@/components/ui/spinner"

function SearchDemo() {
  const [value, setValue] = React.useState("")
  return (
    <InputGroup>
      <InputGroupInput
        placeholder="Search"
        value={value}
        onValueChange={setValue}
      />
      <InputGroupAddon>
        <Icon as={MagnifyingGlassIcon} />
      </InputGroupAddon>
      {value ? (
        <InputGroupAddon align="inline-end">
          <InputGroupButton
            size="icon-xs"
            accessibilityLabel="Clear"
            onPress={() => setValue("")}
          >
            <Icon as={XIcon} />
          </InputGroupButton>
        </InputGroupAddon>
      ) : null}
    </InputGroup>
  )
}

export function InputGroupExample() {
  return (
    <View className="gap-4">
      <SearchDemo />
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>https://</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="example.com" autoCapitalize="none" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>.com</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup>
        <InputGroupInput defaultValue="sk_live_51H8" />
        <InputGroupAddon align="inline-end">
          <InputGroupButton size="icon-xs" accessibilityLabel="Copy">
            <Icon as={CopyIcon} />
          </InputGroupButton>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup>
        <InputGroupInput placeholder="Searching..." />
        <InputGroupAddon align="inline-end">
          <Spinner />
        </InputGroupAddon>
      </InputGroup>
      <InputGroup invalid>
        <InputGroupInput defaultValue="not-an-email" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>Invalid</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup disabled>
        <InputGroupInput placeholder="Disabled" />
        <InputGroupAddon>
          <Icon as={MagnifyingGlassIcon} />
        </InputGroupAddon>
      </InputGroup>
    </View>
  )
}
import { CopyIcon, MagnifyingGlassIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText } from "@/components/ui/input-group"
import { Spinner } from "@/components/ui/spinner"

function SearchDemo() {
  const [value, setValue] = React.useState("")
  return (
    <InputGroup>
      <InputGroupInput
        placeholder="Search"
        value={value}
        onValueChange={setValue}
      />
      <InputGroupAddon>
        <Icon as={MagnifyingGlassIcon} />
      </InputGroupAddon>
      {value ? (
        <InputGroupAddon align="inline-end">
          <InputGroupButton
            size="icon-xs"
            accessibilityLabel="Clear"
            onPress={() => setValue("")}
          >
            <Icon as={XIcon} />
          </InputGroupButton>
        </InputGroupAddon>
      ) : null}
    </InputGroup>
  )
}

export function InputGroupExample() {
  return (
    <View style={{ gap: 16 }}>
      <SearchDemo />
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>https://</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="example.com" autoCapitalize="none" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>.com</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup>
        <InputGroupInput defaultValue="sk_live_51H8" />
        <InputGroupAddon align="inline-end">
          <InputGroupButton size="icon-xs" accessibilityLabel="Copy">
            <Icon as={CopyIcon} />
          </InputGroupButton>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup>
        <InputGroupInput placeholder="Searching..." />
        <InputGroupAddon align="inline-end">
          <Spinner />
        </InputGroupAddon>
      </InputGroup>
      <InputGroup invalid>
        <InputGroupInput defaultValue="not-an-email" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>Invalid</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup disabled>
        <InputGroupInput placeholder="Disabled" />
        <InputGroupAddon>
          <Icon as={MagnifyingGlassIcon} />
        </InputGroupAddon>
      </InputGroup>
    </View>
  )
}
import PhosphorSwift
import SwiftUI

struct InputGroupIcon: View {
  let image: Image

  var body: some View {
    image.frame(width: 16, height: 16)
  }
}

struct InputGroupSearchDemo: View {
  @State private var value = ""

  var body: some View {
    InputGroup {
      InputGroupInput("Search", text: $value)
      InputGroupAddon {
        InputGroupIcon(image: Ph.magnifyingGlass.regular)
      }
      if !value.isEmpty {
        InputGroupAddon(align: .inlineEnd) {
          InputGroupButton(size: .iconXs) {
            value = ""
          } label: {
            InputGroupIcon(image: Ph.x.regular)
          }
          .accessibilityLabel(Text("Clear"))
        }
      }
    }
  }
}

struct InputGroupDefaultDemo: View {
  @State private var domain = ""
  @State private var key = "sk_live_51H8"
  @State private var searching = ""
  @State private var email = "not-an-email"
  @State private var disabled = ""

  var body: some View {
    VStack(alignment: .leading, spacing: 16) {
      InputGroupSearchDemo()
      InputGroup {
        InputGroupAddon {
          InputGroupText("https://")
        }
        InputGroupInput("example.com", text: $domain)
          .textInputAutocapitalization(.never)
        InputGroupAddon(align: .inlineEnd) {
          InputGroupText(".com")
        }
      }
      InputGroup {
        InputGroupInput("", text: $key)
        InputGroupAddon(align: .inlineEnd) {
          InputGroupButton(size: .iconXs) {} label: {
            InputGroupIcon(image: Ph.copy.regular)
          }
          .accessibilityLabel(Text("Copy"))
        }
      }
      InputGroup {
        InputGroupInput("Searching...", text: $searching)
        InputGroupAddon(align: .inlineEnd) {
          Spinner()
        }
      }
      InputGroup {
        InputGroupInput("", text: $email)
        InputGroupAddon(align: .inlineEnd) {
          InputGroupText("Invalid")
        }
      }
      .invalid()
      InputGroup {
        InputGroupInput("Disabled", text: $disabled)
        InputGroupAddon {
          InputGroupIcon(image: Ph.magnifyingGlass.regular)
        }
      }
      .disabled(true)
    }
  }
}
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.MagnifyingGlass
import com.adamglin.phosphoricons.regular.X
import com.esuiss.ui.components.Icon
import com.esuiss.ui.components.InputGroup
import com.esuiss.ui.components.InputGroupAddon
import com.esuiss.ui.components.InputGroupAddonAlign
import com.esuiss.ui.components.InputGroupButton
import com.esuiss.ui.components.InputGroupButtonSize
import com.esuiss.ui.components.InputGroupInput
import com.esuiss.ui.components.InputGroupText
import com.esuiss.ui.components.Spinner

@Composable
fun InputGroupSearch() {
    var value by rememberSaveable { mutableStateOf("") }
    InputGroup {
        InputGroupInput(value, { value = it }, placeholder = "Search")
        InputGroupAddon {
            Icon(PhosphorIcons.Regular.MagnifyingGlass, contentDescription = null)
        }
        if (value.isNotEmpty()) {
            InputGroupAddon(align = InputGroupAddonAlign.InlineEnd) {
                InputGroupButton(onClick = { value = "" }, size = InputGroupButtonSize.IconXs) {
                    Icon(PhosphorIcons.Regular.X, contentDescription = "Clear")
                }
            }
        }
    }
}

@Composable
fun InputGroupDefault() {
    var domain by rememberSaveable { mutableStateOf("") }
    var key by rememberSaveable { mutableStateOf("sk_live_51H8") }
    var searching by rememberSaveable { mutableStateOf("") }
    var email by rememberSaveable { mutableStateOf("not-an-email") }
    var disabled by rememberSaveable { mutableStateOf("") }
    Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(16.dp)) {
        InputGroupSearch()
        InputGroup {
            InputGroupAddon { InputGroupText("https://") }
            InputGroupInput(
                domain,
                { domain = it },
                placeholder = "example.com",
                keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.None),
            )
            InputGroupAddon(align = InputGroupAddonAlign.InlineEnd) { InputGroupText(".com") }
        }
        InputGroup {
            InputGroupInput(key, { key = it })
            InputGroupAddon(align = InputGroupAddonAlign.InlineEnd) {
                InputGroupButton(onClick = {}, size = InputGroupButtonSize.IconXs) {
                    Icon(PhosphorIcons.Regular.Copy, contentDescription = "Copy")
                }
            }
        }
        InputGroup {
            InputGroupInput(searching, { searching = it }, placeholder = "Searching...")
            InputGroupAddon(align = InputGroupAddonAlign.InlineEnd) { Spinner() }
        }
        InputGroup(invalid = true) {
            InputGroupInput(email, { email = it })
            InputGroupAddon(align = InputGroupAddonAlign.InlineEnd) { InputGroupText("Invalid") }
        }
        InputGroup(enabled = false) {
            InputGroupInput(disabled, { disabled = it }, placeholder = "Disabled")
            InputGroupAddon {
                Icon(PhosphorIcons.Regular.MagnifyingGlass, contentDescription = null)
            }
        }
    }
}

Examples

With textarea

Use a block-end addon with InputGroupTextarea for a footer row, here holding a usage label and a button.

Web

Web preview

import { ArrowUpIcon } from "phosphor-react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"

export default function InputGroupWithTextarea() {
  return (
    <InputGroup>
      <InputGroupTextarea
        placeholder="Ask, search or chat..."
        numberOfLines={3}
import { ArrowUpIcon } from "phosphor-react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"

export default function InputGroupWithTextarea() {
  return (
    <InputGroup>
      <InputGroupTextarea
        placeholder="Ask, search or chat..."
        numberOfLines={3}
import PhosphorSwift
import SwiftUI

struct InputGroupIcon: View {
  let image: Image

  var body: some View {
    image.frame(width: 16, height: 16)
  }
}

struct InputGroupTextareaDemo: View {
  @State private var message = ""

  var body: some View {
    InputGroup {
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ArrowUp
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Icon
import com.esuiss.ui.components.InputGroup

Button sizes

The xs, icon-xs, icon-sm and icon button sizes in one addon.

Web

Web preview

import { ArrowUpIcon, CopyIcon, PaperclipIcon } from "phosphor-react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Text } from "@/components/ui/text"

export default function InputGroupButtonSizes() {
  return (
    <InputGroup>
      <InputGroupInput placeholder="Type a command..." />
      <InputGroupAddon align="inline-end">
        <InputGroupButton size="xs">
import PhosphorSwift
import SwiftUI

struct InputGroupIcon: View {
  let image: Image

  var body: some View {
    image.frame(width: 16, height: 16)
  }
}

struct InputGroupButtonSizesDemo: View {
  @State private var message = ""

  var body: some View {
    InputGroup {
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.semantics.contentDescription
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ArrowUp
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Paperclip
import com.esuiss.ui.components.ButtonVariant
import com.esuiss.ui.components.Icon
import com.esuiss.ui.components.InputGroup
import com.esuiss.ui.components.InputGroupAddon

Large

The lg group for forms such as sign-in screens, with a country code before the number and a round icon button that submits it.

Web

Web preview

import { CaretRightIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Text } from "@/components/ui/text"

export default function InputGroupLarge() {
  return (
    <InputGroup size="lg">
      <InputGroupAddon>
        <Text className="text-foreground">+90</Text>
import { CaretRightIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Text } from "@/components/ui/text"
import { useTheme } from "@/components/ui/theme"

export default function InputGroupLarge() {
  const { colors } = useTheme()
  return (
    <InputGroup size="lg">
import PhosphorSwift
import SwiftUI

struct InputGroupIcon: View {
  let image: Image

  var body: some View {
    image.frame(width: 16, height: 16)
  }
}

struct InputGroupLargeDemo: View {
  @State private var phone = ""

  var body: some View {
    InputGroup(size: .lg) {
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons

Block start

A label addon above the input with block-start.

React Native
Input group block start in React Native, light modeInput group block start in React Native, dark mode
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Text } from "@/components/ui/text"

export default function InputGroupBlockStart() {
  return (
    <InputGroup>
      <InputGroupInput placeholder="Enter your name" />
      <InputGroupAddon align="block-start">
        <Text className="text-sm font-medium text-foreground">Full name</Text>
      </InputGroupAddon>
    </InputGroup>
  )
import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@/components/ui/input-group"
import { Text } from "@/components/ui/text"
import { fontSize, useTheme } from "@/components/ui/theme"

export default function InputGroupBlockStart() {
  const { colors } = useTheme()
  return (
    <InputGroup>
      <InputGroupInput placeholder="Enter your name" />
      <InputGroupAddon align="block-start">
        <Text style={{ ...fontSize.sm, fontWeight: "500", color: colors.foreground }}>Full name</Text>
      </InputGroupAddon>
import SwiftUI

struct InputGroupBlockStartDemo: View {
  @State private var name = ""

  var body: some View {
    InputGroup {
      InputGroupInput("Enter your name", text: $name)
      InputGroupAddon(align: .blockStart) {
        Text("Full name")
          .textStyle(.sm, weight: .medium)
          .foregroundStyle(EsuissColor.foreground)
      }
    }
  }
}
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.text.font.FontWeight
import com.esuiss.ui.components.InputGroup
import com.esuiss.ui.components.InputGroupAddon
import com.esuiss.ui.components.InputGroupAddonAlign
import com.esuiss.ui.components.InputGroupInput
import com.esuiss.ui.components.Text
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Typography

@Composable
fun InputGroupBlockStart() {

Accessibility

  • The container has the group role.
  • Addons are not separate accessibility elements; their text is not announced with the input, so give the input an accessibilityLabel that includes needed context.
  • Icon-only buttons need an accessibilityLabel.

API Reference

InputGroup

Field container that lays out the input and addons.

PropTypeDefault
size"default" | "lg""default"
disabledbooleanfalse
invalidboolean-

Also accepts the props of ViewProps.

Set invalid to show the destructive border and tint, or disabled to disable the group and its input, or let a Field provide them. Focus turns the border outline to ring with a solid ring. lg makes the group 54 tall with 16 point padding and 17 point text.

InputGroupAddon

Slot for text, icons or buttons beside or around the input.

PropTypeDefault
align"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"

Also accepts the props of React.ComponentProps<typeof Pressable>.

inline-start and inline-end place the addon on the same line as the input; block-start and block-end place it above or below and turn the group into a column.

InputGroupButton

Compact button inside an addon.

PropTypeDefault
size"xs" | "sm" | "icon-xs" | "icon-sm" | "icon""xs"

Also accepts the props of React.ComponentProps<typeof Button>.

icon is a 36 point round button for lg groups.

InputGroupText

Text inside an addon.

Also accepts the props of React.ComponentProps<typeof Text>.

InputGroupInput

Single-line input without its own border.

Also accepts the props of React.ComponentProps<typeof Input>.

InputGroupTextarea

Multi-line input without its own border.

Also accepts the props of React.ComponentProps<typeof Textarea>.

InputGroupAddonAlign

Values: .inlineStart, .inlineEnd, .blockStart, .blockEnd.

InputGroupSize

Values: .default, .lg.

InputGroup

Field container that lays out the input and addons.

ParameterTypeDefault
sizeSize: .default | .lg.default
content() -> Content-

InputGroupAddon

Slot for text, icons or buttons beside or around the input.

ParameterTypeDefault
alignInputGroupAddonAlign: .inlineStart | .inlineEnd | .blockStart | .blockEnd.inlineStart
content() -> Content-

InputGroupButtonSize

Values: .xs, .sm, .iconXs, .iconSm, .icon.

InputGroupButton

Compact button inside an addon.

ParameterTypeDefault
variantVariantButtonStyle.Variant.ghost
sizeSize: .xs | .sm | .iconXs | .iconSm | .icon.xs
action() -> Void-
label() -> Label-
_ titleLocalizedStringKey-

Overloads: init(variant:size:action:label:), init(_:variant:size:action:).

InputGroupText

Text inside an addon.

ParameterTypeDefault
content() -> Content-
_ textLocalizedStringKey-
verbatimString-

Overloads: init(content:), init(_:), init(verbatim:).

InputGroupInput

Single-line input without its own border.

ParameterTypeDefault
_ titleLocalizedStringKey-
textBinding<String>-

InputGroupTextarea

Multi-line input without its own border.

ParameterTypeDefault
_ titleLocalizedStringKey-
textBinding<String>-
lineLimitClosedRange<Int>2...8

InputGroupAddonAlign

Values: InlineStart, InlineEnd, BlockStart, BlockEnd.

InputGroupSize

Values: Default, Lg.

InputGroupButtonSize

Values: Xs, Sm, IconXs, IconSm, Icon.

InputGroup

Field container that lays out the input and addons.

ParameterTypeDefault
modifierModifierModifier
sizeInputGroupSize: Default | LgInputGroupSize.Default
enabledBooleanLocalFieldState.current.enabled
invalidBooleanLocalFieldState.current.invalid
content@Composable () -> Unit-

InputGroupAddon

Slot for text, icons or buttons beside or around the input.

ParameterTypeDefault
modifierModifierModifier
alignInputGroupAddonAlign: InlineStart | InlineEnd | BlockStart | BlockEndInputGroupAddonAlign.InlineStart
content@Composable RowScope.() -> Unit-

InputGroupText

Text inside an addon.

ParameterTypeDefault
modifierModifierModifier
content@Composable RowScope.() -> Unit-
textString-

Overloads: InputGroupText(content), InputGroupText(text).

InputGroupButton

Compact button inside an addon.

ParameterTypeDefault
onClick() -> Unit-
modifierModifierModifier
sizeInputGroupButtonSize: Xs | Sm | IconXs | IconSm | IconInputGroupButtonSize.Xs
variantButtonVariantButtonVariant.Ghost
enabledBooleantrue
content@Composable RowScope.() -> Unit-
textString-

Overloads: InputGroupButton(onClick, content), InputGroupButton(text, onClick).

InputGroupInput

Single-line input without its own border.

ParameterTypeDefault
valueString-
onValueChange(String) -> Unit-
modifierModifierModifier
placeholderString?null
readOnlyBooleanfalse
keyboardOptionsKeyboardOptionsKeyboardOptions.Default
keyboardActionsKeyboardActionsKeyboardActions.Default
visualTransformationVisualTransformationVisualTransformation.None

InputGroupTextarea

Multi-line input without its own border.

ParameterTypeDefault
valueString-
onValueChange(String) -> Unit-
modifierModifierModifier
placeholderString?null
readOnlyBooleanfalse
minLinesInt3
maxLinesIntInt.MAX_VALUE
keyboardOptionsKeyboardOptionsKeyboardOptions.Default
keyboardActionsKeyboardActionsKeyboardActions.Default
NextInput OTPPreviousInput Accessory Bar

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • Search
    • With text
    • With buttons
    • Button sizes
    • Large
    • With kbd
    • Block addons
    • With textarea
    • Invalid
    • Disabled
  5. 05Accessibility
  6. 06API Reference
    • InputGroup
    • InputGroupAddon
    • InputGroupButton
    • InputGroupText
    • InputGroupInput
    • InputGroupTextarea
  7. 07Installation
  8. 08Usage
  9. 09Examples
    • With textarea
    • Button sizes
    • Large
    • Block start
  10. 10Accessibility
  11. 11API Reference
    • InputGroup
    • InputGroupAddon
    • InputGroupButton
    • InputGroupText
    • InputGroupInput
    • InputGroupTextarea
    • InputGroupAddonAlign
    • InputGroupSize
    • InputGroup
    • InputGroupAddon
    • InputGroupButtonSize
    • InputGroupButton
    • InputGroupText
    • InputGroupInput
    • InputGroupTextarea
    • InputGroupAddonAlign
    • InputGroupSize
    • InputGroupButtonSize
    • InputGroup
    • InputGroupAddon
    • InputGroupText
    • InputGroupButton
    • InputGroupInput
    • InputGroupTextarea