Components › Components
Demos show your theme.
Button group
Buttons that belong together, joined into one row.
Usage #
tscl
@import uiButtonGroup from './button-group.tscl'
@import uiButton from './button.tscl'
<div class="demo">
<uiButtonGroup label="Text alignment">
<uiButton variant="outline">Left</uiButton>
<uiButton variant="outline">Center</uiButton>
<uiButton variant="outline">Right</uiButton>
</uiButtonGroup>
</div>
<style scoped>
:scope {
display: grid;
gap: 12px;
justify-items: start;
padding: 24px;
border: 1px solid var(--ui-border);
border-radius: var(--ui-radius);
background: var(--ui-bg);
color: var(--ui-fg);
}
</style>Source #
Copy it next to your components as button-group.tscl.
tscl
{{-- Button group: buttons that belong together, joined into one row. label names the group. --}}
@input label: string
<div role="group" [aria-label]="label" data-part="button-group"><slot /></div>
<style scoped>
@layer theme, base, components, utilities;
@layer components {
:where(:scope) {
display: inline-flex;
}
:where(:scope > *:not(:first-child)) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-left: -1px;
}
:where(:scope > *:not(:last-child)) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
:where(:scope > *:focus-visible) {
position: relative;
z-index: 1;
}
}
</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-partnamesbutton-group. - 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