Text Field

Single-line input with icon slots, clear button, helper and error text, and a character counter.

c2-text-field

Attributes

NameTypeDefaultDescription
readonlybooleanfalseShows the value but refuses edits. Rendered on a light grey background.
disabledbooleanfalseDisables the input and dims the field.
errorbooleanfalseMarks the field invalid: red border and, when set, `error-text` replaces the helper text.
maxlengthnumber-1Maximum number of characters. Forwarded to the input and shown as a `n / max` counter under the field.
minlengthnumber-1Minimum number of characters, forwarded to the input.
patternstringRegular expression the value must match, forwarded to the input.
requiredbooleanfalseMarks the input required (native validation). Pair with a `required` `c2-label` to show the indicator.
typeTextFieldTypetextInput type: `text`, `email`, `password`, `search`, `tel`, `url` or `number`.
namestringForm field name forwarded to the input.
autocompletestring`autocomplete` hint forwarded to the input, e.g. `email` or `current-password`.
placeholderstringText shown while the field is empty.
aria-labelstring | nullnullAccessible name forwarded to the native input.
valuestringThe current text. Setting the attribute after the user has typed no longer updates it, like a native input.
error-textstringMessage shown under the field while `error` is set.
helpstringHelper text shown under the field.
clearablebooleanfalseShows a clear button at the end of the field while it has a value.

Events

NameTypeDescription
inputInputEventRe-dispatched from the inner input on every keystroke; `value` is already updated.
changeEventRe-dispatched from the inner input when the value is committed (blur or Enter).
clearEventFired after the clear button emptied the field (an `input` and a `change` event follow).

CSS custom properties

Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.

NameTypeDefaultDescription
--c2-text-field--min-heightpixel36px
--c2-text-field--gappixel8pxSpace between the icons and the text.
--c2-text-field--border-top-left-radiusborder-radius6px
--c2-text-field--border-top-right-radiusborder-radius6px
--c2-text-field--border-bottom-left-radiusborder-radius6px
--c2-text-field--border-bottom-right-radiusborder-radius6px
--c2-text-field--padding-toppadding6px
--c2-text-field--padding-rightpadding10px
--c2-text-field--padding-bottompadding6px
--c2-text-field--padding-leftpadding12px
--c2-text-field--border-topborder1px solid #bcbcc6
--c2-text-field--border-rightborder1px solid #bcbcc6
--c2-text-field--border-bottomborder1px solid #bcbcc6
--c2-text-field--border-leftborder1px solid #bcbcc6
--c2-text-field--colorcolor#18181b
--c2-text-field--backgroundcolor#ffffff
--c2-text-field--font-sizefont-size14px
--c2-text-field--font-weightfont-weight
--c2-text-field--font-stylefont-style
--c2-text-field--font-familyfont-family
--c2-text-field--line-heightpixel20px
--c2-text-field__placeholder--colorcolor#71717a
--c2-text-field__placeholder--opacityopacity1
--c2-text-field__placeholder--font-weightfont-weight
--c2-text-field__placeholder--font-stylefont-style
--c2-text-field__hover--border-topborder1px solid #a1a1aa
--c2-text-field__hover--border-rightborder1px solid #a1a1aa
--c2-text-field__hover--border-bottomborder1px solid #a1a1aa
--c2-text-field__hover--border-leftborder1px solid #a1a1aa
--c2-text-field__focus--border-topborder1px solid #476ef9
--c2-text-field__focus--border-rightborder1px solid #476ef9
--c2-text-field__focus--border-bottomborder1px solid #476ef9
--c2-text-field__focus--border-leftborder1px solid #476ef9
--c2-text-field__focus--colorcolor
--c2-text-field__focus--backgroundcolor
--c2-text-field__focus--outlineoutline3px solid rgba(71, 110, 249, 0.2)
--c2-text-field__focus--outline-offsetpixel0px
--c2-text-field__error--border-topborder1px solid #dc2626
--c2-text-field__error--border-rightborder1px solid #dc2626
--c2-text-field__error--border-bottomborder1px solid #dc2626
--c2-text-field__error--border-leftborder1px solid #dc2626
--c2-text-field__error--colorcolor
--c2-text-field__error--backgroundcolor
--c2-text-field__error__focus--outlineoutline3px solid rgba(220, 38, 38, 0.2)
--c2-text-field__read-only--border-topborder1px solid #e4e4e7
--c2-text-field__read-only--border-rightborder1px solid #e4e4e7
--c2-text-field__read-only--border-bottomborder1px solid #e4e4e7
--c2-text-field__read-only--border-leftborder1px solid #e4e4e7
--c2-text-field__read-only--colorcolor
--c2-text-field__read-only--backgroundcolor#fafafa
--c2-text-field__disabled--opacityopacity0.38
--c2-text-field__icon--sizepixel16px
--c2-text-field__icon--colorcolor#71717a
--c2-text-field__clear-icon--sizepixel16px
--c2-text-field__clear-icon--colorcolor#a1a1aa
--c2-text-field__clear-icon__hover--colorcolor#18181b
--c2-text-field__help-icon--sizepixel16px
--c2-text-field__help-icon--colorcolor#71717a
--c2-text-field__help-icon--gappixel8pxSpace between the field and the help icon.
--c2-text-field__supporting-text--gappixel4pxSpace between the field and the helper line.
--c2-text-field__supporting-text--font-sizefont-size12px
--c2-text-field__supporting-text--line-heightpixel16px
--c2-text-field__supporting-text--colorcolor#71717a
--c2-text-field__supporting-text__error--colorcolor#dc2626

c2-text-field-clear

Attributes

NameTypeDefaultDescription
readonlybooleanfalseShows the value but refuses edits. Rendered on a light grey background.
disabledbooleanfalseDisables the input and dims the field.
errorbooleanfalseMarks the field invalid: red border and, when set, `error-text` replaces the helper text.
maxlengthnumber-1Maximum number of characters. Forwarded to the input and shown as a `n / max` counter under the field.
minlengthnumber-1Minimum number of characters, forwarded to the input.
patternstringRegular expression the value must match, forwarded to the input.
requiredbooleanfalseMarks the input required (native validation). Pair with a `required` `c2-label` to show the indicator.
typeTextFieldTypetextInput type: `text`, `email`, `password`, `search`, `tel`, `url` or `number`.
namestringForm field name forwarded to the input.
autocompletestring`autocomplete` hint forwarded to the input, e.g. `email` or `current-password`.
placeholderstringText shown while the field is empty.
aria-labelstring | nullnullAccessible name forwarded to the native input.
valuestringThe current text. Setting the attribute after the user has typed no longer updates it, like a native input.
error-textstringMessage shown under the field while `error` is set.
helpstringHelper text shown under the field.
clearablebooleanfalseShows a clear button at the end of the field while it has a value.

Events

NameTypeDescription
inputInputEventRe-dispatched from the inner input on every keystroke; `value` is already updated.
changeEventRe-dispatched from the inner input when the value is committed (blur or Enter).
clearEventFired after the clear button emptied the field (an `input` and a `change` event follow).

CSS custom properties

Grouped by the element and state they target. Click a group to collapse it; click a name to copy it.

NameTypeDefaultDescription
--c2-text-field-clear__clear-icon--sizepixel24px
--c2-text-field-clear__clear-icon--colorcolorrgb(70, 70, 70)
--c2-text-field--min-heightpixel36px
--c2-text-field--gappixel8pxSpace between the icons and the text.
--c2-text-field--border-top-left-radiusborder-radius6px
--c2-text-field--border-top-right-radiusborder-radius6px
--c2-text-field--border-bottom-left-radiusborder-radius6px
--c2-text-field--border-bottom-right-radiusborder-radius6px
--c2-text-field--padding-toppadding6px
--c2-text-field--padding-rightpadding10px
--c2-text-field--padding-bottompadding6px
--c2-text-field--padding-leftpadding12px
--c2-text-field--border-topborder1px solid #bcbcc6
--c2-text-field--border-rightborder1px solid #bcbcc6
--c2-text-field--border-bottomborder1px solid #bcbcc6
--c2-text-field--border-leftborder1px solid #bcbcc6
--c2-text-field--colorcolor#18181b
--c2-text-field--backgroundcolor#ffffff
--c2-text-field--font-sizefont-size14px
--c2-text-field--font-weightfont-weight
--c2-text-field--font-stylefont-style
--c2-text-field--font-familyfont-family
--c2-text-field--line-heightpixel20px
--c2-text-field__placeholder--colorcolor#71717a
--c2-text-field__placeholder--opacityopacity1
--c2-text-field__placeholder--font-weightfont-weight
--c2-text-field__placeholder--font-stylefont-style
--c2-text-field__hover--border-topborder1px solid #a1a1aa
--c2-text-field__hover--border-rightborder1px solid #a1a1aa
--c2-text-field__hover--border-bottomborder1px solid #a1a1aa
--c2-text-field__hover--border-leftborder1px solid #a1a1aa
--c2-text-field__focus--border-topborder1px solid #476ef9
--c2-text-field__focus--border-rightborder1px solid #476ef9
--c2-text-field__focus--border-bottomborder1px solid #476ef9
--c2-text-field__focus--border-leftborder1px solid #476ef9
--c2-text-field__focus--colorcolor
--c2-text-field__focus--backgroundcolor
--c2-text-field__focus--outlineoutline3px solid rgba(71, 110, 249, 0.2)
--c2-text-field__focus--outline-offsetpixel0px
--c2-text-field__error--border-topborder1px solid #dc2626
--c2-text-field__error--border-rightborder1px solid #dc2626
--c2-text-field__error--border-bottomborder1px solid #dc2626
--c2-text-field__error--border-leftborder1px solid #dc2626
--c2-text-field__error--colorcolor
--c2-text-field__error--backgroundcolor
--c2-text-field__error__focus--outlineoutline3px solid rgba(220, 38, 38, 0.2)
--c2-text-field__read-only--border-topborder1px solid #e4e4e7
--c2-text-field__read-only--border-rightborder1px solid #e4e4e7
--c2-text-field__read-only--border-bottomborder1px solid #e4e4e7
--c2-text-field__read-only--border-leftborder1px solid #e4e4e7
--c2-text-field__read-only--colorcolor
--c2-text-field__read-only--backgroundcolor#fafafa
--c2-text-field__disabled--opacityopacity0.38
--c2-text-field__icon--sizepixel16px
--c2-text-field__icon--colorcolor#71717a
--c2-text-field__clear-icon--sizepixel16px
--c2-text-field__clear-icon--colorcolor#a1a1aa
--c2-text-field__clear-icon__hover--colorcolor#18181b
--c2-text-field__help-icon--sizepixel16px
--c2-text-field__help-icon--colorcolor#71717a
--c2-text-field__help-icon--gappixel8pxSpace between the field and the help icon.
--c2-text-field__supporting-text--gappixel4pxSpace between the field and the helper line.
--c2-text-field__supporting-text--font-sizefont-size12px
--c2-text-field__supporting-text--line-heightpixel16px
--c2-text-field__supporting-text--colorcolor#71717a
--c2-text-field__supporting-text__error--colorcolor#dc2626
escAccordionConnected, animated panels with shared borders and single or multiple expansion.LayoutAvatarImage, initials or icon for a person, with status dot and badge.Data displayBadgeTinted pill for status text, counts and dots, optionally pinned to a corner of another element.Data displayBreadcrumbNavigation trail of link buttons with separators, a current page and optional collapsing.NavigationButtonThemeable button with slots for text, prefix, suffix and running icons.ButtonsButton GroupAttached buttons with shared borders, optionally a segmented control with single or multiple selection.ButtonsCardGroups related content and actions on a single bordered surface.LayoutChat InputAuto-growing message box with a send button for chat interfaces.ChatChat MessageOne chat bubble with avatar, title, timestamp and message body.ChatCheckboxNative checkbox behaviour in a quiet, themeable box with an opt-in hover layer.InputsCode ViewerSyntax-highlighted code with line numbers, copy button and dark mode, powered by shiki.Data displayColor AreaTwo-dimensional area for picking saturation and value of a colour.InputsColor SelectColour swatch that opens a full picker built from area and slider.InputsColor SliderHorizontal slider for choosing a hue from 0 to 360.InputsCopy ButtonButton that copies text to the clipboard — the element it sits in, another element by id, or a literal string.ButtonsDetailsCollapsible disclosure built on native details and summary.LayoutIcon ButtonRound, hoverable button wrapping a slotted SVG icon.ButtonsKbdKeyboard key label for shortcuts and command hints, with the semantics of the native kbd element.Data displayLabelCaption that names and activates the control referenced by its for attribute, with a required marker.InputsLink ButtonText-styled control for link and navigation actions, rendered as a real anchor or a button.NavigationListVertical list container with single or multiple selection.Data displayList ItemSelectable row with icon slots, used on its own or as the option of list and select.Data displayMenuCommands, links, checkboxes and submenus in a popover anchored to a trigger.NavigationModalDialog built on the native dialog element: focus trap, backdrop, Escape, title, body and footer.FeedbackNavigation MenuSite navigation bar whose triggers open panels of links below the header.NavigationOverlayAnchored popup built on the browser Popover API, positioned with floating-ui.FeedbackPaginationPage navigation in three layouts: numbered pages, a simple page status, or a table-footer row with rows-per-page.NavigationProgressLinear progress bar, indeterminate or filling to a value, with an optional label and count.FeedbackRadioRadio options built on native inputs, grouped into one value with keyboard navigation.InputsSelectDropdown that pairs a themeable trigger with an anchored list of c2-list-item options.InputsSeperatorHorizontal or vertical rule with an optional label, for dividing content and toolbars.LayoutSheetDialog pinned to an edge of the screen, for content that complements the page rather than interrupting it.FeedbackSide NavResponsive navigation drawer beside the page: pushes the content on large screens, slides over it with a backdrop on small ones.NavigationSkeletonPlaceholder block standing in for content that has not arrived, in three shapes and three animations.FeedbackSliderRange input with a themeable track, thumb, step ticks and value bubble.InputsSpinnerCircular progress indicator, indeterminate or showing a value, with optional text.FeedbackSwitchOn/off toggle on a native switch input, with label, description and thumb icons.InputsTableVirtualized data grid with declarative columns, sorting, selection, pinning and resizing.Data displayTabsTab strip that shows one content panel at a time.NavigationText FieldSingle-line input with icon slots, clear button, helper and error text, and a character counter.InputsTextareaMultiline text input with resizing, helper and error text, and a character counter.InputsToastNotification cards and a manager for stacked, queued notifications with independent lifetimes.FeedbackTooltipContextual hint shown when its target is hovered or focused, rendered in the top layer.FeedbackFeather Icons287 open-source Feather icons, one web component each.IconsMat Icon2,234 Material Icons ligatures rendered through a single element.IconsPhosphor Icons1,512 flexible icons in six weights, one web component each.IconsThemingTheme every c2n component from a handful of design tokens with @c2n/theme, or reach for any component variable directly.GuideUsing c2n in an applicationThe workflow behind every c2n app: load the theme once, use c2-* tags directly, and turn every repeated pattern into a small variant or composed component.Guide