Skip to documentation

Design system / Atoms

CreativeXHub design system

Atoms

Small controls and display elements: supported props, theme dependencies, consumer responsibilities and current examples.

Focused contracts, explicit consumers

An atom is a small, product-neutral control or display element with a focused API. This page documents Button, Input, Badge and Label in detail and shows other controls and small compound assemblies. A file in components/ui is not necessarily an atom: classify its responsibility, not its folder or source supplier.

Button

Variant, size, asChild and native button props. Product commands stay with the consumer.

Live preview

Current component with fictional data. Example changes are not persisted.

These actions intentionally have no business command. Icon-only controls need accessible names. Button variants also style links through buttonVariants.

src/components/ui/button.tsx

Button renders a native action control with shared variants, sizes and interaction styles. The caller supplies the accessible name, command and availability. With asChild, it applies that contract to a supplied element instead.

Supported inputs

Button maintained API notes
InputDefault / ownershipWhat it does
variantdefaultChoose default, destructive, outline, secondary, ghost or link. This changes appearance, not permission or confirmation behavior.
sizedefaultChoose default, xs, sm, lg, icon, icon-xs, icon-sm or icon-lg. Give icon-only buttons a name that explains the action.
asChildfalseApply Button's styling and props to a child instead of adding another button element. A link remains a link.
classNameoptionalAdjust a particular use. Overrides may prevent that use from picking up a later shared style change.
Native button propsforwardedIncludes disabled, onClick, type and aria-* attributes. Use type=button for actions that should not submit a surrounding form.

Theme and style dependencies

Button token and utility dependencies
Token / utilityWhat it contributes
bg-primary / text-primary-foregroundPrimary action background and its paired text color.
bg-secondary / text-secondary-foregroundA quieter action treatment with its own text pairing.
bg-accent / text-accent-foregroundHover feedback for outline and ghost treatments.
bg-destructive / text-whiteDestructive treatment currently uses literal white text, not the destructive-foreground token.
focus-visible:ring-ring / border-ringThe visible keyboard-focus indicator.
text-md / text-xs; rounded-md; h-9 / px-4The real fluid type scale, radius mapping and spacing multiplier supply the geometry.

Example binding

<Button type="button" variant="outline" size="sm" onClick={onContinue}>
  Continue
</Button>

A real use: FieldInfo inside LabelWithInfo

The help icon uses a ghost Button at icon-xs size. Its accessible name is More info. A change to ghost-button focus styling reaches this help trigger; changing only the default variant does not.

src/components/ui/field-label.tsx

Where to change it

Change buttonVariants for shared appearance, sizes or variants. Change Button itself for structure and prop handling. Keep labels and click commands in the screen using it. The exported buttonVariants helper also styles links, so its reach is wider than Button's markup.

Input

Native input props. Value, label association, validation and help are consumer-owned.

Live preview

Current component with fictional data. Example changes are not persisted.

Consumer-supplied error message.

src/components/ui/input.tsx

Input renders a native input element and forwards its standard attributes. The caller supplies type, value ownership, a label and validation feedback. Input does not define field meaning or product validation rules.

Supported inputs

Input maintained API notes
InputDefault / ownershipWhat it does
typenative text defaultChoose a suitable native input type, such as text or email.
value / defaultValue / onChangenative propsEither supply the current value and a change handler, or let the browser manage an initial value.
idconsumer suppliedMatch this ID with the label's htmlFor so clicking the label focuses the field.
disabled / aria-invalid / aria-describedbyforwardedDescribe availability, indicate invalid input and connect help or error text. These attributes do not implement validation.
classNameoptionalMerged with shared styles for a specific use.

Theme and style dependencies

Input token and utility dependencies
Token / utilityWhat it contributes
border-input / placeholder:text-muted-foregroundThe entry boundary and placeholder appearance.
selection:bg-primary / selection:text-primary-foregroundThe selected-text color pairing.
focus-visible:border-ring / ring-ringKeyboard focus styling.
aria-invalid:border-destructive / ring-destructiveAppearance when the surrounding form marks the value invalid.
dark:bg-input/30The current dark-mode surface treatment.
text-md / rounded-md / h-9 / px-3Shared type, shape and dimensions, backed by the theme.

Example binding

<Label htmlFor="display-name">Display name</Label>
<Input id="display-name" name="displayName" type="text" />

A real use: FormControl and FormLabel

FormControl passes generated IDs and accessibility attributes to its child control. FormLabel uses the same ID. The form's author still supplies the Input, help text, validation rule and error message.

src/components/ui/form.tsx

Where to change it

Change input.tsx for input-wide borders, dimensions, focus treatment or forwarded props. Keep field names, validation rules and product-specific formatting in the form or feature.

Badge

Variant and asChild; no size or disabled API. Text conveys meaning, not color alone.

Live preview

Current component with fictional data. Example changes are not persisted.

defaultsecondarydestructiveoutlineghostlink
src/components/ui/badge.tsx

Badge renders a compact span with selectable visual variants. The caller supplies the text and any status-to-variant mapping. With asChild, a supplied element retains its native semantics while receiving the badge treatment.

Supported inputs

Badge maintained API notes
InputDefault / ownershipWhat it does
variantdefaultChoose default, secondary, destructive, outline, ghost or link. It has no built-in status rules.
asChildfalseUse another element, such as an anchor, while retaining the badge treatment.
classNameoptionalAdjust a particular badge's shared styles.
Native span propsforwardedIncludes children and aria-* attributes. There is no built-in size or disabled prop.

Theme and style dependencies

Badge token and utility dependencies
Token / utilityWhat it contributes
bg-primary / text-primary-foregroundDefault badge pairing.
bg-secondary / text-secondary-foregroundSecondary pairing, used for draft submission summaries.
border-border / text-foregroundOutline treatment.
bg-destructive / text-whiteCurrent destructive treatment uses literal white.
[a&]:hover:* / focus-visible:ring-ringSome hover styles apply only to an actual anchor; focus styles do not make a span interactive.
text-xs / rounded-full / px-2 / py-0.5Compact type and pill-shaped geometry.

Example binding

<Badge variant="secondary">Draft</Badge>

A real use: SubmissionCard

SubmissionCard chooses secondary only when status is exactly draft; other statuses use outline. That choice belongs to the submission summary, not to Badge itself.

src/components/submissions/submissionCard.tsx

Where to change it

Change badgeVariants for the shared visual treatment. Keep status-to-text and status-to-variant decisions with the feature that understands those states.

Label

Radix label props. htmlFor must match the control ID; a placeholder is not a label.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/label.tsx

Label wraps Radix Label.Root with shared typography and disabled-state styles. Supply a persistent field name and match htmlFor to the control's id. Styling does not establish that association.

Supported inputs

Label maintained API notes
InputDefault / ownershipWhat it does
Radix Label.Root propsforwardedThe underlying label primitive supplies the association behavior.
htmlForconsumer suppliedUse the same ID as the control being named.
childrenconsumer suppliedProvide a clear, visible field name.
classNameoptionalMerged with the shared label styles.

Theme and style dependencies

Label token and utility dependencies
Token / utilityWhat it contributes
text-labelThe theme's purpose-driven label size.
leading-none / font-medium / gap-2Current line height, weight and spacing are explicit component choices.
group-data-[disabled=true] / peer-disabledDisabled styling depends on the matching surrounding group or peer markup.

Example binding

<Label htmlFor="contact-email">Contact email</Label>
<Input id="contact-email" type="email" />

A real use: LabelWithInfo

LabelWithInfo combines the Label with a separate help trigger. The label names the control; the tooltip adds optional explanation. Neither takes ownership of the field's value or validation.

src/components/ui/field-label.tsx

Where to change it

Change Label for shared label typography and association behavior. Keep field wording with the consumer, and keep help, errors and required-field rules in the larger field composition.

Textarea

Native textarea props; formatting and preview are separate compositions.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/textarea.tsx

Checkbox

Radix checked/onCheckedChange contract, including the indeterminate state.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/checkbox.tsx

Switch

Radix boolean checked/onCheckedChange; preference persistence is not built in.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/switch.tsx

Toggle

Radix pressed/onPressedChange plus local variants; not a form checkbox.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/toggle.tsx

RadioGroup

A related-choice assembly. Its group coordinates value and focus; individual items remain focused controls.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/radio-group.tsx

Avatar

Image/fallback compound display. This example uses an actual fallback, not an external image.

Live preview

Current component with fictional data. Example changes are not persisted.

EX
src/components/ui/avatar.tsx

Progress

Value-driven progress display. The consumer owns work and accessible labeling.

Live preview

Current component with fictional data. Example changes are not persisted.

src/components/ui/progress.tsx

Skeleton

Loading presentation only; the consumer owns announcement and request lifecycle.

Live preview

Current component with fictional data. Example changes are not persisted.

Loading example
src/components/ui/skeleton.tsx

Where a change reaches

Change the shared atom for common visual structure, supported variants and accessibility. Change product copy and commands in its consumer. Local class overrides can mask a shared change. Exported helpers such as buttonVariants also style links without rendering Button.

import { Button } from "@/components/ui/button";

<Button type="button" variant="outline" size="sm" onClick={onContinue}>
  Continue
</Button>
docs/decisions/ADR-0031-frontend-component-taxonomy-and-product-instances.md
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.