Skip to content

components/TabPill

import { … } from 'zidane-ui'ui/src/components/TabPill.tsx

Segmented md
Segmented sm, one disabled
TabPill + CountBadge in a track

Components#

CountBadgeComponent#

The one count badge. attention is the agent waiting on the user (warn fill, soft pulse while it lasts); info a quiet count set into its surface; neutral an extension's own badge.

TypeScript
function CountBadge(props: CountBadgeProps): Element
Parameters
NameTypeDescription
propsCountBadgeProps

Component props.

Element
CountBadge props
NameTypeDescription
className?string

Extra classes on the root element.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

textstring

The count or short label to show.

toneCountTone

Look of the badge, see CountTone.

ui/src/components/TabPill.tsx:169

TabPillComponent#

Renders a tab in a .zg-segment track. The selected tab is the raised chip, and the close button shows on hover. A tab is one control for keyboard and assistive tech: Delete or Backspace on the focused tab closes it, and the close button is out of the tab order.

TypeScript
function TabPill(props: TabPillProps): Element
Parameters
NameTypeDescription
propsTabPillProps

Component props.

Element
TabPill props
NameTypeDefaultDescription
className?string

Extra classes on the wrapping element.

closeAlways?booleanfalse

Show the close button always, not only on hover or focus.

closeLabelstring

Accessible name and tooltip of the close button.

keyShortcuts?string

Keyboard shortcut of the tab, announced through aria-keyshortcuts, such as Control+1.

labelReactNode

Content of the tab.

leading?ReactNode

Content before the label, such as a file icon.

lifted?boolean

Raised without being selected (the pill being dragged).

marker?ReactNode

Overlay on the close button's corner, such as an unsaved or updated dot.

onAuxClick?(e: MouseEvent<HTMLButtonElement>) => void

Called on a non-primary click on the tab, such as a middle-click.

onClose() => void

Called when the close button is clicked, or on Delete or Backspace on the focused tab.

onContextMenu?(e: MouseEvent<HTMLButtonElement>) => void

Called on a right-click on the tab.

onKeyDown?(e: KeyboardEvent<HTMLButtonElement>) => void

Called on key down on the tab, before the built-in Delete and Backspace handling. Call preventDefault to skip it.

onSelect() => void

Called when the tab is clicked.

selectedboolean

Whether this is the current tab. Sets aria-selected and the raised chip.

size?'sm' | 'md''md'

Tab height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

title?string

Native tooltip of the tab.

trailing?ReactNode

Inside the tab (its accessible name includes it): the count badge.

ui/src/components/TabPill.tsx:74

Interfaces#

CountBadgePropsInterface#

Props for CountBadge.

TypeScript
interface CountBadgeProps
CountBadgeProps properties
NameTypeDescription
className?string

Extra classes on the root element.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

textstring

The count or short label to show.

toneCountTone

Look of the badge, see CountTone.

ui/src/components/TabPill.tsx:151

TabPillPropsInterface#

Props for TabPill.

TypeScript
interface TabPillProps
TabPillProps properties
NameTypeDefaultDescription
className?string

Extra classes on the wrapping element.

closeAlways?booleanfalse

Show the close button always, not only on hover or focus.

closeLabelstring

Accessible name and tooltip of the close button.

keyShortcuts?string

Keyboard shortcut of the tab, announced through aria-keyshortcuts, such as Control+1.

labelReactNode

Content of the tab.

leading?ReactNode

Content before the label, such as a file icon.

lifted?boolean

Raised without being selected (the pill being dragged).

marker?ReactNode

Overlay on the close button's corner, such as an unsaved or updated dot.

onAuxClick?(e: MouseEvent<HTMLButtonElement>) => void

Called on a non-primary click on the tab, such as a middle-click.

onClose() => void

Called when the close button is clicked, or on Delete or Backspace on the focused tab.

onContextMenu?(e: MouseEvent<HTMLButtonElement>) => void

Called on a right-click on the tab.

onKeyDown?(e: KeyboardEvent<HTMLButtonElement>) => void

Called on key down on the tab, before the built-in Delete and Backspace handling. Call preventDefault to skip it.

onSelect() => void

Called when the tab is clicked.

selectedboolean

Whether this is the current tab. Sets aria-selected and the raised chip.

size?'sm' | 'md''md'

Tab height: sm is 24px, md is 28px.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

title?string

Native tooltip of the tab.

trailing?ReactNode

Inside the tab (its accessible name includes it): the count badge.

ui/src/components/TabPill.tsx:19

Types#

CountToneType#

Look of a CountBadge: attention, info or neutral.

TypeScript
type CountTone = 'attention' | 'info' | 'neutral'

ui/src/components/TabPill.tsx:148