Home / Function/ ModelItem() — ui Function Reference

ModelItem() — ui Function Reference

Architecture documentation for the ModelItem() function in model-selector.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  c273cd83_7f27_a159_5725_3371ea1c750d["ModelItem()"]
  c9ff8f7d_3661_b534_3ddc_912a75766464["model-selector.tsx"]
  c273cd83_7f27_a159_5725_3371ea1c750d -->|defined in| c9ff8f7d_3661_b534_3ddc_912a75766464
  style c273cd83_7f27_a159_5725_3371ea1c750d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/app/(app)/examples/playground/components/model-selector.tsx lines 134–162

function ModelItem({ model, isSelected, onSelect, onPeek }: ModelItemProps) {
  const ref = React.useRef<HTMLDivElement>(null)

  useMutationObserver(ref, (mutations) => {
    mutations.forEach((mutation) => {
      if (
        mutation.type === "attributes" &&
        mutation.attributeName === "aria-selected" &&
        ref.current?.getAttribute("aria-selected") === "true"
      ) {
        onPeek(model)
      }
    })
  })

  return (
    <CommandItem
      key={model.id}
      onSelect={onSelect}
      ref={ref}
      className="data-[selected=true]:bg-primary data-[selected=true]:text-primary-foreground"
    >
      {model.name}
      <Check
        className={cn("ml-auto", isSelected ? "opacity-100" : "opacity-0")}
      />
    </CommandItem>
  )
}

Subdomains

Frequently Asked Questions

What does ModelItem() do?
ModelItem() is a function in the ui codebase, defined in deprecated/www/app/(app)/examples/playground/components/model-selector.tsx.
Where is ModelItem() defined?
ModelItem() is defined in deprecated/www/app/(app)/examples/playground/components/model-selector.tsx at line 134.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free