moi-computer 0.11.0 → 0.11.1-dev.be1ed10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/client/AGENTS.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +170 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/useChat.ts +42 -24
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +25 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +210 -162
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +2 -30
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +23 -30
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-mzrgr577.js +5 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/default-widgets.ts +32 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +91 -34
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +42 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +139 -66
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -242
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +169 -108
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +48 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +46 -13
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +90 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -264
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r5xrenjy.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Button Group
|
|
3
|
+
description: A container that groups related buttons together with consistent styling.
|
|
4
|
+
base: base
|
|
5
|
+
component: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
'use client'
|
|
10
|
+
|
|
11
|
+
import * as React from 'react'
|
|
12
|
+
import {
|
|
13
|
+
IconArchive,
|
|
14
|
+
IconArrowLeft,
|
|
15
|
+
IconCalendarPlus,
|
|
16
|
+
IconClock,
|
|
17
|
+
IconFilter,
|
|
18
|
+
IconMailCheck,
|
|
19
|
+
IconDots,
|
|
20
|
+
IconTag,
|
|
21
|
+
IconTrash
|
|
22
|
+
} from '@tabler/icons-react'
|
|
23
|
+
|
|
24
|
+
import { Button } from '@/components/ui/button'
|
|
25
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
26
|
+
import {
|
|
27
|
+
DropdownMenu,
|
|
28
|
+
DropdownMenuContent,
|
|
29
|
+
DropdownMenuGroup,
|
|
30
|
+
DropdownMenuItem,
|
|
31
|
+
DropdownMenuRadioGroup,
|
|
32
|
+
DropdownMenuRadioItem,
|
|
33
|
+
DropdownMenuSeparator,
|
|
34
|
+
DropdownMenuSub,
|
|
35
|
+
DropdownMenuSubContent,
|
|
36
|
+
DropdownMenuSubTrigger,
|
|
37
|
+
DropdownMenuTrigger
|
|
38
|
+
} from '@/components/ui/dropdown-menu'
|
|
39
|
+
|
|
40
|
+
export function ButtonGroupDemo() {
|
|
41
|
+
const [label, setLabel] = React.useState('personal')
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ButtonGroup>
|
|
45
|
+
<ButtonGroup className="hidden sm:flex">
|
|
46
|
+
<Button variant="outline" size="icon" aria-label="Go Back">
|
|
47
|
+
<IconArrowLeft stroke={1.5} />
|
|
48
|
+
</Button>
|
|
49
|
+
</ButtonGroup>
|
|
50
|
+
<ButtonGroup>
|
|
51
|
+
<Button variant="outline">Archive</Button>
|
|
52
|
+
<Button variant="outline">Report</Button>
|
|
53
|
+
</ButtonGroup>
|
|
54
|
+
<ButtonGroup>
|
|
55
|
+
<Button variant="outline">Snooze</Button>
|
|
56
|
+
<DropdownMenu>
|
|
57
|
+
<DropdownMenuTrigger
|
|
58
|
+
render={<Button variant="outline" size="icon" aria-label="More Options" />}
|
|
59
|
+
>
|
|
60
|
+
<IconDots stroke={1.5} />
|
|
61
|
+
</DropdownMenuTrigger>
|
|
62
|
+
<DropdownMenuContent align="end" className="w-40">
|
|
63
|
+
<DropdownMenuGroup>
|
|
64
|
+
<DropdownMenuItem>
|
|
65
|
+
<IconMailCheck stroke={1.75} />
|
|
66
|
+
Mark as Read
|
|
67
|
+
</DropdownMenuItem>
|
|
68
|
+
<DropdownMenuItem>
|
|
69
|
+
<IconArchive stroke={1.75} />
|
|
70
|
+
Archive
|
|
71
|
+
</DropdownMenuItem>
|
|
72
|
+
</DropdownMenuGroup>
|
|
73
|
+
<DropdownMenuSeparator />
|
|
74
|
+
<DropdownMenuGroup>
|
|
75
|
+
<DropdownMenuItem>
|
|
76
|
+
<IconClock stroke={1.75} />
|
|
77
|
+
Snooze
|
|
78
|
+
</DropdownMenuItem>
|
|
79
|
+
<DropdownMenuItem>
|
|
80
|
+
<IconCalendarPlus stroke={1.75} />
|
|
81
|
+
Add to Calendar
|
|
82
|
+
</DropdownMenuItem>
|
|
83
|
+
<DropdownMenuItem>
|
|
84
|
+
<IconFilter stroke={1.75} />
|
|
85
|
+
Add to List
|
|
86
|
+
</DropdownMenuItem>
|
|
87
|
+
<DropdownMenuSub>
|
|
88
|
+
<DropdownMenuSubTrigger>
|
|
89
|
+
<IconTag stroke={1.75} />
|
|
90
|
+
Label As...
|
|
91
|
+
</DropdownMenuSubTrigger>
|
|
92
|
+
<DropdownMenuSubContent>
|
|
93
|
+
<DropdownMenuRadioGroup value={label} onValueChange={setLabel}>
|
|
94
|
+
<DropdownMenuRadioItem value="personal">Personal</DropdownMenuRadioItem>
|
|
95
|
+
<DropdownMenuRadioItem value="work">Work</DropdownMenuRadioItem>
|
|
96
|
+
<DropdownMenuRadioItem value="other">Other</DropdownMenuRadioItem>
|
|
97
|
+
</DropdownMenuRadioGroup>
|
|
98
|
+
</DropdownMenuSubContent>
|
|
99
|
+
</DropdownMenuSub>
|
|
100
|
+
</DropdownMenuGroup>
|
|
101
|
+
<DropdownMenuSeparator />
|
|
102
|
+
<DropdownMenuGroup>
|
|
103
|
+
<DropdownMenuItem variant="destructive">
|
|
104
|
+
<IconTrash stroke={1.75} />
|
|
105
|
+
Trash
|
|
106
|
+
</DropdownMenuItem>
|
|
107
|
+
</DropdownMenuGroup>
|
|
108
|
+
</DropdownMenuContent>
|
|
109
|
+
</DropdownMenu>
|
|
110
|
+
</ButtonGroup>
|
|
111
|
+
</ButtonGroup>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Installation
|
|
117
|
+
|
|
118
|
+
<CodeTabs>
|
|
119
|
+
|
|
120
|
+
<TabsList>
|
|
121
|
+
<TabsTrigger value="cli">Command</TabsTrigger>
|
|
122
|
+
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
123
|
+
</TabsList>
|
|
124
|
+
<TabsContent value="cli">
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
moi ui-components add button-group
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
</TabsContent>
|
|
131
|
+
|
|
132
|
+
<TabsContent value="manual">
|
|
133
|
+
|
|
134
|
+
<Steps className="mb-0 pt-2">
|
|
135
|
+
|
|
136
|
+
<Step>Install the following dependencies:</Step>
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm install @base-ui/react
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
<Step>Copy and paste the following code into your project.</Step>
|
|
143
|
+
|
|
144
|
+
<ComponentSource
|
|
145
|
+
name="button-group"
|
|
146
|
+
title="components/ui/button-group.tsx"
|
|
147
|
+
styleName="base-nova"
|
|
148
|
+
/>
|
|
149
|
+
|
|
150
|
+
<Step>Update the import paths to match your project setup.</Step>
|
|
151
|
+
|
|
152
|
+
</Steps>
|
|
153
|
+
|
|
154
|
+
</TabsContent>
|
|
155
|
+
|
|
156
|
+
</CodeTabs>
|
|
157
|
+
|
|
158
|
+
## Usage
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from '@/components/ui/button-group'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
<ButtonGroup>
|
|
166
|
+
<Button>Button 1</Button>
|
|
167
|
+
<Button>Button 2</Button>
|
|
168
|
+
</ButtonGroup>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Composition
|
|
172
|
+
|
|
173
|
+
Use the following composition to build a `ButtonGroup`:
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
ButtonGroup
|
|
177
|
+
├── Button or Input
|
|
178
|
+
├── ButtonGroupSeparator
|
|
179
|
+
└── ButtonGroupText
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Accessibility
|
|
183
|
+
|
|
184
|
+
- The `ButtonGroup` component has the `role` attribute set to `group`.
|
|
185
|
+
- Use <Kbd>Tab</Kbd> to navigate between the buttons in the group.
|
|
186
|
+
- Use `aria-label` or `aria-labelledby` to label the button group.
|
|
187
|
+
|
|
188
|
+
```tsx showLineNumbers
|
|
189
|
+
<ButtonGroup aria-label="Button group">
|
|
190
|
+
<Button>Button 1</Button>
|
|
191
|
+
<Button>Button 2</Button>
|
|
192
|
+
</ButtonGroup>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## ButtonGroup vs ToggleGroup
|
|
196
|
+
|
|
197
|
+
- Use the `ButtonGroup` component when you want to group buttons that perform an action.
|
|
198
|
+
- Use the `ToggleGroup` component when you want to group buttons that toggle a state.
|
|
199
|
+
|
|
200
|
+
## Orientation
|
|
201
|
+
|
|
202
|
+
Set the `orientation` prop to change the button group layout.
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import { IconMinus, IconPlus } from '@tabler/icons-react'
|
|
206
|
+
|
|
207
|
+
import { Button } from '@/components/ui/button'
|
|
208
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
209
|
+
|
|
210
|
+
export function ButtonGroupOrientation() {
|
|
211
|
+
return (
|
|
212
|
+
<ButtonGroup orientation="vertical" aria-label="Media controls" className="h-fit">
|
|
213
|
+
<Button variant="outline" size="icon">
|
|
214
|
+
<IconPlus stroke={1.5} />
|
|
215
|
+
</Button>
|
|
216
|
+
<Button variant="outline" size="icon">
|
|
217
|
+
<IconMinus stroke={1.5} />
|
|
218
|
+
</Button>
|
|
219
|
+
</ButtonGroup>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Size
|
|
225
|
+
|
|
226
|
+
Control the size of buttons using the `size` prop on individual buttons.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { IconPlus } from '@tabler/icons-react'
|
|
230
|
+
|
|
231
|
+
import { Button } from '@/components/ui/button'
|
|
232
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
233
|
+
|
|
234
|
+
export function ButtonGroupSize() {
|
|
235
|
+
return (
|
|
236
|
+
<div className="flex flex-col items-start gap-8">
|
|
237
|
+
<ButtonGroup>
|
|
238
|
+
<Button variant="outline" size="sm">
|
|
239
|
+
Small
|
|
240
|
+
</Button>
|
|
241
|
+
<Button variant="outline" size="sm">
|
|
242
|
+
Button
|
|
243
|
+
</Button>
|
|
244
|
+
<Button variant="outline" size="sm">
|
|
245
|
+
Group
|
|
246
|
+
</Button>
|
|
247
|
+
<Button variant="outline" size="icon-sm">
|
|
248
|
+
<IconPlus stroke={1.75} />
|
|
249
|
+
</Button>
|
|
250
|
+
</ButtonGroup>
|
|
251
|
+
<ButtonGroup>
|
|
252
|
+
<Button variant="outline">Default</Button>
|
|
253
|
+
<Button variant="outline">Button</Button>
|
|
254
|
+
<Button variant="outline">Group</Button>
|
|
255
|
+
<Button variant="outline" size="icon">
|
|
256
|
+
<IconPlus stroke={1.5} />
|
|
257
|
+
</Button>
|
|
258
|
+
</ButtonGroup>
|
|
259
|
+
<ButtonGroup>
|
|
260
|
+
<Button variant="outline" size="lg">
|
|
261
|
+
Large
|
|
262
|
+
</Button>
|
|
263
|
+
<Button variant="outline" size="lg">
|
|
264
|
+
Button
|
|
265
|
+
</Button>
|
|
266
|
+
<Button variant="outline" size="lg">
|
|
267
|
+
Group
|
|
268
|
+
</Button>
|
|
269
|
+
<Button variant="outline" size="icon-lg">
|
|
270
|
+
<IconPlus stroke={1.5} />
|
|
271
|
+
</Button>
|
|
272
|
+
</ButtonGroup>
|
|
273
|
+
</div>
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Nested
|
|
279
|
+
|
|
280
|
+
Nest `<ButtonGroup>` components to create button groups with spacing.
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
import { IconWaveSine, IconPlus } from '@tabler/icons-react'
|
|
284
|
+
|
|
285
|
+
import { Button } from '@/components/ui/button'
|
|
286
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
287
|
+
import { Input } from '@/components/ui/input'
|
|
288
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/ui/input-group'
|
|
289
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
290
|
+
|
|
291
|
+
export function ButtonGroupNested() {
|
|
292
|
+
return (
|
|
293
|
+
<ButtonGroup>
|
|
294
|
+
<ButtonGroup>
|
|
295
|
+
<Button variant="outline" size="icon">
|
|
296
|
+
<IconPlus stroke={1.5} />
|
|
297
|
+
</Button>
|
|
298
|
+
</ButtonGroup>
|
|
299
|
+
<ButtonGroup>
|
|
300
|
+
<InputGroup>
|
|
301
|
+
<InputGroupInput placeholder="Send a message..." />
|
|
302
|
+
<Tooltip>
|
|
303
|
+
<TooltipTrigger render={<InputGroupAddon align="inline-end" />}>
|
|
304
|
+
<IconWaveSine stroke={1.75} />
|
|
305
|
+
</TooltipTrigger>
|
|
306
|
+
<TooltipContent>Voice Mode</TooltipContent>
|
|
307
|
+
</Tooltip>
|
|
308
|
+
</InputGroup>
|
|
309
|
+
</ButtonGroup>
|
|
310
|
+
</ButtonGroup>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Separator
|
|
316
|
+
|
|
317
|
+
The `ButtonGroupSeparator` component visually divides buttons within a group.
|
|
318
|
+
|
|
319
|
+
Buttons with variant `outline` do not need a separator since they have a border. For other variants, a separator is recommended to improve the visual hierarchy.
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
import { Button } from '@/components/ui/button'
|
|
323
|
+
import { ButtonGroup, ButtonGroupSeparator } from '@/components/ui/button-group'
|
|
324
|
+
|
|
325
|
+
export function ButtonGroupSeparatorDemo() {
|
|
326
|
+
return (
|
|
327
|
+
<ButtonGroup>
|
|
328
|
+
<Button variant="secondary" size="sm">
|
|
329
|
+
Copy
|
|
330
|
+
</Button>
|
|
331
|
+
<ButtonGroupSeparator />
|
|
332
|
+
<Button variant="secondary" size="sm">
|
|
333
|
+
Paste
|
|
334
|
+
</Button>
|
|
335
|
+
</ButtonGroup>
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Split
|
|
341
|
+
|
|
342
|
+
Create a split button group by adding two buttons separated by a `ButtonGroupSeparator`.
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
import { IconPlus } from '@tabler/icons-react'
|
|
346
|
+
|
|
347
|
+
import { Button } from '@/components/ui/button'
|
|
348
|
+
import { ButtonGroup, ButtonGroupSeparator } from '@/components/ui/button-group'
|
|
349
|
+
|
|
350
|
+
export function ButtonGroupSplit() {
|
|
351
|
+
return (
|
|
352
|
+
<ButtonGroup>
|
|
353
|
+
<Button variant="secondary">Button</Button>
|
|
354
|
+
<ButtonGroupSeparator />
|
|
355
|
+
<Button size="icon" variant="secondary">
|
|
356
|
+
<IconPlus stroke={1.5} />
|
|
357
|
+
</Button>
|
|
358
|
+
</ButtonGroup>
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Input
|
|
364
|
+
|
|
365
|
+
Wrap an `Input` component with buttons.
|
|
366
|
+
|
|
367
|
+
```tsx
|
|
368
|
+
import { IconSearch } from '@tabler/icons-react'
|
|
369
|
+
|
|
370
|
+
import { Button } from '@/components/ui/button'
|
|
371
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
372
|
+
import { Input } from '@/components/ui/input'
|
|
373
|
+
|
|
374
|
+
export function ButtonGroupInput() {
|
|
375
|
+
return (
|
|
376
|
+
<ButtonGroup>
|
|
377
|
+
<Input placeholder="Search..." />
|
|
378
|
+
<Button variant="outline" aria-label="Search">
|
|
379
|
+
<IconSearch stroke={1.5} />
|
|
380
|
+
</Button>
|
|
381
|
+
</ButtonGroup>
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Input Group
|
|
387
|
+
|
|
388
|
+
Wrap an `InputGroup` component to create complex input layouts.
|
|
389
|
+
|
|
390
|
+
```tsx
|
|
391
|
+
'use client'
|
|
392
|
+
|
|
393
|
+
import * as React from 'react'
|
|
394
|
+
import { IconWaveSine, IconPlus } from '@tabler/icons-react'
|
|
395
|
+
|
|
396
|
+
import { Button } from '@/components/ui/button'
|
|
397
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
398
|
+
import {
|
|
399
|
+
InputGroup,
|
|
400
|
+
InputGroupAddon,
|
|
401
|
+
InputGroupButton,
|
|
402
|
+
InputGroupInput
|
|
403
|
+
} from '@/components/ui/input-group'
|
|
404
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
|
405
|
+
|
|
406
|
+
export function ButtonGroupInputGroup() {
|
|
407
|
+
const [voiceEnabled, setVoiceEnabled] = React.useState(false)
|
|
408
|
+
|
|
409
|
+
return (
|
|
410
|
+
<ButtonGroup className="[--radius:9999rem]">
|
|
411
|
+
<ButtonGroup>
|
|
412
|
+
<Button variant="outline" size="icon">
|
|
413
|
+
<IconPlus stroke={1.5} />
|
|
414
|
+
</Button>
|
|
415
|
+
</ButtonGroup>
|
|
416
|
+
<ButtonGroup>
|
|
417
|
+
<InputGroup>
|
|
418
|
+
<InputGroupInput
|
|
419
|
+
placeholder={voiceEnabled ? 'Record and send audio...' : 'Send a message...'}
|
|
420
|
+
disabled={voiceEnabled}
|
|
421
|
+
/>
|
|
422
|
+
<InputGroupAddon align="inline-end">
|
|
423
|
+
<Tooltip>
|
|
424
|
+
<TooltipTrigger
|
|
425
|
+
render={
|
|
426
|
+
<InputGroupButton
|
|
427
|
+
onClick={() => setVoiceEnabled(!voiceEnabled)}
|
|
428
|
+
size="icon-xs"
|
|
429
|
+
data-active={voiceEnabled}
|
|
430
|
+
className="data-[active=true]:bg-orange-100 data-[active=true]:text-orange-700 dark:data-[active=true]:bg-orange-800 dark:data-[active=true]:text-orange-100"
|
|
431
|
+
aria-pressed={voiceEnabled}
|
|
432
|
+
/>
|
|
433
|
+
}
|
|
434
|
+
>
|
|
435
|
+
<IconWaveSine stroke={1.5} />
|
|
436
|
+
</TooltipTrigger>
|
|
437
|
+
<TooltipContent>Voice Mode</TooltipContent>
|
|
438
|
+
</Tooltip>
|
|
439
|
+
</InputGroupAddon>
|
|
440
|
+
</InputGroup>
|
|
441
|
+
</ButtonGroup>
|
|
442
|
+
</ButtonGroup>
|
|
443
|
+
)
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## Dropdown Menu
|
|
448
|
+
|
|
449
|
+
Create a split button group with a `DropdownMenu` component.
|
|
450
|
+
|
|
451
|
+
```tsx
|
|
452
|
+
'use client'
|
|
453
|
+
|
|
454
|
+
import {
|
|
455
|
+
IconAlertTriangle,
|
|
456
|
+
IconCheck,
|
|
457
|
+
IconChevronDown,
|
|
458
|
+
IconCopy,
|
|
459
|
+
IconShare,
|
|
460
|
+
IconTrash,
|
|
461
|
+
IconUserX,
|
|
462
|
+
IconVolumeOff
|
|
463
|
+
} from '@tabler/icons-react'
|
|
464
|
+
|
|
465
|
+
import { Button } from '@/components/ui/button'
|
|
466
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
467
|
+
import {
|
|
468
|
+
DropdownMenu,
|
|
469
|
+
DropdownMenuContent,
|
|
470
|
+
DropdownMenuGroup,
|
|
471
|
+
DropdownMenuItem,
|
|
472
|
+
DropdownMenuSeparator,
|
|
473
|
+
DropdownMenuTrigger
|
|
474
|
+
} from '@/components/ui/dropdown-menu'
|
|
475
|
+
|
|
476
|
+
export function ButtonGroupDropdown() {
|
|
477
|
+
return (
|
|
478
|
+
<ButtonGroup>
|
|
479
|
+
<Button variant="outline">Follow</Button>
|
|
480
|
+
<DropdownMenu>
|
|
481
|
+
<DropdownMenuTrigger render={<Button variant="outline" className="pl-2!" />}>
|
|
482
|
+
<IconChevronDown stroke={1.5} />
|
|
483
|
+
</DropdownMenuTrigger>
|
|
484
|
+
<DropdownMenuContent align="end" className="w-44">
|
|
485
|
+
<DropdownMenuGroup>
|
|
486
|
+
<DropdownMenuItem>
|
|
487
|
+
<IconVolumeOff stroke={1.75} />
|
|
488
|
+
Mute Conversation
|
|
489
|
+
</DropdownMenuItem>
|
|
490
|
+
<DropdownMenuItem>
|
|
491
|
+
<IconCheck stroke={1.75} />
|
|
492
|
+
Mark as Read
|
|
493
|
+
</DropdownMenuItem>
|
|
494
|
+
<DropdownMenuItem>
|
|
495
|
+
<IconAlertTriangle stroke={1.75} />
|
|
496
|
+
Report Conversation
|
|
497
|
+
</DropdownMenuItem>
|
|
498
|
+
<DropdownMenuItem>
|
|
499
|
+
<IconUserX stroke={1.75} />
|
|
500
|
+
Block User
|
|
501
|
+
</DropdownMenuItem>
|
|
502
|
+
<DropdownMenuItem>
|
|
503
|
+
<IconShare stroke={1.75} />
|
|
504
|
+
Share Conversation
|
|
505
|
+
</DropdownMenuItem>
|
|
506
|
+
<DropdownMenuItem>
|
|
507
|
+
<IconCopy stroke={1.75} />
|
|
508
|
+
Copy Conversation
|
|
509
|
+
</DropdownMenuItem>
|
|
510
|
+
</DropdownMenuGroup>
|
|
511
|
+
<DropdownMenuSeparator />
|
|
512
|
+
<DropdownMenuGroup>
|
|
513
|
+
<DropdownMenuItem variant="destructive">
|
|
514
|
+
<IconTrash stroke={1.75} />
|
|
515
|
+
Delete Conversation
|
|
516
|
+
</DropdownMenuItem>
|
|
517
|
+
</DropdownMenuGroup>
|
|
518
|
+
</DropdownMenuContent>
|
|
519
|
+
</DropdownMenu>
|
|
520
|
+
</ButtonGroup>
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
## Select
|
|
526
|
+
|
|
527
|
+
Pair with a `Select` component.
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
'use client'
|
|
531
|
+
|
|
532
|
+
import * as React from 'react'
|
|
533
|
+
import { IconArrowRight } from '@tabler/icons-react'
|
|
534
|
+
|
|
535
|
+
import { Button } from '@/components/ui/button'
|
|
536
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
537
|
+
import { Input } from '@/components/ui/input'
|
|
538
|
+
import {
|
|
539
|
+
Select,
|
|
540
|
+
SelectContent,
|
|
541
|
+
SelectGroup,
|
|
542
|
+
SelectItem,
|
|
543
|
+
SelectTrigger
|
|
544
|
+
} from '@/components/ui/select'
|
|
545
|
+
|
|
546
|
+
const CURRENCIES = [
|
|
547
|
+
{ label: 'US Dollar', value: '$' },
|
|
548
|
+
{ label: 'Euro', value: '€' },
|
|
549
|
+
{ label: 'British Pound', value: '£' }
|
|
550
|
+
]
|
|
551
|
+
|
|
552
|
+
export function ButtonGroupSelect() {
|
|
553
|
+
const [currency, setCurrency] = React.useState('$')
|
|
554
|
+
|
|
555
|
+
return (
|
|
556
|
+
<ButtonGroup>
|
|
557
|
+
<ButtonGroup>
|
|
558
|
+
<Select
|
|
559
|
+
items={CURRENCIES}
|
|
560
|
+
value={currency}
|
|
561
|
+
onValueChange={value => setCurrency(value as string)}
|
|
562
|
+
>
|
|
563
|
+
<SelectTrigger className="font-mono">{currency}</SelectTrigger>
|
|
564
|
+
<SelectContent alignItemWithTrigger={false} align="start">
|
|
565
|
+
<SelectGroup>
|
|
566
|
+
{CURRENCIES.map(item => (
|
|
567
|
+
<SelectItem key={item.value} value={item.value}>
|
|
568
|
+
{item.value} <span className="text-muted-foreground">{item.label}</span>
|
|
569
|
+
</SelectItem>
|
|
570
|
+
))}
|
|
571
|
+
</SelectGroup>
|
|
572
|
+
</SelectContent>
|
|
573
|
+
</Select>
|
|
574
|
+
<Input placeholder="10.00" pattern="[0-9]*" />
|
|
575
|
+
</ButtonGroup>
|
|
576
|
+
<ButtonGroup>
|
|
577
|
+
<Button aria-label="Send" size="icon" variant="outline">
|
|
578
|
+
<IconArrowRight stroke={1.5} />
|
|
579
|
+
</Button>
|
|
580
|
+
</ButtonGroup>
|
|
581
|
+
</ButtonGroup>
|
|
582
|
+
)
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
## Popover
|
|
587
|
+
|
|
588
|
+
Use with a `Popover` component.
|
|
589
|
+
|
|
590
|
+
```tsx
|
|
591
|
+
import { IconRobot, IconChevronDown } from '@tabler/icons-react'
|
|
592
|
+
|
|
593
|
+
import { Button } from '@/components/ui/button'
|
|
594
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
595
|
+
import { Field, FieldDescription, FieldLabel } from '@/components/ui/field'
|
|
596
|
+
import {
|
|
597
|
+
Popover,
|
|
598
|
+
PopoverContent,
|
|
599
|
+
PopoverDescription,
|
|
600
|
+
PopoverHeader,
|
|
601
|
+
PopoverTitle,
|
|
602
|
+
PopoverTrigger
|
|
603
|
+
} from '@/components/ui/popover'
|
|
604
|
+
import { Textarea } from '@/components/ui/textarea'
|
|
605
|
+
|
|
606
|
+
export function ButtonGroupPopover() {
|
|
607
|
+
return (
|
|
608
|
+
<ButtonGroup>
|
|
609
|
+
<Button variant="outline">
|
|
610
|
+
<IconRobot stroke={1.5} /> Copilot
|
|
611
|
+
</Button>
|
|
612
|
+
<Popover>
|
|
613
|
+
<PopoverTrigger render={<Button variant="outline" size="icon" aria-label="Open Popover" />}>
|
|
614
|
+
<IconChevronDown stroke={1.5} />
|
|
615
|
+
</PopoverTrigger>
|
|
616
|
+
<PopoverContent align="end" className="rounded-xl text-sm">
|
|
617
|
+
<PopoverHeader>
|
|
618
|
+
<PopoverTitle>Start a new task with Copilot</PopoverTitle>
|
|
619
|
+
<PopoverDescription>Describe your task in natural language.</PopoverDescription>
|
|
620
|
+
</PopoverHeader>
|
|
621
|
+
<Field>
|
|
622
|
+
<FieldLabel htmlFor="task" className="sr-only">
|
|
623
|
+
Task Description
|
|
624
|
+
</FieldLabel>
|
|
625
|
+
<Textarea id="task" placeholder="I need to..." className="resize-none" />
|
|
626
|
+
<FieldDescription>Copilot will open a pull request for review.</FieldDescription>
|
|
627
|
+
</Field>
|
|
628
|
+
</PopoverContent>
|
|
629
|
+
</Popover>
|
|
630
|
+
</ButtonGroup>
|
|
631
|
+
)
|
|
632
|
+
}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
## RTL
|
|
636
|
+
|
|
637
|
+
```tsx
|
|
638
|
+
'use client'
|
|
639
|
+
|
|
640
|
+
import * as React from 'react'
|
|
641
|
+
import {
|
|
642
|
+
IconArchive,
|
|
643
|
+
IconArrowLeft,
|
|
644
|
+
IconCalendarPlus,
|
|
645
|
+
IconClock,
|
|
646
|
+
IconFilter,
|
|
647
|
+
IconMailCheck,
|
|
648
|
+
IconDots,
|
|
649
|
+
IconTag,
|
|
650
|
+
IconTrash
|
|
651
|
+
} from '@tabler/icons-react'
|
|
652
|
+
|
|
653
|
+
import { useTranslation, type Translations } from '@/components/language-selector'
|
|
654
|
+
import { Button } from '@/components/ui/button'
|
|
655
|
+
import { ButtonGroup } from '@/components/ui/button-group'
|
|
656
|
+
import {
|
|
657
|
+
DropdownMenu,
|
|
658
|
+
DropdownMenuContent,
|
|
659
|
+
DropdownMenuGroup,
|
|
660
|
+
DropdownMenuItem,
|
|
661
|
+
DropdownMenuRadioGroup,
|
|
662
|
+
DropdownMenuRadioItem,
|
|
663
|
+
DropdownMenuSeparator,
|
|
664
|
+
DropdownMenuSub,
|
|
665
|
+
DropdownMenuSubContent,
|
|
666
|
+
DropdownMenuSubTrigger,
|
|
667
|
+
DropdownMenuTrigger
|
|
668
|
+
} from '@/components/ui/dropdown-menu'
|
|
669
|
+
|
|
670
|
+
const translations: Translations = {
|
|
671
|
+
en: {
|
|
672
|
+
dir: 'ltr',
|
|
673
|
+
values: {
|
|
674
|
+
archive: 'Archive',
|
|
675
|
+
report: 'Report',
|
|
676
|
+
snooze: 'Snooze',
|
|
677
|
+
markAsRead: 'Mark as Read',
|
|
678
|
+
addToCalendar: 'Add to Calendar',
|
|
679
|
+
addToList: 'Add to List',
|
|
680
|
+
labelAs: 'Label As...',
|
|
681
|
+
personal: 'Personal',
|
|
682
|
+
work: 'Work',
|
|
683
|
+
other: 'Other',
|
|
684
|
+
trash: 'Trash'
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
ar: {
|
|
688
|
+
dir: 'rtl',
|
|
689
|
+
values: {
|
|
690
|
+
archive: 'أرشفة',
|
|
691
|
+
report: 'تقرير',
|
|
692
|
+
snooze: 'تأجيل',
|
|
693
|
+
markAsRead: 'وضع علامة كمقروء',
|
|
694
|
+
addToCalendar: 'إضافة إلى التقويم',
|
|
695
|
+
addToList: 'إضافة إلى القائمة',
|
|
696
|
+
labelAs: 'تصنيف كـ...',
|
|
697
|
+
personal: 'شخصي',
|
|
698
|
+
work: 'عمل',
|
|
699
|
+
other: 'آخر',
|
|
700
|
+
trash: 'سلة المهملات'
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
he: {
|
|
704
|
+
dir: 'rtl',
|
|
705
|
+
values: {
|
|
706
|
+
archive: 'ארכיון',
|
|
707
|
+
report: 'דוח',
|
|
708
|
+
snooze: 'דחה',
|
|
709
|
+
markAsRead: 'סמן כנקרא',
|
|
710
|
+
addToCalendar: 'הוסף ליומן',
|
|
711
|
+
addToList: 'הוסף לרשימה',
|
|
712
|
+
labelAs: 'תייג כ...',
|
|
713
|
+
personal: 'אישי',
|
|
714
|
+
work: 'עבודה',
|
|
715
|
+
other: 'אחר',
|
|
716
|
+
trash: 'פח'
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
export function ButtonGroupRtl() {
|
|
722
|
+
const { dir, t, language } = useTranslation(translations, 'ar')
|
|
723
|
+
const [label, setLabel] = React.useState('personal')
|
|
724
|
+
|
|
725
|
+
return (
|
|
726
|
+
<div dir={dir}>
|
|
727
|
+
<ButtonGroup>
|
|
728
|
+
<ButtonGroup className="hidden sm:flex">
|
|
729
|
+
<Button variant="outline" size="icon" aria-label="Go Back">
|
|
730
|
+
<IconArrowLeft stroke={1.5} className="rtl:rotate-180" />
|
|
731
|
+
</Button>
|
|
732
|
+
</ButtonGroup>
|
|
733
|
+
<ButtonGroup>
|
|
734
|
+
<Button variant="outline">{t.archive}</Button>
|
|
735
|
+
<Button variant="outline">{t.report}</Button>
|
|
736
|
+
</ButtonGroup>
|
|
737
|
+
<ButtonGroup>
|
|
738
|
+
<Button variant="outline">{t.snooze}</Button>
|
|
739
|
+
<DropdownMenu>
|
|
740
|
+
<DropdownMenuTrigger
|
|
741
|
+
render={<Button variant="outline" size="icon" aria-label="More Options" />}
|
|
742
|
+
>
|
|
743
|
+
<IconDots stroke={1.5} />
|
|
744
|
+
</DropdownMenuTrigger>
|
|
745
|
+
<DropdownMenuContent
|
|
746
|
+
align={dir === 'rtl' ? 'start' : 'end'}
|
|
747
|
+
data-lang={dir === 'rtl' ? language : undefined}
|
|
748
|
+
dir={dir}
|
|
749
|
+
className="w-40"
|
|
750
|
+
>
|
|
751
|
+
<DropdownMenuGroup>
|
|
752
|
+
<DropdownMenuItem>
|
|
753
|
+
<IconMailCheck stroke={1.75} />
|
|
754
|
+
{t.markAsRead}
|
|
755
|
+
</DropdownMenuItem>
|
|
756
|
+
<DropdownMenuItem>
|
|
757
|
+
<IconArchive stroke={1.75} />
|
|
758
|
+
{t.archive}
|
|
759
|
+
</DropdownMenuItem>
|
|
760
|
+
</DropdownMenuGroup>
|
|
761
|
+
<DropdownMenuSeparator />
|
|
762
|
+
<DropdownMenuGroup>
|
|
763
|
+
<DropdownMenuItem>
|
|
764
|
+
<IconClock stroke={1.75} />
|
|
765
|
+
{t.snooze}
|
|
766
|
+
</DropdownMenuItem>
|
|
767
|
+
<DropdownMenuItem>
|
|
768
|
+
<IconCalendarPlus stroke={1.75} />
|
|
769
|
+
{t.addToCalendar}
|
|
770
|
+
</DropdownMenuItem>
|
|
771
|
+
<DropdownMenuItem>
|
|
772
|
+
<IconFilter stroke={1.75} />
|
|
773
|
+
{t.addToList}
|
|
774
|
+
</DropdownMenuItem>
|
|
775
|
+
<DropdownMenuSub>
|
|
776
|
+
<DropdownMenuSubTrigger>
|
|
777
|
+
<IconTag stroke={1.75} />
|
|
778
|
+
{t.labelAs}
|
|
779
|
+
</DropdownMenuSubTrigger>
|
|
780
|
+
<DropdownMenuSubContent
|
|
781
|
+
dir={dir}
|
|
782
|
+
data-lang={dir === 'rtl' ? language : undefined}
|
|
783
|
+
>
|
|
784
|
+
<DropdownMenuRadioGroup value={label} onValueChange={setLabel}>
|
|
785
|
+
<DropdownMenuRadioItem value="personal">{t.personal}</DropdownMenuRadioItem>
|
|
786
|
+
<DropdownMenuRadioItem value="work">{t.work}</DropdownMenuRadioItem>
|
|
787
|
+
<DropdownMenuRadioItem value="other">{t.other}</DropdownMenuRadioItem>
|
|
788
|
+
</DropdownMenuRadioGroup>
|
|
789
|
+
</DropdownMenuSubContent>
|
|
790
|
+
</DropdownMenuSub>
|
|
791
|
+
</DropdownMenuGroup>
|
|
792
|
+
<DropdownMenuSeparator />
|
|
793
|
+
<DropdownMenuGroup>
|
|
794
|
+
<DropdownMenuItem variant="destructive">
|
|
795
|
+
<IconTrash stroke={1.75} />
|
|
796
|
+
{t.trash}
|
|
797
|
+
</DropdownMenuItem>
|
|
798
|
+
</DropdownMenuGroup>
|
|
799
|
+
</DropdownMenuContent>
|
|
800
|
+
</DropdownMenu>
|
|
801
|
+
</ButtonGroup>
|
|
802
|
+
</ButtonGroup>
|
|
803
|
+
</div>
|
|
804
|
+
)
|
|
805
|
+
}
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
## API Reference
|
|
809
|
+
|
|
810
|
+
### ButtonGroup
|
|
811
|
+
|
|
812
|
+
The `ButtonGroup` component is a container that groups related buttons together with consistent styling.
|
|
813
|
+
|
|
814
|
+
| Prop | Type | Default |
|
|
815
|
+
| ------------- | ---------------------------- | -------------- |
|
|
816
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` |
|
|
817
|
+
|
|
818
|
+
```tsx
|
|
819
|
+
<ButtonGroup>
|
|
820
|
+
<Button>Button 1</Button>
|
|
821
|
+
<Button>Button 2</Button>
|
|
822
|
+
</ButtonGroup>
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
Nest multiple button groups to create complex layouts with spacing. See the [nested](#nested) example for more details.
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
<ButtonGroup>
|
|
829
|
+
<ButtonGroup />
|
|
830
|
+
<ButtonGroup />
|
|
831
|
+
</ButtonGroup>
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
### ButtonGroupSeparator
|
|
835
|
+
|
|
836
|
+
The `ButtonGroupSeparator` component visually divides buttons within a group.
|
|
837
|
+
|
|
838
|
+
| Prop | Type | Default |
|
|
839
|
+
| ------------- | ---------------------------- | ------------ |
|
|
840
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"vertical"` |
|
|
841
|
+
|
|
842
|
+
```tsx
|
|
843
|
+
<ButtonGroup>
|
|
844
|
+
<Button>Button 1</Button>
|
|
845
|
+
<ButtonGroupSeparator />
|
|
846
|
+
<Button>Button 2</Button>
|
|
847
|
+
</ButtonGroup>
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
### ButtonGroupText
|
|
851
|
+
|
|
852
|
+
Use this component to display text within a button group.
|
|
853
|
+
|
|
854
|
+
| Prop | Type | Default |
|
|
855
|
+
| -------- | -------------------- | ------- |
|
|
856
|
+
| `render` | `React.ReactElement` | |
|
|
857
|
+
|
|
858
|
+
```tsx
|
|
859
|
+
<ButtonGroup>
|
|
860
|
+
<ButtonGroupText>Text</ButtonGroupText>
|
|
861
|
+
<Button>Button</Button>
|
|
862
|
+
</ButtonGroup>
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
Use the `render` prop to render a custom component as the text, for example a label.
|
|
866
|
+
|
|
867
|
+
```tsx showLineNumbers
|
|
868
|
+
import { ButtonGroupText } from '@/components/ui/button-group'
|
|
869
|
+
import { Label } from '@/components/ui/label'
|
|
870
|
+
|
|
871
|
+
export function ButtonGroupTextDemo() {
|
|
872
|
+
return (
|
|
873
|
+
<ButtonGroup>
|
|
874
|
+
<ButtonGroupText render={<Label htmlFor="name" />}>Text</ButtonGroupText>
|
|
875
|
+
<Input placeholder="Type something here..." id="name" />
|
|
876
|
+
</ButtonGroup>
|
|
877
|
+
)
|
|
878
|
+
}
|
|
879
|
+
```
|