CSC Design System next
VueFlavour Vue React Angular TypeScript PrimaryCSC UI ColorsPrimarySecondaryAccentCustom ColorsRedOrangeGreenBluePurplePink
Guides Getting started Customization Data visualization Migration guide Componentsc-accordionc-alertc-autocompletec-badgec-buttonc-button-groupc-cardc-checkboxc-csc-logoc-data-tablec-dividerc-iconc-icon-buttonc-inputc-linkc-listc-loaderc-login-buttonsc-login-cardc-mainc-menuc-messagec-modalc-navigation-buttonc-otp-inputc-pagec-paginationc-popoverc-progress-barc-progress-circlec-radio-groupc-selectc-side-navigationc-sliderc-spinnerc-statusc-stepsc-switchc-tablec-tabsc-tagsc-text-fieldc-toastsc-toolbarc-tooltip

<c-text-field>

Examples

Basic
Vue React Angular TypeScript
<template>
  <div>
    <c-text-field
      v-model="name"
      hint="Shown on your public profile"
      label="Display name"
    />

    <p>Value: {{ name }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const name = ref('');
</script>
Small
Vue React Angular TypeScript
<template>
  <div style="display: flex; align-items: flex-start; gap: 16px">
    <c-text-field v-model="query" label="Search" size="small" />

    <c-button size="small">Search</c-button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const query = ref('');
</script>
Textarea
Vue React Angular TypeScript
<template>
  <div>
    <c-text-field
      v-model="description"
      hint="A rows value above 1 renders a textarea"
      label="Description"
      rows="4"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const description = ref('');
</script>

API reference

<c-text-field>

Properties

PropertyAttributeTypeDefaultDescription
autocompleteautocompletestring''HTML input autocomplete
autocorrectautocorrectbooleanEnable native input autocorrection (Safari). Maps to the input's `autocorrect="on"`/`"off"` attribute; left unset (browser default per input type) when not specified. Mirrors the platform `HTMLElement.autocorrect` boolean.
automaticCapitalizeautomatic-capitalizeCTextFieldAutocapitalizeHTML input autocapitalize
disableddisabledbooleanfalseDisable the input
errorMessageerror-messagestring''Error message shown in place of the hint while the input is invalid
hideDetailshide-detailsbooleanfalseHide the hint and error messages
hinthintstring''Hint text for the input
hostIdhost-idstring''Id of the input
labellabelstring''Label of the input
labelOnToplabel-on-topbooleanfalseLabel on top of the input
maxmaxnull | numbernullMaximum value on a numeric input
minminnull | numbernullMinimum value on a numeric input
namenamestring''Name of the input
placeholderplaceholderstring''Placeholder of the input
readonlyreadonlybooleanfalseMark as readonly
requiredrequiredbooleanfalseSet the input as required
rowsrowsnumber1Rows on the input
shadowshadowbooleanfalseShadow variant of the input
sizesizeCFieldSize'default'Field height: the 44px default or the 36px `small` box (single-line fields)
stepstepnull | numbernullStep size on a numeric input
trimWhitespacetrim-whitespacebooleanfalseTrim whitespace from the return value
typetypeCTextFieldType'text'Type of the input
validvalidbooleantrueSet the validity of the input
valuevaluestring''Value of the input

Events

EventDetailDescription
changevoidStandard bubbling DOM change event, re-dispatched from the host when the inner input/textarea fires its native change (which does not cross the shadow boundary). No detail; read the current text from the host's `value` property.
changeValuestringFired on every keystroke (and on native change), carrying the current text — trimmed when `trim-whitespace` is set. Also dispatched as `change-value` — bind that name in Vue templates.
inputvoidNative bubbling input event fired alongside every value change so a plain Vue `v-model` works without the `v-control` directive. No detail.
update:valuestringv-model contract event fired on every keystroke (and on native change), carrying the current text — trimmed when `trim-whitespace` is set.

Slots

SlotDescription
preContent added before the input
postContent added after the input

Types

Importable from the package root: import type { … } from '@cscfi/csc-ui'

CTextFieldAutocapitalize

Native `autocapitalize` behaviour of the input.

export type CTextFieldAutocapitalize =
  | 'characters'
  | 'none'
  | 'off'
  | 'on'
  | 'sentences'
  | 'words';
CTextFieldProps
export interface CTextFieldProps {
  /**
   * HTML input autocomplete
   *
   * @seeded from csc-ui — verify
   * @freeform any HTML autocomplete token list
   */
  autocomplete?: string;
  /**
   * Enable native input autocorrection (Safari). Maps to the input's
   * `autocorrect="on"`/`"off"` attribute; left unset (browser default per
   * input type) when not specified. Mirrors the platform
   * `HTMLElement.autocorrect` boolean.
   */
  autocorrect?: boolean;
  /**
   * HTML input autocapitalize
   *
   * @seeded from csc-ui — verify
   */
  automaticCapitalize?: CTextFieldAutocapitalize;
  /**
   * Disable the input
   *
   * @seeded from csc-ui — verify
   */
  disabled?: boolean;
  /**
   * Error message shown in place of the hint while the input is invalid
   *
   * @freeform
   */
  errorMessage?: string;
  /**
   * Hide the hint and error messages
   *
   * @seeded from csc-ui — verify
   */
  hideDetails?: boolean;
  /**
   * Hint text for the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  hint?: string;
  /**
   * Id of the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  hostId?: string;
  /**
   * Label of the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  label?: string;
  /**
   * Label on top of the input
   *
   * @seeded from csc-ui — verify
   */
  labelOnTop?: boolean;
  /**
   * Maximum value on a numeric input
   *
   * @seeded from csc-ui — verify
   */
  max?: null | number;
  /**
   * Minimum value on a numeric input
   *
   * @seeded from csc-ui — verify
   */
  min?: null | number;
  /**
   * Name of the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  name?: string;
  /**
   * Placeholder of the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  placeholder?: string;
  /**
   * Mark as readonly
   *
   * @seeded from csc-ui — verify
   */
  readonly?: boolean;
  /**
   * Set the input as required
   *
   * @seeded from csc-ui — verify
   */
  required?: boolean;
  /**
   * Rows on the input
   *
   * @seeded from csc-ui — verify
   */
  rows?: number;
  /**
   * Shadow variant of the input
   *
   * @seeded from csc-ui — verify
   */
  shadow?: boolean;
  /** Field height: the 44px default or the 36px `small` box (single-line fields) */
  size?: CFieldSize;
  /**
   * Step size on a numeric input
   *
   * @seeded from csc-ui — verify
   */
  step?: null | number;
  /**
   * Trim whitespace from the return value
   *
   * @seeded from csc-ui — verify
   */
  trimWhitespace?: boolean;
  /**
   * Type of the input
   *
   * @seeded from csc-ui — verify
   */
  type?: CTextFieldType;
  /**
   * Set the validity of the input
   *
   * @seeded from csc-ui — verify
   */
  valid?: boolean;
  /**
   * Value of the input
   *
   * @seeded from csc-ui — verify
   * @freeform
   */
  value?: string;
}
CTextFieldType

Type of the input. `password` gets a reveal toggle, `date` a picker button, `number` honours `min`/`max`/`step`; the rest map straight to the native input type.

export type CTextFieldType =
  | 'date'
  | 'email'
  | 'number'
  | 'password'
  | 'search'
  | 'tel'
  | 'text'
  | 'url';
CFieldSize shared

Field height of the form controls built on `c-input`. `default` is the 44px field; `small` is the 36px field. Owned here because the value passes from the wrapping control (`c-select`) into `c-input`.

export type CFieldSize = 'default' | 'small';