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

A single-line text field for entering and editing short values.

Input 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 { Input } from "@/components/ui/input"

export default function InputDemo() {
  return <Input type="text" placeholder="Enter your name" className="w-80" />
}

Input renders a native input element with a bordered control style. It supports every native input type, including email, password, number, search and file, and adds a size prop for four heights.

Use it for short, free-form values. For multi-line text use a textarea, for icons, buttons or text attached to the field use InputGroup, and for one-time codes use InputOTP.

Installation

$ pnpm dlx shadcn@latest add @esuiss/input

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
  1. Install the following dependencies and add the cn helper:
$ pnpm add @base-ui/react
  1. Copy and paste the following code into your project.
components/ui/input.tsx
import { Input as InputPrimitive } from "@base-ui/react/input"
import type * as React from "react"
import { cn } from "@/lib/utils"

function Input({
  className,
  type,
  size = "default",
  ...props
}: Omit<React.ComponentProps<"input">, "size"> & {
  size?: "sm" | "md" | "default" | "lg"
}) {
  return (
    <InputPrimitive
      type={type}
      data-slot="input"
  1. Update the import paths to match your project setup.

Usage

import { Input } from "@/components/ui/input"
<div className="w-80">
  <Input type="text" placeholder="Enter your name" />
</div>

Examples

Sizes

Use the size prop to set the height. Choose a size that matches neighboring controls such as a Button, as shown here.

import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"

export default function InputSizes() {
  return (
    <div className="flex w-80 flex-col gap-3">
      <div className="flex items-center gap-2">
        <Input type="text" size="sm" placeholder="Small" />
        <Button size="sm">Save</Button>
      </div>
      <div className="flex items-center gap-2">
        <Input type="text" size="md" placeholder="Medium" />
        <Button>Save</Button>
      </div>
      <div className="flex items-center gap-2">
        <Input type="text" size="default" placeholder="Default" />

Types

Set the native type attribute for email, password, number and search fields.

import { Input } from "@/components/ui/input"

export default function InputTypes() {
  return (
    <div className="flex w-80 flex-col gap-3">
      <Input type="email" placeholder="jane@example.com" />
      <Input type="password" placeholder="Password" />
      <Input type="number" placeholder="Quantity" />
      <Input type="search" placeholder="Search..." />
    </div>
  )
}

With value

Set defaultValue for an uncontrolled field that starts with a value, or use value with onChange to control it.

import { Input } from "@/components/ui/input"

export default function InputWithValue() {
  return (
    <Input
      type="text"
      placeholder="Enter your name"
      defaultValue="Jane Doe"
      className="w-80"
    />
  )
}

File

Set type="file" for a file picker. Give it an accessible name, as with any input.

import { Input } from "@/components/ui/input"

export default function InputFile() {
  return (
    <Input
      type="file"
      placeholder={undefined}
      aria-label="Menu"
      className="w-80"
    />
  )
}

Invalid

Set aria-invalid to show the error style.

import { Input } from "@/components/ui/input"

export default function InputInvalid() {
  return (
    <Input
      type="email"
      placeholder="Enter your name"
      defaultValue="jane@"
      aria-invalid
      className="w-80"
    />
  )
}

Disabled

Set disabled to stop the input from being focused or edited.

import { Input } from "@/components/ui/input"

export default function InputDisabled() {
  return (
    <Input
      type="text"
      placeholder="Enter your name"
      disabled
      className="w-80"
    />
  )
}

Accessibility

  • Renders a native input, so the role follows its type: textbox by default, spinbutton for number and searchbox for search.
  • Needs an accessible name from an associated label or aria-label.
  • Set aria-invalid to communicate a validation error.
  • A disabled input cannot be focused or edited.

API Reference

Input

The text field.

PropTypeDefault
size"sm" | "md" | "default" | "lg""default"

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

size sets the height and text size: lg is 54px with 17px text for forms such as sign-in pages, default is 44px, md is medium and sm is the most compact with a smaller radius. It replaces the native size attribute. Give every input a visible label, for example with FieldLabel inside a Field, or set aria-label when a visible label is not possible. The input sets data-slot="input" and data-size for styling.

Web

Web preview

import { Input } from "@/components/ui/input"

export default function InputDemo() {
  return <Input placeholder="Email" />
}
import SwiftUI

struct InputExample: View {
  var body: some View {
    InputDemo(placeholder: "Email")
  }
}

struct InputDemo: View {
  let placeholder: LocalizedStringKey
  var size: InputStyle.Size = .default

  @State private var text: String

  init(placeholder: LocalizedStringKey, size: InputStyle.Size = .default, initial: String = "") {
    self.placeholder = placeholder
import androidx.compose.foundation.layout.fillMaxWidth
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 com.esuiss.ui.components.Input

@Composable
fun InputExample() {
    InputSingle(initial = "", placeholder = "Email")
}

@Composable
fun InputSingle(initial: String, placeholder: String, enabled: Boolean = true) {

Input wraps a TextInput through the field control primitive. It tracks its own focused, filled, invalid and disabled state and styles itself from that state: a focus border while editing, a destructive border and tint when invalid, and 50% opacity when disabled.

It comes in three sizes: default (44 pt), md and sm. Use the default size for forms on a full screen, and the smaller sizes inside dense layouts such as toolbars or sheets.

Installation

$ pnpm dlx shadcn@latest add @esuiss/input

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

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

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

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

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

$ pnpm dlx @esuiss/ui@latest add input --platform kotlin
  1. Install the following dependencies:
npx expo install cn
  1. 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/input.tsx
import {
  Control,
  type ControlChangeEventDetails,
  type ControlChangeEventReason,
  type ControlProps,
  type ControlState,
} from "./field"

type RootProps = ControlProps

type RootState = ControlState

type ChangeEventReason = ControlChangeEventReason

type ChangeEventDetails = ControlChangeEventDetails
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.tsx:
uniwind/components/ui/input.tsx
import { cn } from "cn"
import { useInsetContext } from "@/components/primitives/field"
import * as InputPrimitive from "@/components/primitives/input"
import { resolveClassName } from "@/components/primitives/use-render"

type InputSize = "sm" | "md" | "default" | "lg"

function Input({
  className,
  size = "default",
  ...props
}: React.ComponentProps<typeof InputPrimitive.Root> & {
  size?: InputSize
}) {
  const inset = useInsetContext()
  return (
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn nativewind
  1. 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/input.tsx
import {
  Control,
  type ControlChangeEventDetails,
  type ControlChangeEventReason,
  type ControlProps,
  type ControlState,
} from "./field"

type RootProps = ControlProps

type RootState = ControlState

type ChangeEventReason = ControlChangeEventReason

type ChangeEventDetails = ControlChangeEventDetails
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.tsx:
nativewind/components/ui/input.tsx
import { cn } from "cn"
import { cssInterop } from "nativewind"
import { TextInput } from "react-native"
import { useInsetContext } from "@/components/primitives/field"
import * as InputPrimitive from "@/components/primitives/input"
import { resolveClassName } from "@/components/primitives/use-render"

declare module "react-native" {
  interface TextInputProps {
    cursorColorClassName?: string
    selectionColorClassName?: string
  }
}

cssInterop(TextInput, {
  className: { target: "style", nativeStyleToProp: { textAlign: true } },
  1. Update the import paths to match your project setup.
  1. 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/input.tsx
import {
  Control,
  type ControlChangeEventDetails,
  type ControlChangeEventReason,
  type ControlProps,
  type ControlState,
} from "./field"

type RootProps = ControlProps

type RootState = ControlState

type ChangeEventReason = ControlChangeEventReason

type ChangeEventDetails = ControlChangeEventDetails
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.tsx:
stylesheet/components/ui/input.tsx
import { StyleSheet } from "react-native"
import { useInsetContext } from "@/components/primitives/field"
import * as InputPrimitive from "@/components/primitives/input"
import { fontSize, metrics, radius, useTheme } from "@/components/ui/theme"

type InputSize = "sm" | "md" | "default" | "lg"

function withAlpha(color: string, alpha: number) {
  if (!color.startsWith("#") || color.length !== 7) return color
  const r = Number.parseInt(color.slice(1, 3), 16)
  const g = Number.parseInt(color.slice(3, 5), 16)
  const b = Number.parseInt(color.slice(5, 7), 16)
  return `rgba(${r}, ${g}, ${b}, ${alpha})`
}

const styles = StyleSheet.create({
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. 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/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/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/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/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")
}
  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/Input.kt
package com.esuiss.ui.components

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
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
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
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/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 { Input } from "@/components/ui/input"
<Input placeholder="Email" />
import SwiftUI

struct InputExample: View {
  var body: some View {
    InputDemo(placeholder: "Email")
  }
}

struct InputDemo: View {
  let placeholder: LocalizedStringKey
  var size: InputStyle.Size = .default

  @State private var text: String

  init(placeholder: LocalizedStringKey, size: InputStyle.Size = .default, initial: String = "") {
    self.placeholder = placeholder
    self.size = size
    _text = State(initialValue: initial)
  }

  var body: some View {
    TextField(placeholder, text: $text)
      .textFieldStyle(.input(size: size))
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
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 com.esuiss.ui.components.Input

@Composable
fun InputExample() {
    InputSingle(initial = "", placeholder = "Email")
}

@Composable
fun InputSingle(initial: String, placeholder: String, enabled: Boolean = true) {
    var value by rememberSaveable { mutableStateOf(initial) }
    Input(value, { value = it }, Modifier.fillMaxWidth(), enabled = enabled, placeholder = placeholder)
}

Examples

Types

Pass a TextInput prop such as secureTextEntry, keyboardType or inputMode to get the matching field type.

Web

Web preview

import { View } from "react-native"
import { Input } from "@/components/ui/input"

export default function InputTypes() {
  return (
    <View className="gap-3">
      <Input placeholder="Text" />
      <Input
        placeholder="Email"
        keyboardType="email-address"
        autoCapitalize="none"
      />
      <Input placeholder="Password" secureTextEntry />
      <Input placeholder="Number" keyboardType="number-pad" />
      <Input placeholder="Search" inputMode="search" />
    </View>
import { View } from "react-native"
import { Input } from "@/components/ui/input"

export default function InputTypes() {
  return (
    <View style={{ gap: 12 }}>
      <Input placeholder="Text" />
      <Input
        placeholder="Email"
        keyboardType="email-address"
        autoCapitalize="none"
      />
      <Input placeholder="Password" secureTextEntry />
      <Input placeholder="Number" keyboardType="number-pad" />
      <Input placeholder="Search" inputMode="search" />
    </View>
import SwiftUI

struct InputTypesDemo: View {
  @State private var text = ""
  @State private var email = ""
  @State private var password = ""
  @State private var number = ""
  @State private var search = ""

  var body: some View {
    VStack(alignment: .leading, spacing: 12) {
      TextField("Text", text: $text)
        .textFieldStyle(.input)
      TextField("Email", text: $email)
        .textFieldStyle(.input)
        .keyboardType(.emailAddress)
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
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.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Input

Sizes

The sm, md, default and lg sizes, each next to a matching button. lg is 54 tall with 17 point text, for forms such as sign-in screens.

Web

Web preview

import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Text } from "@/components/ui/text"

export default function InputSizes() {
  return (
    <View className="gap-3">
      <Input size="sm" placeholder="Small" />
      <Input size="md" placeholder="Medium" />
      <Input placeholder="Default" />
      <View className="flex-row items-center gap-2">
        <Input size="lg" placeholder="Large" className="flex-1" />
        <Button size="form">
          <Text>Save</Text>
        </Button>
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Text } from "@/components/ui/text"

export default function InputSizes() {
  return (
    <View style={{ gap: 12 }}>
      <Input size="sm" placeholder="Small" />
      <Input size="md" placeholder="Medium" />
      <Input placeholder="Default" />
      <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
        <Input size="lg" placeholder="Large" style={{ flex: 1 }} />
        <Button size="form">
          <Text>Save</Text>
        </Button>
import SwiftUI

struct InputSizesExample: View {
  var body: some View {
    VStack(alignment: .leading, spacing: 12) {
      InputDemo(placeholder: "Small", size: .sm)
      InputDemo(placeholder: "Medium", size: .md)
      InputDemo(placeholder: "Default")
      HStack(spacing: 8) {
        InputDemo(placeholder: "Large", size: .lg)
        Button("Save") {}
          .buttonStyle(.variant(size: .form))
      }
    }
  }
}
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.Input
import com.esuiss.ui.components.InputSize

With value

An input that starts with a defaultValue.

An input that starts with a value.

Web

Web preview

import { Input } from "@/components/ui/input"

export default function InputWithValue() {
  return <Input placeholder="Email" defaultValue="hello@example.com" />
}
import SwiftUI

struct InputWithValueExample: View {
  var body: some View {
    InputDemo(placeholder: "Email", initial: "hello@example.com")
  }
}

struct InputDemo: View {
  let placeholder: LocalizedStringKey
  var size: InputStyle.Size = .default

  @State private var text: String

  init(placeholder: LocalizedStringKey, size: InputStyle.Size = .default, initial: String = "") {
    self.placeholder = placeholder
import androidx.compose.foundation.layout.fillMaxWidth
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 com.esuiss.ui.components.Input

@Composable
fun InputWithValueExample() {
    InputSingle(initial = "hello@example.com", placeholder = "Email")
}

@Composable
fun InputSingle(initial: String, placeholder: String, enabled: Boolean = true) {

With label

An input inside a Field with a label and description.

React Native
Input with label in React Native, light modeInput with label in React Native, dark mode
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

export default function InputWithLabel() {
  return (
    <Field>
      <FieldLabel>Email</FieldLabel>
      <Input
        placeholder="m@example.com"
        keyboardType="email-address"
        autoCapitalize="none"
      />
      <FieldDescription>We will never share your email.</FieldDescription>
    </Field>
  )
}
import SwiftUI

struct InputWithLabelDemo: View {
  @State private var email = ""

  var body: some View {
    Field {
      FieldLabel("Email")
        .accessibilityHidden(true)
      TextField(text: $email, prompt: Text(verbatim: "m@example.com")) {
        Text("Email")
      }
        .textFieldStyle(.input)
        .keyboardType(.emailAddress)
        .textInputAutocapitalization(.never)
        .accessibilityLabel(Text("Email"))
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.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import com.esuiss.ui.components.Field
import com.esuiss.ui.components.FieldDescription
import com.esuiss.ui.components.FieldLabel
import com.esuiss.ui.components.Input

val InputEmailKeyboard = KeyboardOptions(
    capitalization = KeyboardCapitalization.None,
    keyboardType = KeyboardType.Email,

Invalid

An input inside an invalid Field with an error message. Inside a Field, set invalid on the field instead of on the input.

Web

Web preview

import { Field, FieldError, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

export default function InputInvalid() {
  return (
    <Field invalid>
      <FieldLabel>Username</FieldLabel>
      <Input defaultValue="x" />
      <FieldError>Username must be at least 3 characters.</FieldError>
    </Field>
  )
}
import SwiftUI

struct InputInvalidDemo: View {
  @State private var username = "x"

  var body: some View {
    Field(invalid: true) {
      FieldLabel("Username")
        .accessibilityHidden(true)
      TextField("", text: $username)
        .textFieldStyle(.input)
        .accessibilityLabel(Text("Username"))
      FieldError("Username must be at least 3 characters.")
    }
  }
}
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 com.esuiss.ui.components.Field
import com.esuiss.ui.components.FieldError
import com.esuiss.ui.components.FieldLabel
import com.esuiss.ui.components.Input

@Composable
fun InputInvalid() {
    var value by rememberSaveable { mutableStateOf("x") }
    Field(invalid = true) {
        FieldLabel("Username")
        Input(value, { value = it })

Controlled

A controlled input that mirrors its value below.

React Native
Input controlled in React Native, light modeInput controlled in React Native, dark mode
import * as React from "react"
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { Text } from "@/components/ui/text"

export default function InputControlled() {
  const [value, setValue] = React.useState("")
  return (
    <View className="gap-2">
      <Input
        placeholder="Lowercase only"
        autoCapitalize="none"
        value={value}
        onValueChange={(next) => setValue(next.toLowerCase())}
      />
      <Text variant="muted">Value: {value}</Text>
import * as React from "react"
import { View } from "react-native"
import { Input } from "@/components/ui/input"
import { Text } from "@/components/ui/text"

export default function InputControlled() {
  const [value, setValue] = React.useState("")
  return (
    <View style={{ gap: 8 }}>
      <Input
        placeholder="Lowercase only"
        autoCapitalize="none"
        value={value}
        onValueChange={(next) => setValue(next.toLowerCase())}
      />
      <Text variant="muted">Value: {value}</Text>
import SwiftUI

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

  var body: some View {
    VStack(alignment: .leading, spacing: 8) {
      TextField(
        "Lowercase only",
        text: Binding(get: { value }, set: { value = $0.lowercased() })
      )
      .textFieldStyle(.input)
      .textInputAutocapitalization(.never)
      Text(verbatim: "Value: \(value)")
        .textVariant(.muted)
    }
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
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.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Input
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariant

Disabled

A disabled input.

Web

Web preview

import { Input } from "@/components/ui/input"

export default function InputDisabled() {
  return <Input placeholder="Disabled" />
}
import SwiftUI

struct InputDisabledExample: View {
  var body: some View {
    InputDemo(placeholder: "Disabled")
      .disabled(true)
  }
}

struct InputDemo: View {
  let placeholder: LocalizedStringKey
  var size: InputStyle.Size = .default

  @State private var text: String

  init(placeholder: LocalizedStringKey, size: InputStyle.Size = .default, initial: String = "") {
import androidx.compose.foundation.layout.fillMaxWidth
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 com.esuiss.ui.components.Input

@Composable
fun InputDisabledExample() {
    InputSingle(initial = "", placeholder = "Disabled", enabled = false)
}

@Composable
fun InputSingle(initial: String, placeholder: String, enabled: Boolean = true) {

Accessibility

  • Inside a Field, the input is linked to the field label through accessibilityLabelledBy and gets the label as accessibilityLabel and the description as accessibilityHint.
  • disabled is set in accessibilityState and makes the input non-editable.
  • Outside a Field, give the input an accessibilityLabel; a placeholder alone is not a label.

API Reference

Input

The text field.

PropTypeDefault
sizeInputSize"default"

Also accepts the props of React.ComponentProps<typeof InputPrimitive.Root>.

size sets the height and text size. The value works controlled with value and onValueChange(value, details), or uncontrolled with defaultValue. Inside a Field, the input picks up the field's label, description, invalid and disabled state. className can be a function that receives the state (focused, invalid, disabled, filled, …) and returns classes. Fields have a border outline; focus turns it to ring with a solid ring, and an invalid field gets a thicker destructive border with a tint.

.textFieldStyle(.input)

Style that creates InputStyle.

ParameterTypeDefault
sizeInputStyle.Size: .default | .md | .sm | .lg.default

InputSize

Values: Default, Md, Sm, Lg.

Input

The text field.

ParameterTypeDefault
valueString-
onValueChange(String) -> Unit-
modifierModifierModifier
sizeInputSize: Default | Md | Sm | LgInputSize.Default
enabledBooleanLocalFieldState.current.enabled
readOnlyBooleanfalse
invalidBooleanLocalFieldState.current.invalid
placeholderString?null
keyboardOptionsKeyboardOptionsKeyboardOptions.Default
keyboardActionsKeyboardActionsKeyboardActions.Default
visualTransformationVisualTransformationVisualTransformation.None
interactionSourceMutableInteractionSource?null
NextInput Accessory BarPreviousIcon

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • Sizes
    • Types
    • With value
    • File
    • Invalid
    • Disabled
  4. 04Accessibility
  5. 05API Reference
    • Input
  6. 06Installation
  7. 07Usage
  8. 08Examples
    • Types
    • Sizes
    • With value
    • With label
    • Invalid
    • Controlled
    • Disabled
  9. 09Accessibility
  10. 10API Reference
    • Input
    • .textFieldStyle(.input)
    • InputSize
    • Input