Skip to content

feat: add Kbd component - #886

Open
Shreyag02 wants to merge 1 commit into
mainfrom
feat/kbd-component
Open

feat: add Kbd component#886
Shreyag02 wants to merge 1 commit into
mainfrom
feat/kbd-component

Conversation

@Shreyag02

@Shreyag02 Shreyag02 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Kbd, a component for displaying keyboard keys and shortcut sequences.

Apsara has no shared way to render a keyboard key today, so it gets hand-rolled with inline styles wherever it appears. Command.Shortcut renders unstyled <kbd> elements, Menu has no shortcut support, and tooltips have no way to show an action's shortcut.

<Kbd>Esc</Kbd>

<Kbd.Group>
  <Kbd></Kbd>
  <Kbd>K</Kbd>
</Kbd.Group>

The API follows shadcn's Kbd, converted to Apsara conventions: dot-notation sub-components and --rs-* tokens. The visual treatment reuses the existing key styling from Command.Shortcut and the docs-site Kbd, so no new tokens were added.

One note for review: Kbd.Group renders a <kbd> rather than a <div>, since the HTML spec defines a nested kbd as an individual key within a larger input.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes, no bug fixes just code improvements)
  • Chore (changes to the build process or auxiliary tools and libraries such as documentation generation)
  • Style (changes that do not affect the meaning of the code (white-space, formatting, etc))
  • Test (adding missing tests or correcting existing tests)
  • Improvement (Improvements to existing code)
  • Other (please specify)

How Has This Been Tested?

  • 18 new tests covering rendering, className merging, ref forwarding, composition, and the data-slot contract. Full suite: 2589 passed, 1 skipped.
  • pnpm build:apsara and pnpm --filter www build both pass; the docs page generates and appears in the sidebar.
  • tsc --noEmit and biome check clean on all new files.
  • Checked in light and dark themes on a tooltip surface, in a menu row, and inline in text.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (.mdx files)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Screenshots (if appropriate):

N/A

Related Issues

N/A

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview Aug 10, 2026 10:03pm

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the semantic Kbd component and compound Kbd.Group API. Both support native props, refs, custom classes, and slot attributes. Adds keyboard shortcut styling and public package exports. Adds tests for rendering, composition, separators, semantics, forwarding, and slots. Adds documentation, prop interfaces, accessibility guidance, and demos for standalone keys, grouped shortcuts, separators, text, and tooltips.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant Button
  participant Tooltip
  participant Kbd
  User->>Button: Activate outline button
  Button->>Tooltip: Trigger tooltip
  Tooltip->>Kbd: Render Command-K shortcut
Loading

Suggested reviewers: rohilsurana, paansinghcoder

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding the Kbd component.
Description check ✅ Passed The description directly explains the Kbd component, its API, implementation purpose, tests, documentation, and validation.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/raystack/apsara/@raystack/apsara@886

commit: d679eef

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/www/src/content/docs/components/kbd/demo.ts`:
- Around line 5-8: In apps/www/src/content/docs/components/kbd/demo.ts, add
descriptive aria-label values to every symbol-only Kbd example: label Command at
lines 5-8, 13-19, 24-34, 42-46, 61-68, and 73-86; additionally label Shift and
Enter in the 13-19 example and Shift in the 24-34 example. Use labels such as
“Command,” “Shift,” and “Enter” while preserving the displayed symbols.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b976dc67-dfd8-49f0-97d5-98284057b0fe

📥 Commits

Reviewing files that changed from the base of the PR and between 8d138d4 and d679eef.

📒 Files selected for processing (9)
  • apps/www/src/content/docs/components/kbd/demo.ts
  • apps/www/src/content/docs/components/kbd/index.mdx
  • apps/www/src/content/docs/components/kbd/props.ts
  • packages/raystack/components/kbd/__tests__/data-slots.test.tsx
  • packages/raystack/components/kbd/__tests__/kbd.test.tsx
  • packages/raystack/components/kbd/index.tsx
  • packages/raystack/components/kbd/kbd.module.css
  • packages/raystack/components/kbd/kbd.tsx
  • packages/raystack/index.tsx

Comment on lines +5 to +8
code: `<Kbd.Group>
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
</Kbd.Group>`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add aria-label to every symbol-only key example.

These examples use symbols as the only key content. They do not follow the accessibility guidance on apps/www/src/content/docs/components/kbd/index.mdx line 94. Add labels such as <Kbd aria-label="Command">⌘</Kbd>.

  • apps/www/src/content/docs/components/kbd/demo.ts#L5-L8: Label the Command key.
  • apps/www/src/content/docs/components/kbd/demo.ts#L13-L19: Label the Command, Shift, and Enter keys.
  • apps/www/src/content/docs/components/kbd/demo.ts#L24-L34: Label the Command and Shift keys.
  • apps/www/src/content/docs/components/kbd/demo.ts#L42-L46: Label the Command key.
  • apps/www/src/content/docs/components/kbd/demo.ts#L61-L68: Label the Command key.
  • apps/www/src/content/docs/components/kbd/demo.ts#L73-L86: Label the Command key.
📍 Affects 1 file
  • apps/www/src/content/docs/components/kbd/demo.ts#L5-L8 (this comment)
  • apps/www/src/content/docs/components/kbd/demo.ts#L13-L19
  • apps/www/src/content/docs/components/kbd/demo.ts#L24-L34
  • apps/www/src/content/docs/components/kbd/demo.ts#L42-L46
  • apps/www/src/content/docs/components/kbd/demo.ts#L61-L68
  • apps/www/src/content/docs/components/kbd/demo.ts#L73-L86
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/www/src/content/docs/components/kbd/demo.ts` around lines 5 - 8, In
apps/www/src/content/docs/components/kbd/demo.ts, add descriptive aria-label
values to every symbol-only Kbd example: label Command at lines 5-8, 13-19,
24-34, 42-46, 61-68, and 73-86; additionally label Shift and Enter in the 13-19
example and Shift in the 24-34 example. Use labels such as “Command,” “Shift,”
and “Enter” while preserving the displayed symbols.

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.

1 participant