tuil
ReferenceComponentsTypography and status

Badge

Badge component API, behavior, and executable example.

View rawEdit

Loading executable example…

API and events

Render styled terminal copy, hierarchy, separators, labels, and compact status signals with semantic metadata.

export function Badge({
  tone = "neutral",
  children,
  ...props
}: BadgeProps): ReactNode;

Props, functions, and events

MemberTypeRequiredDescriptionRelated types
tone"neutral" | "success" | "warning" | "danger" | "info" | undefinedNoThe tone member uses the "neutral" | "success" | "warning" | "danger" | "info" | undefined contract.
aria-labelstring | undefinedNoA label for the element for screen readers.
aria-hiddenboolean | undefinedNoHide the element from screen readers.
colorLiteralUnion<keyof import("../../../../../../../packages/ink/node_modules/chalk/source/vendor/ansi-styles/index.js").ForegroundColor, string> | undefinedNoChange text color. Ink uses Chalk under the hood, so all its functionality is supported.
backgroundColorLiteralUnion<keyof import("../../../../../../../packages/ink/node_modules/chalk/source/vendor/ansi-styles/index.js").ForegroundColor, string> | undefinedNoSame as color, but for the background.
dimColorboolean | undefinedNoDim the color (make it less bright).
boldboolean | undefinedNoMake the text bold.
italicboolean | undefinedNoMake the text italic.
underlineboolean | undefinedNoMake the text underlined.
strikethroughboolean | undefinedNoMake the text crossed out with a line.
inverseboolean | undefinedNoInverse background and foreground colors.
wrap"wrap" | "hard" | "truncate-end" | "truncate" | "truncate-middle" | "truncate-start" | undefinedNoThis property tells Ink to wrap or truncate text if its width is larger than the container. If wrap is passed (the default), Ink will wrap text and split it into multiple lines. If hard is passed, Ink will fill each line to the full column width, breaking words as necessary. If truncate-* is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.
childrenReact.ReactNodeNoThe children member uses the React.ReactNode contract.
variantstring | undefinedNoThe variant member uses the string | undefined contract.
size"sm" | "md" | "lg" | undefinedNoThe size member uses the "sm" | "md" | "lg" | undefined contract.
unstyledboolean | undefinedNoThe unstyled member uses the boolean | undefined contract.
classNamestring | undefinedNoThe className member uses the string | undefined contract.
layoutPartial<Omit<LayoutNodeInput, "children" | "id" | "semantics">> | undefinedNoThe layout member uses the Partial<Omit<LayoutNodeInput, "children" | "id" | "semantics">> | undefined contract.
idstring | undefinedNoThe id member uses the string | undefined contract.
testIdstring | undefinedNoThe testId member uses the string | undefined contract.
roleSemanticRole | undefinedNoThe role member uses the SemanticRole | undefined contract.SemanticRole
labelstring | undefinedNoThe label member uses the string | undefined contract.
descriptionstring | undefinedNoThe description member uses the string | undefined contract.
disabledboolean | undefinedNoThe disabled member uses the boolean | undefined contract.
readOnlyboolean | undefinedNoThe readOnly member uses the boolean | undefined contract.
selectedboolean | undefinedNoThe selected member uses the boolean | undefined contract.
checkedboolean | undefinedNoThe checked member uses the boolean | undefined contract.
expandedboolean | undefinedNoThe expanded member uses the boolean | undefined contract.
valueTextstring | undefinedNoThe valueText member uses the string | undefined contract.
slotsPartial<SlotComponents<&#123; root: import("ink").TextProps; &#125;>> | undefinedNoThe slots member uses the Partial<SlotComponents<&#123; root: import("ink").TextProps; &#125;>> | undefined contract.SlotComponents, TextProps
slotPropsPartial<SlotProps<&#123; root: import("ink").TextProps; &#125;, object>> | undefinedNoThe slotProps member uses the Partial<SlotProps<&#123; root: import("ink").TextProps; &#125;, object>> | undefined contract.SlotProps, TextProps

No events are emitted.

Callback props run after the documented input is accepted. Callbacks are not cancellable unless their return type or description states otherwise.

Interaction and capabilities

Read-only presentation; accessibility lives in semantic role and label metadata.

The published manifest records keyboard, focus, pointer, theme, terminal, semantic, event, and dependency requirements.

Complete import

import { Badge } from "@/components/tuil/data-display/text";

On this page