ZUI

Search documentation

Find a page or a heading.

Editor tab

One tab in an editor's tab strip, muted until active, whose close button shows at all times.

Installation

bash

The CLI writes components/navigation/editor-tab.tsx, installs Button, Icon, Item, Unsaved indicator and Utils, and adds lucide-react-native.

Usage

tsx
tsx

Compose the parts inside Item's ItemContent and ItemActions. Use it for one tab in an editor's tab strip; give it active for the document on show and dirty while that document has unsaved changes.

To make a tab pressable, give it asChild and a Pressable with role="tab" and aria-selected, as the demo does. A press on the close button does not reach that Pressable.

Composition

text

API reference

EditorTab

Takes every prop of Item except variant and size, which it fixes to outline and xs, plus:

It is as wide as its content.

EditorTabTitle

Takes every prop of ItemTitle. It is muted until its tab is active.

EditorTabCloseButton

Takes every prop of Button except children, which it supplies: a ghost extra-small icon button with an X, named "Close" unless given its own aria-label. On a dirty tab that is not active, the Unsaved indicator sits before it. A press on it does not reach the tab, so closing a tab does not also activate it.

Differences from the web

  • The close button's X shows at all times, since a phone has no hover to reveal it. On a dirty tab the web shows the unsaved dot in the X's place until the tab is hovered, focused or active; here the dot sits before the X while the tab is dirty and not active.
  • onPress stands in for the web's onClick. The X is a static icon; the web's plays while the button is hovered or focused.
  • The web's data-slot, data-active and data-dirty attributes are not set; a View takes no data attributes.