Kosmesis
Components

Input

A single-line text input, wrapping Morphos's Input primitive.

Installation

npx kosmesis add input
pnpm dlx kosmesis add input
yarn dlx kosmesis add input
bunx kosmesis add input

Install the following dependencies:

npm install @morphos/inputs
pnpm add @morphos/inputs
yarn add @morphos/inputs
bun add @morphos/inputs

Copy and paste the following code into your project.

input.tsx
import { StatelessComponent } from "@praxisjs/core";import { Component } from "@praxisjs/decorators";import { Input as MorphosInput, type InputProps as MorphosInputProps  } from "@morphos/inputs";import { cn } from "@/lib/utils";export type InputProps = MorphosInputProps;@Component()export class Input extends StatelessComponent<InputProps> {  render() {    const { class: cls, ...rest } = this.props;    return (      <MorphosInput        class={cn(          "flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 data-focused:border-ring data-focused:ring-[3px] data-focused:ring-ring/50 data-invalid:border-destructive data-invalid:ring-destructive/20 md:text-sm",          cls,        )}        {...rest}      />    );  }}

Install the following dependencies:

npm install @morphos/inputs @praxisjs/css
pnpm add @morphos/inputs @praxisjs/css
yarn add @morphos/inputs @praxisjs/css
bun add @morphos/inputs @praxisjs/css

Copy and paste the following code into your project.

input.tsx
import { StatelessComponent } from "@praxisjs/core";import { cx, Stylesheet, Styled, tokenVars } from "@praxisjs/css";import { Component } from "@praxisjs/decorators";import { Input as MorphosInput, type InputProps as MorphosInputProps  } from "@morphos/inputs";import { KosmesisTokens } from "@/lib/kosmesis-theme";const t = tokenVars(KosmesisTokens);class InputStyles extends Stylesheet {  $root = this.css({    display: "flex",    height: "2.25rem",    width: "100%",    minWidth: "0",    borderRadius: `calc(${t.radius} - 2px)`,    border: `1px solid ${t.input}`,    backgroundColor: "transparent",    padding: "0.25rem 0.75rem",    fontSize: "0.875rem",    boxShadow: "0 1px 2px 0 rgb(0 0 0 / 0.05)",    outline: "none",    transition: "color 120ms ease, box-shadow 120ms ease",  })    .on("&::file-selector-button", { display: "inline-flex", height: "1.75rem", border: "0", backgroundColor: "transparent", fontSize: "0.875rem", fontWeight: 500 })    .placeholder({ color: t.mutedForeground })    .disabled({ pointerEvents: "none", cursor: "not-allowed", opacity: 0.5 })    .on("&[data-disabled]", { pointerEvents: "none", cursor: "not-allowed", opacity: 0.5 })    .on("&[data-focused]", { borderColor: t.ring, boxShadow: `0 0 0 3px color-mix(in oklab, ${t.ring} 50%, transparent)` })    .on("&[data-invalid]", { borderColor: t.destructive, boxShadow: `0 0 0 3px color-mix(in oklab, ${t.destructive} 20%, transparent)` });}export type InputProps = MorphosInputProps;@Component()export class Input extends StatelessComponent<InputProps> {  @Styled(InputStyles) $s!: InputStyles;  render() {    const { class: cls, ...rest } = this.props;    return <MorphosInput class={cx(this.$s.$root, cls)} {...rest} />;  }}

Examples

Usage

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

<Input type="email" placeholder="you@example.com" />
<Input disabled placeholder="Disabled" />
<Input invalid placeholder="Invalid" />

Props

Passes through to Morphos's Inputtype, value, defaultValue, placeholder, disabled, readonly, required, invalid, name, autoComplete, maxLength, minLength, onInput, onChange, onFocus, onBlur. See Morphos's Input docs for the full list.

On this page