- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
One tab in an editor's tab strip, muted until active, whose close button shows at all times.
Installation#
pnpm dlx shadcn@latest add @zui/editor-tabThe CLI writes components/navigation/editor-tab.tsx, installs Button,
Icon, Item,
Unsaved indicator and Utils, and adds lucide-react-native.
Usage#
import { EditorTab, EditorTabCloseButton, EditorTabTitle } from '@/components/navigation/editor-tab';<EditorTab active dirty>
<ItemContent>
<EditorTabTitle>page.tsx</EditorTabTitle>
</ItemContent>
<ItemActions>
<EditorTabCloseButton aria-label="Close page.tsx" onPress={close} />
</ItemActions>
</EditorTab>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#
EditorTab
|-- ItemContent
| `-- EditorTabTitle
`-- ItemActions
`-- EditorTabCloseButtonAPI reference#
EditorTab#
Takes every prop of Item except variant and size, which it fixes to
outline and xs, plus:
| Prop | Type | Default |
|---|---|---|
active | boolean | false |
dirty | boolean | false |
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.
onPressstands in for the web'sonClick. The X is a static icon; the web's plays while the button is hovered or focused.- The web's
data-slot,data-activeanddata-dirtyattributes are not set; a View takes no data attributes.