مفتاح
غطاء مفتاح لمفتاح يضغطه القارئ، يُعرض على الخادم. والتركيبة مفاتيح متجاورة، بلا جزء تجميع وبلا علامة زائد.
مفتاح
server - 0 KBغطاء مفتاح لمفتاح يضغطه القارئ، يُعرض على الخادم. والتركيبة مفاتيح متجاورة، بلا جزء تجميع وبلا علامة زائد.
الشيفرة
import { Kbd } from 'topclassui/kbd'
export default function Demo() {
return (
<div className="flex flex-wrap items-center gap-3">
<Kbd>K</Kbd>
<Kbd>Tab</Kbd>
<Kbd>Ctrl</Kbd>
<Kbd>Shift</Kbd>
<Kbd>Enter</Kbd>
<Kbd>Esc</Kbd>
</div>
)
}
الأيقونة داخل المفتاح <Svg> بلا حجم: بقيمتها الافتراضية 1em تتبع نص المفتاح نفسه.
أو استورده من الحزمة
import { Kbd } from 'topclassui/kbd'ثبّت مرة واحدة:npm i topclassui@beta zod
أمثلة
- لتسمية مفتاح يضغطه القارئ، داخل النص أو بجانب عنصر قائمة. هو
<kbd>واحد بشكل غطاء مفتاح، بلا خصائص خاصة به. - التركيبة مفاتيح متجاورة تفصل بينها مسافة. وللشكل المتداخل في مواصفة HTML، غلّف المفاتيح بنفسك في
<kbd>عادي.
import { Kbd } from 'topclassui/kbd'
export default function Demo() {
return (
<div className="flex flex-wrap items-center gap-3">
<Kbd>K</Kbd>
<Kbd>Tab</Kbd>
<Kbd>Ctrl</Kbd>
<Kbd>Shift</Kbd>
<Kbd>Enter</Kbd>
<Kbd>Esc</Kbd>
</div>
)
}
Press Ctrl K to open the command palette.
Press Shift Tab to move focus backwards.
import { Kbd } from 'topclassui/kbd'
/** The two pairs the Components page captions, as sibling keys on a raised card: no group, no plus. */
export default function Demo() {
return (
<div className="flex flex-col gap-3 rounded-box border border-line bg-surface-raised p-4 text-sm text-body">
<p>Press <Kbd>Ctrl</Kbd> <Kbd>K</Kbd> to open the command palette.</p>
<p>Press <Kbd>Shift</Kbd> <Kbd>Tab</Kbd> to move focus backwards.</p>
</div>
)
}
Press K to open the command palette.
import { command } from 'topclassui/icons/command'
import { Svg } from 'topclassui/svg'
import { Kbd } from 'topclassui/kbd'
/** The docs sample: the icon takes no size, so at its 1em default it follows the key's text. */
export default function Demo() {
return (
<p className="text-sm text-body">
Press <Kbd><Svg icon={command} label="Command" /></Kbd> <Kbd>K</Kbd> to open the command palette.
</p>
)
}
Press Shift Tab to move focus backwards.
import { Kbd } from 'topclassui/kbd'
/** The nested form of the HTML spec: a plain outer kbd the caller writes. It stays inline, so its
* keys follow the sentence in both directions, as sibling keys do. */
export default function Demo() {
return (
<p className="text-sm text-body">
Press <kbd className="whitespace-nowrap"><Kbd>Shift</Kbd> <Kbd>Tab</Kbd></kbd> to move focus backwards.
</p>
)
}
اضغط Ctrl K لفتح لوحة الأوامر.
اضغط Shift Tab للرجوع إلى العنصر السابق.
import { Kbd } from 'topclassui/kbd'
export default function Demo() {
return (
<div dir="rtl" lang="ar" className="flex flex-col gap-3 text-sm text-body">
<p>اضغط <Kbd>Ctrl</Kbd> <Kbd>K</Kbd> لفتح لوحة الأوامر.</p>
<p>اضغط <Kbd>Shift</Kbd> <Kbd>Tab</Kbd> للرجوع إلى العنصر السابق.</p>
</div>
)
}
الخصائص
لا خصائص خاصة به: يأخذ سمات العنصر الذي يعرضه.
لوحة المفاتيح وإمكانية الوصول
لا شيء يُشغَّل: ليس تفاعليًا بمفرده.
- ليس عنصر تحكم: لا يأخذ التركيز ولا حالات له.
- قارئ الشاشة يقرأ نص المفتاح، فأعطِ مفتاح الأيقونة اسمًا نصيًا، كما يسمّي المثال
with-iconأيقونته «Command».
من اليمين إلى اليسار
أسماء المفاتيح تبقى بالحروف اللاتينية، ومفاتيح التركيبة تتبع اتجاه الجملة، فيقع المفتاح الأول في العربية على اليمين.
الخادم والمتصفح
يُعرض على الخادم ولا يرسل أي JavaScript.
الملفات: index.tsx.
على الشارة: server - 0 KB.