1414 * same 1.5 gap as `Chip`. It shares the chip-field chrome with
1515 * {@link ChipTextarea}, shows no focus ring — keep the surface calm and rely on
1616 * the caret for focus. Pass `error` to swap the border to the error token.
17+ * `appearance='compactSearch'` owns the existing 23px code-search field
18+ * treatment without changing the 30px chip default.
1719 *
1820 * @example
1921 * ```tsx
2729 * ```
2830 */
2931import * as React from 'react'
32+ import { cva , type VariantProps } from 'class-variance-authority'
3033import { cn } from '../../lib/cn'
3134import { chipFieldSurfaceClass , chipFieldTextClass , chipGeometryClass } from '../chip/chip-chrome'
3235
3336type ChipInputIcon = React . ComponentType < { className ?: string } >
3437
35- export interface ChipInputProps extends Omit < React . InputHTMLAttributes < HTMLInputElement > , 'size' > {
38+ /** The compact search field keeps the existing code-viewer input geometry. */
39+ export const chipInputVariants = cva ( '' , {
40+ variants : {
41+ appearance : {
42+ chip : '' ,
43+ compactSearch :
44+ 'h-[23px] items-center rounded-sm border border-[var(--border-1)] bg-[var(--surface-5)] px-2 transition-colors' ,
45+ } ,
46+ } ,
47+ defaultVariants : { appearance : 'chip' } ,
48+ } )
49+
50+ export interface ChipInputProps
51+ extends Omit < React . InputHTMLAttributes < HTMLInputElement > , 'size' > ,
52+ VariantProps < typeof chipInputVariants > {
53+ /** The default chip field or the compact code-search field. */
54+ appearance ?: VariantProps < typeof chipInputVariants > [ 'appearance' ]
3655 /** Leading icon component (e.g. `Search` from `@sim/emcn/icons`). Rendered at 14px in `--text-icon`, with the chip's 1.5 gap. */
3756 icon ?: ChipInputIcon
3857 /** Custom leading content, such as a color swatch. Takes precedence over `icon`. */
@@ -54,6 +73,7 @@ export interface ChipInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
5473export const ChipInput = React . forwardRef < HTMLInputElement , ChipInputProps > (
5574 (
5675 {
76+ appearance = 'chip' ,
5777 className,
5878 inputClassName,
5979 icon : Icon ,
@@ -69,8 +89,9 @@ export const ChipInput = React.forwardRef<HTMLInputElement, ChipInputProps>(
6989 < div
7090 className = { cn (
7191 'flex w-full' ,
72- chipGeometryClass ,
73- chipFieldSurfaceClass ,
92+ appearance === 'chip' && chipGeometryClass ,
93+ appearance === 'chip' && chipFieldSurfaceClass ,
94+ chipInputVariants ( { appearance } ) ,
7495 error && 'border-[var(--text-error)]' ,
7596 disabled && 'opacity-50' ,
7697 className
@@ -83,8 +104,12 @@ export const ChipInput = React.forwardRef<HTMLInputElement, ChipInputProps>(
83104 type = { type }
84105 disabled = { disabled }
85106 className = { cn (
86- '-ml-1 h-full w-full bg-transparent indent-1 disabled:cursor-not-allowed' ,
87- chipFieldTextClass ,
107+ appearance === 'compactSearch'
108+ ? 'h-full w-full touch-manipulation scroll-pr-1 bg-transparent font-sans text-[var(--text-primary)] text-caption outline-hidden [letter-spacing:inherit] placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed'
109+ : cn (
110+ '-ml-1 h-full w-full bg-transparent indent-1 disabled:cursor-not-allowed' ,
111+ chipFieldTextClass
112+ ) ,
88113 inputClassName
89114 ) }
90115 { ...props }
0 commit comments