Skip to content

Commit 30d9f69

Browse files
authored
feat(component): add ButtonGroup component (#103)
1 parent e6cda35 commit 30d9f69

File tree

8 files changed

+88
-0
lines changed

8 files changed

+88
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
import { ButtonGroup as HeadlessButtonGroup } from '@qwik-ui/headless';
3+
4+
export type ButtonGroupProps = HTMLAttributes<HTMLElement>;
5+
6+
export const ButtonGroup = component$(
7+
(props: ButtonGroupProps) => {
8+
return (
9+
<HeadlessButtonGroup {...props} class="btn-group" >
10+
<Slot />
11+
</HeadlessButtonGroup>
12+
);
13+
}
14+
);

packages/daisy/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './components/button/button';
2+
export * from './components/button-group/button-group';
23
export * from './components/collapse/collapse';
34
export * from './components/drawer/drawer';
45
export * from './components/tabs';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
3+
export type ButtonGroupProps = HTMLAttributes<HTMLElement>;
4+
5+
export const ButtonGroup = component$(
6+
(props: ButtonGroupProps) => {
7+
return (
8+
<div {...props}>
9+
<Slot />
10+
</div>
11+
);
12+
}
13+
);

packages/headless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './components/button/button';
2+
export * from './components/button-group/button-group';
23
export * from './components/collapse/collapse';
34
export * from './components/drawer';
45
export * from './components/tabs/tabs';

packages/website/src/components/menu/menu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import styles from './menu.css?inline';
44

55
export const generateMenu = (library: string) => [
66
{ label: 'Button', path: `/docs/${library.toLowerCase()}/button` },
7+
{ label: 'ButtonGroup', path: `/docs/${library.toLowerCase()}/button-group` },
78
{ label: 'Collapse', path: `/docs/${library.toLowerCase()}/collapse` },
89
{ label: 'Drawer', path: `/docs/${library.toLowerCase()}/drawer` },
910
{ label: 'Select', path: `/docs/${library.toLowerCase()}/select` },
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { Button, ButtonGroup } from '@qwik-ui/theme-daisy';
3+
4+
export default component$(() => {
5+
return (
6+
<>
7+
<h2>This is the documentation for the ButtonGroup</h2>
8+
9+
<h1>Basic Example</h1>
10+
<ButtonGroup>
11+
<Button>BUTTON 1</Button>
12+
<Button>BUTTON 2</Button>
13+
<Button>BUTTON 3</Button>
14+
</ButtonGroup>
15+
16+
<hr/>
17+
<h1>With custom styles</h1>
18+
<ButtonGroup style="border: 0.2rem solid black; padding: 1rem;">
19+
<Button>BUTTON 1</Button>
20+
<Button>BUTTON 2</Button>
21+
<Button>BUTTON 3</Button>
22+
</ButtonGroup>
23+
</>
24+
);
25+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.custom-btn-group {
2+
display: inline-flex;
3+
padding: 1rem;
4+
gap: 3rem;
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { component$, useStyles$ } from '@builder.io/qwik';
2+
import { Button, ButtonGroup } from '@qwik-ui/headless';
3+
import styles from './button-group.css?inline';
4+
5+
export default component$(() => {
6+
useStyles$(styles);
7+
8+
return (
9+
<>
10+
<h2>This is the documentation for the ButtonGroup</h2>
11+
12+
<h1>Basic Example</h1>
13+
<ButtonGroup>
14+
<Button>BUTTON 1</Button>
15+
<Button>BUTTON 2</Button>
16+
<Button>BUTTON 3</Button>
17+
</ButtonGroup>
18+
19+
<hr/>
20+
<h1>With custom styles</h1>
21+
<ButtonGroup class="custom-btn-group" style="border: 2px solid black">
22+
<Button>BUTTON 1</Button>
23+
<Button>BUTTON 2</Button>
24+
<Button>BUTTON 3</Button>
25+
</ButtonGroup>
26+
</>
27+
);
28+
});

0 commit comments

Comments
 (0)