Components › Components
Demos show your theme.
Kbd
A key to press, as in Ctrl K.
Search with Ctrl K.
Usage #
tscl
@import uiKbd from './kbd.tscl'
<div class="demo">
<p>Search with <uiKbd>Ctrl</uiKbd> <uiKbd>K</uiKbd>.</p>
</div>
<style scoped>
:scope {
display: grid;
gap: 12px;
padding: 24px;
border: 1px solid var(--ui-border);
border-radius: var(--ui-radius);
background: var(--ui-bg);
color: var(--ui-fg);
}
p {
margin: 0;
}
</style>Source #
Copy it into your components folder (next to the others) as kbd.tscl.
tscl
{{-- Kbd: a key to press. --}}
<kbd data-part="kbd"><slot /></kbd>
<style scoped>
@layer theme, base, components, utilities;
@layer components {
:where(:scope) {
display: inline-block;
min-width: 1.6em;
padding: 1px 6px;
border: 1px solid var(--ui-border);
border-bottom-width: 2px;
border-radius: 4px;
background: var(--ui-bg);
color: var(--ui-fg);
font: calc(var(--ui-font-size) - 2px)/1.5 var(--ui-font-mono);
text-align: center;
}
}
</style>Styling #
- On the root:
class,style,id,aria-*anddata-*written on the tag land on its root element;classandstylemerge with its own. - Selectors:
data-partnameskbd. - Your rules win: every rule here has zero specificity (
:where()) and sits in@layer components, so your own CSS and Tailwind utilities override it.
Needs #
- theme.css, once per project