Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion apps/ui/content/docs/components/avatar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
</Avatar>
```

Use `keepMounted` when the image relies on native lazy loading or an optimized image component. The fallback remains visible while the image loads or if it fails:

```tsx
<Avatar>
<AvatarImage
src="/avatars/01.png"
alt="User avatar"
loading="lazy"
keepMounted
/>
<AvatarFallback>JD</AvatarFallback>
</Avatar>
```

## API Reference

### Avatar
Expand All @@ -68,7 +82,7 @@ Root component. Styled wrapper for `Avatar.Root` from Base UI with default size

### AvatarImage

Image element for the avatar. Styled wrapper for `Avatar.Image` from Base UI.
Image element for the avatar. Styled wrapper for `Avatar.Image` from Base UI with support for `keepMounted` images.

### AvatarFallback

Expand Down
33 changes: 32 additions & 1 deletion apps/ui/content/docs/components/combobox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
ComboboxItem,
ComboboxList,
ComboboxPopup,
createComboboxItems,
} from "@/components/ui/combobox"
```

Expand All @@ -81,6 +82,33 @@ const items = [
</Combobox>
```

When your source items are objects but selection should use a stable primitive value, create a typed collection with `createComboboxItems`:

```tsx
const users = [
{ id: "ada", name: "Ada Lovelace" },
{ id: "grace", name: "Grace Hopper" },
]

const userItems = createComboboxItems(users, {
getLabel: (user) => user.name,
getValue: (user) => user.id,
})

<Combobox defaultValue="ada" items={userItems}>
<ComboboxInput placeholder="Select a user..." />
<ComboboxPopup>
<ComboboxList>
{(user) => (
<ComboboxItem key={user.id} value={user.id}>
{user.name}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxPopup>
</Combobox>
```

### Multiple Selection

```tsx
Expand Down Expand Up @@ -145,6 +173,10 @@ The root combobox component. Manages the combobox state and provides context to
| `open` | `boolean` | Controls whether the popup is open |
| `...props` | `React.ComponentProps<typeof Combobox>` | All Base UI Combobox props are supported |

### createComboboxItems

Creates a typed item collection that derives primitive selection values and labels from object items. Define static collections outside components and memoize dynamic collections.

### ComboboxInput

The input field component for single selection mode with extended features for size variants and addon support.
Expand Down Expand Up @@ -328,4 +360,3 @@ Use `SelectButton` as a `render` prop on `ComboboxTrigger` to make the combobox
### Form Integration - Multiple

<ComponentPreview name="p-combobox-12" />

2 changes: 1 addition & 1 deletion apps/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@base-ui/react": "1.6.0",
"@base-ui/react": "1.8.0",
"@coss/ui": "workspace:*",
"@daypicker/react": "10.0.1",
"@hugeicons/core-free-icons": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/r/avatar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"files": [
{
"path": "registry/default/ui/avatar.tsx",
"content": "\"use client\";\n\nimport { Avatar as AvatarPrimitive } from \"@base-ui/react/avatar\";\nimport type React from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\nexport function Avatar({\n className,\n ...props\n}: AvatarPrimitive.Root.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Root\n className={cn(\n \"inline-flex size-8 shrink-0 select-none items-center justify-center overflow-hidden rounded-full bg-background align-middle font-medium text-xs\",\n className,\n )}\n data-slot=\"avatar\"\n {...props}\n />\n );\n}\n\nexport function AvatarImage({\n className,\n ...props\n}: AvatarPrimitive.Image.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Image\n className={cn(\"size-full object-cover\", className)}\n data-slot=\"avatar-image\"\n {...props}\n />\n );\n}\n\nexport function AvatarFallback({\n className,\n ...props\n}: AvatarPrimitive.Fallback.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Fallback\n className={cn(\n \"flex size-full items-center justify-center rounded-full bg-muted\",\n className,\n )}\n data-slot=\"avatar-fallback\"\n {...props}\n />\n );\n}\n\nexport { AvatarPrimitive };\n",
"content": "\"use client\";\n\nimport { Avatar as AvatarPrimitive } from \"@base-ui/react/avatar\";\nimport type React from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\nexport function Avatar({\n className,\n ...props\n}: AvatarPrimitive.Root.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Root\n className={cn(\n \"relative isolate inline-flex size-8 shrink-0 select-none items-center justify-center overflow-hidden rounded-full bg-background align-middle font-medium text-xs\",\n className,\n )}\n data-slot=\"avatar\"\n {...props}\n />\n );\n}\n\nexport function AvatarImage({\n className,\n ...props\n}: AvatarPrimitive.Image.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Image\n className={cn(\n \"absolute inset-0 z-10 size-full object-cover data-error:invisible data-loading:invisible\",\n className,\n )}\n data-slot=\"avatar-image\"\n {...props}\n />\n );\n}\n\nexport function AvatarFallback({\n className,\n ...props\n}: AvatarPrimitive.Fallback.Props): React.ReactElement {\n return (\n <AvatarPrimitive.Fallback\n className={cn(\n \"absolute inset-0 flex size-full items-center justify-center rounded-full bg-muted\",\n className,\n )}\n data-slot=\"avatar-fallback\"\n {...props}\n />\n );\n}\n\nexport { AvatarPrimitive };\n",
"type": "registry:ui"
}
],
Expand Down
Loading
Loading