Skip to content

feat(code): add preformatted text primitives - #14

Merged
maxigimenez merged 2 commits into
mainfrom
feat/code-component
Sep 2, 2026
Merged

maxigimenez merged 2 commits into
mainfrom
feat/code-component

Conversation

@maxigimenez

Copy link
Copy Markdown
Owner

Closes #6

Summary

  • add a block Code primitive for logs, JSON, prompts, configuration, and machine output
  • add an inline variant for identifiers and short fragments
  • expose @16-bits-design/ui/code plus the root barrel export
  • render block code as a named, keyboard-focusable native <pre> region containing <code>
  • preserve whitespace and contain long unbroken lines in an internal horizontal scroller
  • use --bits-surface as the inset ground and semantic theme variables for every color and focus state

Visual evidence

Ember

Code blocks in Ember

Ocean

Code blocks in Ocean

Overflow, theme, and accessibility evidence

  • block styles resolve to white-space: pre and overflow-x: auto
  • the scroll region is named from the visible label, uses tabIndex=0, and retains a visible token-based focus ring
  • at 320px, the document remains 320px wide while a 499px unbroken line scrolls inside a 252px region
  • Ember block: surface rgb(16, 15, 12), foreground rgb(255, 184, 119)
  • Ocean block: surface rgb(8, 16, 21), foreground rgb(168, 236, 255)
  • inline code has no unnecessary region semantics

Verification

  • Node 24.13.1
  • ESLint: pass
  • TypeScript: pass
  • Vitest: 16/16 pass
  • package build and 17 public export checks: pass
  • Storybook production build: pass

# Conflicts:
#	README.md
#	scripts/verify-package.mjs
#	src/components/components.test.tsx
@maxigimenez
maxigimenez merged commit d0a4f33 into main Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Code component for preformatted text

1 participant