@hanzo/ui

Item

import { Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle } from '@hanzo/ui'

Default

Media, a title and description, and an action, in one row.

i
New message from Sarah
Sarah sent you a message about the design review.
export function Default() {
  return (
    <Item variant="outline">
      <ItemMedia variant="icon">
        <Badge variant="secondary">i</Badge>
      </ItemMedia>
      <ItemContent>
        <ItemTitle>New message from Sarah</ItemTitle>
        <ItemDescription>Sarah sent you a message about the design review.</ItemDescription>
      </ItemContent>
      <ItemActions>
        <Button size="sm" variant="outline">
          Reply
        </Button>
      </ItemActions>
    </Item>
  )
}

Variants

Default, outline and muted read as three levels of emphasis.

Default
Outline
Muted
export function Variants() {
  return (
    <YStack gap="$3">
      <Item variant="default">
        <ItemContent>
          <ItemTitle>Default</ItemTitle>
        </ItemContent>
      </Item>
      <Item variant="outline">
        <ItemContent>
          <ItemTitle>Outline</ItemTitle>
        </ItemContent>
      </Item>
      <Item variant="muted">
        <ItemContent>
          <ItemTitle>Muted</ItemTitle>
        </ItemContent>
      </Item>
    </YStack>
  )
}

Group

A list of items sharing one rhythm, divided by a separator.

Invoice #1024
Paid on March 3
Paid
Invoice #1025
Due March 18
Due
export function Group() {
  return (
    <ItemGroup>
      <Item size="sm" variant="outline">
        <ItemContent>
          <ItemTitle>Invoice #1024</ItemTitle>
          <ItemDescription>Paid on March 3</ItemDescription>
        </ItemContent>
        <ItemActions>
          <Badge variant="secondary">Paid</Badge>
        </ItemActions>
      </Item>
      <ItemSeparator />
      <Item size="sm" variant="outline">
        <ItemContent>
          <ItemTitle>Invoice #1025</ItemTitle>
          <ItemDescription>Due March 18</ItemDescription>
        </ItemContent>
        <ItemActions>
          <Badge variant="outline">Due</Badge>
        </ItemActions>
      </Item>
    </ItemGroup>
  )
}

As a link

`asChild` puts the row's hover and focus styling on the anchor.

export function AsChild() {
  return (
    <XStack maxW={420}>
      <Item asChild variant="outline">
        <a href="/dashboard">
          <ItemContent>
            <ItemTitle>Dashboard</ItemTitle>
            <ItemDescription>Overview of your account and activity.</ItemDescription>
          </ItemContent>
        </a>
      </Item>
    </XStack>
  )
}

Types

export type ItemVariant = 'default' | 'outline' | 'muted'
export type ItemSize = 'default' | 'sm' | 'row'
export type ItemMediaVariant = 'default' | 'icon' | 'image'
export type ItemProps = Omit<ComponentProps<typeof ItemFrame>, 'color'> & {
  variant?: ItemVariant | null
  size?: ItemSize | null
  asChild?: boolean
  /** `check` after the content when `selected`; `checkbox` a box before it; `none` (default) tints a selected row. */
  indicator?: 'none' | 'check' | 'checkbox'
  selected?: boolean
  /** Highlighted by a cursor that is not focus (a list whose search field keeps focus). */
  focused?: boolean
  color?: 'neutral' | 'danger'
  disabled?: boolean
  /** Keep a disabled row focusable, saying `aria-disabled` instead of `disabled`. */
  focusableWhenDisabled?: boolean
  /** Keys after the content: one key or a list read as a chord. */
  shortcut?: string | readonly string[]
  /** Trailing controls; `hover` shows them under the pointer or focus (always on touch). */
  actions?: ReactNode
  actionsVisibility?: 'hover' | 'always'
  /** A trailing chevron; a disabled row keeps its width so rows align. */
  hasSubmenu?: boolean
}
export type ItemMediaProps = ComponentProps<typeof ItemMediaFrame> & {
  variant?: ItemMediaVariant | null
}
export type ItemContentProps = ComponentProps<typeof ItemContentFrame>
export type ItemTitleProps = ComponentProps<typeof ItemTitleFrame>
export type ItemDescriptionProps = ComponentProps<typeof ItemDescriptionFrame>
export type ItemActionsProps = ComponentProps<typeof ItemActionsFrame>
export type ItemHeaderProps = ComponentProps<typeof ItemHeaderFrame>
export type ItemFooterProps = ComponentProps<typeof ItemFooterFrame>
export type ItemGroupProps = ComponentProps<typeof ItemGroupFrame>
export type ItemSeparatorProps = ComponentProps<typeof Separator>

Exports

ItemItemActionsItemContentItemDescriptionItemFooterItemGroupItemHeaderItemMediaItemSeparatorItemTitletype ItemActionsPropstype ItemContentPropstype ItemDescriptionPropstype ItemFooterPropstype ItemGroupPropstype ItemHeaderPropstype ItemMediaPropstype ItemMediaVarianttype ItemPropstype ItemSeparatorPropstype ItemSizetype ItemTitlePropstype ItemVariant