Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Code Group

One code block with tabs for its variants, such as npm, pnpm and yarn. Groups with the same sync-key switch together and remember the choice.

ComponentsCode Group
typographyinteractive
<arc-code-group>

Overview

CodeGroup puts several `arc-code-block` elements behind one set of tabs, so variants of the same thing (an install command for three package managers, or one command for two editions of a product) take the space of one block. Each child becomes a tab, named by its `label`, or by its `filename` or `language` when it has no label. The group draws the frame, the tab strip and one copy button that copies whichever block is showing, and the blocks drop their own headers. Give related groups the same `sync-key` and they switch together: pick pnpm in one and every group on the page with that key shows pnpm, matched by tab name. The choice is saved in localStorage under the key, so the next page opens on it too. A group without the tab the reader picked keeps what it had. The tabs follow the ARIA tabs pattern: one tab stop, the arrow keys move and select, Home and End jump to the ends. Picking a tab fires `arc-change` with the tab's name and index. Before the component upgrades, and without JavaScript, the blocks show one after another with their own headers, so nothing is hidden. A server render opens on the first tab, and a remembered choice applies once the page is live. CodeGroup doesn't import arc-code-block, so it's in the main barrel. Import `@arclux/arc-ui/code-block` for the blocks themselves, and shiki if you want them colored.

Guidelines

Do

  • Use it for real alternatives a reader picks one of: package managers, operating systems, editions
  • Give every block a short `label`. The tab names are all a reader has to choose by
  • Use the same `sync-key` and the same tab names across a page or a whole docs site
  • Keep the blocks parallel, so switching tabs changes only what differs

Don't

  • Don't use it for steps a reader runs in order. Those go in separate blocks, one after another
  • Don't put anything but `arc-code-block` elements inside. Other children are ignored
  • Don't give tabs in synced groups different names for the same thing, or they won't follow each other

Features

  • The copy button is icon-only

Preview

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-code-group label="Package manager" sync-key="pm">
  <arc-code-block label="npm" language="bash" prompt code="npm install @arclux/arc-ui"></arc-code-block>
  <arc-code-block label="pnpm" language="bash" prompt code="pnpm add @arclux/arc-ui"></arc-code-block>
  <arc-code-block label="yarn" language="bash" prompt code="yarn add @arclux/arc-ui"></arc-code-block>
</arc-code-group>

<script type="module">
  import '@arclux/arc-ui/code-block';
  import '@arclux/arc-ui/code-group';
</script>

API

sync-keystring''
Groups with the same key switch together, matched by tab name, and the choice is remembered in localStorage (arc-code-group:<key>).
labelstring''
Accessible name for the tab list, such as "Package manager".
selectednumber0
Index of the visible block. Out-of-range values fall back to the first block.

Events

arc-changedetail:{ value: string, index: number }
The user picked a tab. detail.value is the tab's name, detail.index its position. Not fired on groups that follow along through sync-key.

See also