combobox-01
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const frameworks = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
] as const
export function ComboboxBasic() {
return (
<Combobox items={frameworks}>
<ComboboxInput placeholder="Select a Designali product" />
<ComboboxContent>
<ComboboxEmpty>No items found.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-02
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
const frameworks = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
] as const
export function ComboboxMultiple() {
const anchor = useComboboxAnchor()
return (
<Combobox
multiple
autoHighlight
items={frameworks}
defaultValue={[frameworks[0]]}
>
<ComboboxChips ref={anchor} className="w-full max-w-xs">
<ComboboxValue>
{(values) => (
<React.Fragment>
{values.map((value: string) => (
<ComboboxChip key={value}>{value}</ComboboxChip>
))}
<ComboboxChipsInput />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No items found.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-03
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const frameworks = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
] as const
export function ComboboxWithClear() {
return (
<Combobox items={frameworks} defaultValue={frameworks[0]}>
<ComboboxInput placeholder="Select a Designali product" showClear />
<ComboboxContent>
<ComboboxEmpty>No items found.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-04
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
const frameworks = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
] as const
export function ComboboxMultiple() {
const anchor = useComboboxAnchor()
return (
<Combobox
multiple
autoHighlight
items={frameworks}
defaultValue={[frameworks[0]]}
>
<ComboboxChips ref={anchor} className="w-full max-w-xs">
<ComboboxValue>
{(values) => (
<React.Fragment>
{values.map((value: string) => (
<ComboboxChip key={value}>{value}</ComboboxChip>
))}
<ComboboxChipsInput />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No items found.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-05
Loading...
"use client"
import {
Combobox,
ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
ComboboxGroup,
ComboboxInput,
ComboboxItem,
ComboboxLabel,
ComboboxList,
ComboboxSeparator,
} from "@/components/ui/combobox"
const timezones = [
{
value: "Americas",
items: [
"(GMT-5) New York",
"(GMT-8) Los Angeles",
"(GMT-6) Chicago",
"(GMT-5) Toronto",
"(GMT-8) Vancouver",
"(GMT-3) São Paulo",
],
},
{
value: "Europe",
items: [
"(GMT+0) London",
"(GMT+1) Paris",
"(GMT+1) Berlin",
"(GMT+1) Rome",
"(GMT+1) Madrid",
"(GMT+1) Amsterdam",
],
},
{
value: "Asia/Pacific",
items: [
"(GMT+9) Tokyo",
"(GMT+8) Shanghai",
"(GMT+8) Singapore",
"(GMT+4) Dubai",
"(GMT+11) Sydney",
"(GMT+9) Seoul",
],
},
] as const
export function ComboboxWithGroupsAndSeparator() {
return (
<Combobox items={timezones}>
<ComboboxInput placeholder="Select a timezone" />
<ComboboxContent>
<ComboboxEmpty>No timezones found.</ComboboxEmpty>
<ComboboxList>
{(group, index) => (
<ComboboxGroup key={group.value} items={group.items}>
<ComboboxLabel>{group.value}</ComboboxLabel>
<ComboboxCollection>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxCollection>
{index < timezones.length - 1 && <ComboboxSeparator />}
</ComboboxGroup>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-06
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Item,
ItemContent,
ItemDescription,
ItemTitle,
} from "@/components/ui/item"
const countries = [
{ code: "", value: "", continent: "", label: "Select country" },
{
code: "ar",
value: "argentina",
label: "Argentina",
continent: "South America",
},
{ code: "au", value: "australia", label: "Australia", continent: "Oceania" },
{ code: "br", value: "brazil", label: "Brazil", continent: "South America" },
{ code: "ca", value: "canada", label: "Canada", continent: "North America" },
{ code: "cn", value: "china", label: "China", continent: "Asia" },
{
code: "co",
value: "colombia",
label: "Colombia",
continent: "South America",
},
{ code: "eg", value: "egypt", label: "Egypt", continent: "Africa" },
{ code: "fr", value: "france", label: "France", continent: "Europe" },
{ code: "de", value: "germany", label: "Germany", continent: "Europe" },
{ code: "it", value: "italy", label: "Italy", continent: "Europe" },
{ code: "jp", value: "japan", label: "Japan", continent: "Asia" },
{ code: "ke", value: "kenya", label: "Kenya", continent: "Africa" },
{ code: "mx", value: "mexico", label: "Mexico", continent: "North America" },
{
code: "nz",
value: "new-zealand",
label: "New Zealand",
continent: "Oceania",
},
{ code: "ng", value: "nigeria", label: "Nigeria", continent: "Africa" },
{
code: "za",
value: "south-africa",
label: "South Africa",
continent: "Africa",
},
{ code: "kr", value: "south-korea", label: "South Korea", continent: "Asia" },
{
code: "gb",
value: "united-kingdom",
label: "United Kingdom",
continent: "Europe",
},
{
code: "us",
value: "united-states",
label: "United States",
continent: "North America",
},
]
export function ComboboxWithCustomItems() {
return (
<Combobox
items={countries.filter((country) => country.code !== "")}
itemToStringValue={(country: (typeof countries)[number]) => country.label}
>
<ComboboxInput placeholder="Search countries..." />
<ComboboxContent>
<ComboboxEmpty>No countries found.</ComboboxEmpty>
<ComboboxList>
{(country) => (
<ComboboxItem key={country.code} value={country}>
<Item size="xs" className="p-0">
<ItemContent>
<ItemTitle className="whitespace-nowrap">
{country.label}
</ItemTitle>
<ItemDescription>
{country.continent} ({country.code})
</ItemDescription>
</ItemContent>
</Item>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-07
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const frameworks = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
] as const
export function ComboboxInvalid() {
return (
<Combobox items={frameworks}>
<ComboboxInput placeholder="Select a Designali product" aria-invalid="true" />
<ComboboxContent>
<ComboboxEmpty>No items found.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}combobox-08
Loading...
"use client"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
type Member = { id: string; name: string; email: string; initials: string }
const members: Member[] = [
{ id: "1", name: "Ali Imam", email: "ali@designali.com", initials: "AI" },
{
id: "2",
name: "Sara Designer",
email: "sara@designali.com",
initials: "SD",
},
{
id: "3",
name: "Omar Developer",
email: "omar@designali.com",
initials: "OD",
},
{
id: "4",
name: "Nina Motion",
email: "nina@designali.com",
initials: "NM",
},
{ id: "5", name: "Leo Brand", email: "leo@designali.com", initials: "LB" },
]
export function AssigneePicker() {
return (
<div className="w-full max-w-xs">
<Combobox
items={members}
itemToStringLabel={(member: Member) => member.name}
>
<ComboboxInput placeholder="Assign to..." className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No teammates found.</ComboboxEmpty>
<ComboboxList>
{(member: Member) => (
<ComboboxItem key={member.id} value={member}>
<Avatar size="sm">
<AvatarFallback>{member.initials}</AvatarFallback>
</Avatar>
<div className="flex min-w-0 flex-col">
<span className="truncate">{member.name}</span>
<span className="truncate text-[11px] text-muted-foreground">
{member.email}
</span>
</div>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-09
Loading...
"use client"
import * as React from "react"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const regions = [
"Frankfurt (eu-central-1)",
"Dublin (eu-west-1)",
"Virginia (us-east-1)",
"Oregon (us-west-2)",
"Singapore (ap-southeast-1)",
]
export function ControlledRegionReadout() {
const [value, setValue] = React.useState<string | null>(regions[0]!)
return (
<div className="flex w-full max-w-xs flex-col gap-3">
<Combobox items={regions} value={value} onValueChange={setValue}>
<ComboboxInput placeholder="Choose a region" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No regions found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<div className="flex items-center justify-between border bg-muted/40 px-3 py-2 text-xs">
<span>
Deploying to: <span className="font-medium">{value ?? "none"}</span>
</span>
<Button
variant="ghost"
size="xs"
onClick={() => setValue(null)}
disabled={!value}
>
Reset
</Button>
</div>
</div>
)
}
combobox-10
Loading...
"use client"
import {
Lock as LockIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
const plans = ["Starter", "Team", "Business", "Enterprise"]
export function DisabledCombobox() {
return (
<Field className="w-full max-w-xs" data-disabled>
<FieldLabel>Billing plan</FieldLabel>
<Combobox items={plans} defaultValue="Business" disabled>
<ComboboxInput disabled className="w-full" />
<ComboboxContent>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription className="flex items-center gap-1">
<LockIcon className="size-3" />
Only workspace owners can change the plan.
</FieldDescription>
</Field>
)
}
combobox-11
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
const titles = [
"Product Designer",
"Product Manager",
"Frontend Engineer",
"Backend Engineer",
"Design Engineer",
"Engineering Manager",
"Motion Designer",
]
export function JobTitleField() {
return (
<FieldGroup className="w-full max-w-xs">
<Field>
<FieldLabel htmlFor="full-name">Full name</FieldLabel>
<Input id="full-name" defaultValue="Ali Imam" />
</Field>
<Field>
<FieldLabel htmlFor="job-title">Job title</FieldLabel>
<Combobox items={titles}>
<ComboboxInput
id="job-title"
placeholder="Search titles"
className="w-full"
/>
<ComboboxContent>
<ComboboxEmpty>No matching titles.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription>
Shown on your profile and in mentions.
</FieldDescription>
</Field>
</FieldGroup>
)
}
combobox-12
Loading...
"use client"
import * as React from "react"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
const departments = [
"Engineering",
"Design",
"Marketing",
"Sales",
"Operations",
"Finance",
]
export function RequiredFieldValidation() {
const [value, setValue] = React.useState<string | null>(null)
const [submitted, setSubmitted] = React.useState(false)
const invalid = submitted && !value
return (
<form
className="flex w-full max-w-xs flex-col gap-4"
onSubmit={(event) => {
event.preventDefault()
setSubmitted(true)
}}
>
<Field data-invalid={invalid || undefined}>
<FieldLabel htmlFor="department">Department</FieldLabel>
<Combobox items={departments} value={value} onValueChange={setValue}>
<ComboboxInput
id="department"
placeholder="Select department"
aria-invalid={invalid}
className="w-full"
/>
<ComboboxContent>
<ComboboxEmpty>No departments found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
{invalid && <FieldError>Please choose a department.</FieldError>}
</Field>
<Button type="submit">{submitted && value ? "Saved" : "Continue"}</Button>
</form>
)
}
combobox-13
Loading...
"use client"
import {
Building2 as Building2Icon,
Search as SearchIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
const customers = [
"Dalim Agency",
"Dalim Fonts",
"Dalim Graphic",
"Dalim Icons",
"Dalim Tools",
"Dalim Works",
]
export function CustomerSearchAddon() {
return (
<div className="w-full max-w-xs">
<Combobox items={customers}>
<ComboboxInput
placeholder="Search customers"
showTrigger={false}
showClear
className="w-full"
>
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No customers match.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
<Building2Icon className="text-muted-foreground" />
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-14
Loading...
"use client"
import {
Folder as FolderIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
ComboboxValue,
} from "@/components/ui/combobox"
const projects = [
"designali.com refresh",
"Templates v2",
"Brand identity",
"Icons library",
"Dalim UI",
]
export function MoveToProjectButton() {
return (
<Combobox items={projects} defaultValue="Templates v2">
<ComboboxTrigger
render={
<Button
variant="outline"
className="w-56 justify-between font-normal"
/>
}
>
<span className="flex items-center gap-2 truncate">
<FolderIcon className="text-muted-foreground" />
<ComboboxValue placeholder="Move to project" />
</span>
</ComboboxTrigger>
<ComboboxContent>
<ComboboxInput showTrigger={false} placeholder="Search projects" />
<ComboboxEmpty>No projects found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
combobox-15
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
const topics = [
"Design systems",
"Accessibility",
"Motion",
"Typography",
"Research",
"Prototyping",
"Illustration",
]
const MAX = 3
export function TopicTagsMaxThree() {
const anchor = useComboboxAnchor()
const [value, setValue] = React.useState<string[]>(["Accessibility"])
return (
<Field className="w-full max-w-xs">
<FieldLabel>Topics you write about</FieldLabel>
<Combobox
multiple
items={topics}
value={value}
onValueChange={(next) => setValue(next.slice(0, MAX))}
>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values: string[]) => (
<React.Fragment>
{values.map((topic) => (
<ComboboxChip key={topic}>{topic}</ComboboxChip>
))}
<ComboboxChipsInput
placeholder={values.length < MAX ? "Add topic" : ""}
disabled={values.length >= MAX}
/>
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No topics found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem
key={item}
value={item}
disabled={value.length >= MAX && !value.includes(item)}
>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription>
{MAX - value.length} of {MAX} remaining
</FieldDescription>
</Field>
)
}
combobox-16
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
import { cn } from "@/lib/utils"
type IssueLabel = { name: string; color: string }
const labels: IssueLabel[] = [
{ name: "bug", color: "bg-destructive" },
{ name: "feature", color: "bg-primary" },
{ name: "design", color: "bg-primary" },
{ name: "docs", color: "bg-primary" },
{ name: "performance", color: "bg-primary" },
]
export function IssueLabelChips() {
const anchor = useComboboxAnchor()
return (
<div className="w-full max-w-xs">
<Combobox
multiple
items={labels}
defaultValue={[labels[0]!, labels[2]!]}
itemToStringLabel={(label: IssueLabel) => label.name}
isItemEqualToValue={(a, b) => a.name === b.name}
>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values: IssueLabel[]) => (
<React.Fragment>
{values.map((label) => (
<ComboboxChip key={label.name}>
<span className={cn("size-2 rounded-full", label.color)} />
{label.name}
</ComboboxChip>
))}
<ComboboxChipsInput placeholder="Add label" />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No labels found.</ComboboxEmpty>
<ComboboxList>
{(label: IssueLabel) => (
<ComboboxItem key={label.name} value={label}>
<span className={cn("size-2.5 rounded-full", label.color)} />
{label.name}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-17
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
type Contact = { name: string; email: string }
const contacts: Contact[] = [
{ name: "Ali Imam", email: "ali@designali.com" },
{ name: "Designali Support", email: "support@designali.com" },
{ name: "Designali Billing", email: "billing@designali.com" },
{ name: "Client Team", email: "client@example.com" },
]
const initialsOf = (name: string) =>
name
.split(" ")
.map((part) => part[0])
.join("")
export function EmailRecipientsField() {
const anchor = useComboboxAnchor()
return (
<div className="w-full max-w-md border">
<div className="flex items-center gap-2 border-b px-3 py-2">
<span className="text-xs text-muted-foreground">To</span>
<Combobox
multiple
items={contacts}
defaultValue={[contacts[0]!]}
itemToStringLabel={(contact: Contact) => contact.name}
isItemEqualToValue={(a, b) => a.email === b.email}
>
<ComboboxChips
ref={anchor}
className="flex-1 border-0 px-0 focus-within:ring-0 dark:bg-transparent"
>
<ComboboxValue>
{(values: Contact[]) => (
<React.Fragment>
{values.map((contact) => (
<ComboboxChip key={contact.email}>
<span className="flex size-4 items-center justify-center rounded-full bg-foreground text-[8px] text-background">
{initialsOf(contact.name)}
</span>
{contact.name}
</ComboboxChip>
))}
<ComboboxChipsInput />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No contacts found.</ComboboxEmpty>
<ComboboxList>
{(contact: Contact) => (
<ComboboxItem key={contact.email} value={contact}>
<div className="flex flex-col">
<span>{contact.name}</span>
<span className="text-[11px] text-muted-foreground">
{contact.email}
</span>
</div>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
<div className="px-3 py-2 text-sm text-muted-foreground">
Subject: Q4 planning notes
</div>
</div>
)
}
combobox-18
Loading...
"use client"
import {
Server as ServerIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
ComboboxGroup,
ComboboxInput,
ComboboxItem,
ComboboxLabel,
ComboboxList,
} from "@/components/ui/combobox"
import { cn } from "@/lib/utils"
type Region = { id: string; city: string; ms: number }
const groups: { label: string; items: Region[] }[] = [
{
label: "Europe",
items: [
{ id: "fra", city: "Frankfurt", ms: 18 },
{ id: "ams", city: "Amsterdam", ms: 22 },
{ id: "lhr", city: "London", ms: 27 },
],
},
{
label: "North America",
items: [
{ id: "iad", city: "Virginia", ms: 94 },
{ id: "sfo", city: "San Francisco", ms: 148 },
],
},
{
label: "Asia Pacific",
items: [
{ id: "sin", city: "Singapore", ms: 182 },
{ id: "syd", city: "Sydney", ms: 274 },
],
},
]
export function ServerRegionLatency() {
return (
<div className="w-full max-w-xs">
<Combobox
items={groups}
itemToStringLabel={(region: Region) => region.city}
>
<ComboboxInput placeholder="Pick a region" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No regions found.</ComboboxEmpty>
<ComboboxList>
{(group: (typeof groups)[number]) => (
<ComboboxGroup key={group.label} items={group.items}>
<ComboboxLabel>{group.label}</ComboboxLabel>
<ComboboxCollection>
{(region: Region) => (
<ComboboxItem key={region.id} value={region}>
<ServerIcon className="text-muted-foreground" />
{region.city}
<span
className={cn(
"ml-auto text-[11px] tabular-nums",
region.ms < 50
? "text-primary dark:text-primary"
: "text-muted-foreground"
)}
>
{region.ms} ms
</span>
</ComboboxItem>
)}
</ComboboxCollection>
</ComboboxGroup>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-19
Loading...
"use client"
import {
Cpu as CpuIcon,
} from "@designali/icons"
import { Badge } from "@/components/ui/badge"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
type Machine = { id: string; label: string; spec: string; locked: boolean }
const machines: Machine[] = [
{ id: "s", label: "Small", spec: "1 vCPU · 2 GB", locked: false },
{ id: "m", label: "Medium", spec: "2 vCPU · 4 GB", locked: false },
{ id: "l", label: "Large", spec: "4 vCPU · 16 GB", locked: true },
{ id: "xl", label: "X-Large", spec: "8 vCPU · 32 GB", locked: true },
]
export function PlanTierDisabledItems() {
return (
<div className="w-full max-w-xs">
<Combobox
items={machines}
defaultValue={machines[0]}
itemToStringLabel={(machine: Machine) => machine.label}
>
<ComboboxInput placeholder="Machine size" className="w-full" />
<ComboboxContent>
<ComboboxList>
{(machine: Machine) => (
<ComboboxItem
key={machine.id}
value={machine}
disabled={machine.locked}
>
<CpuIcon className="text-muted-foreground" />
<span className="flex-1">{machine.label}</span>
<span className="text-[11px] text-muted-foreground">
{machine.spec}
</span>
{machine.locked && (
<Badge variant="outline" className="h-4 px-1 text-[10px]">
Pro
</Badge>
)}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-20
Loading...
"use client"
import * as React from "react"
import {
Users as UsersIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
import { Spinner } from "@/components/ui/spinner"
const directory = [
"Ali Imam",
"Amir · Designer",
"Bella · Client",
"Chris · Developer",
"Dana · Motion Designer",
"Eli · Brand Designer",
"Farah · Client",
"Gia · Designer",
]
export function AsyncUserSearch() {
const [query, setQuery] = React.useState("")
const [results, setResults] = React.useState<string[]>([])
const [loading, setLoading] = React.useState(false)
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null)
React.useEffect(
() => () => {
if (timer.current) clearTimeout(timer.current)
},
[]
)
const search = (next: string) => {
setQuery(next)
if (timer.current) clearTimeout(timer.current)
if (!next) {
setResults([])
setLoading(false)
return
}
setLoading(true)
timer.current = setTimeout(() => {
setResults(
directory.filter((name) =>
name.toLowerCase().includes(next.toLowerCase())
)
)
setLoading(false)
}, 500)
}
return (
<div className="w-full max-w-xs">
<Combobox
items={results}
filter={null}
inputValue={query}
onInputValueChange={search}
>
<ComboboxInput
placeholder="Search the directory"
className="w-full"
showTrigger={false}
>
<InputGroupAddon align="inline-end">
{loading ? <Spinner /> : <UsersIcon />}
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>
{loading
? "Searching..."
: query
? "No people match " + JSON.stringify(query)
: "Start typing a name"}
</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-21
Loading...
"use client"
import * as React from "react"
import {
Hash as HashIcon,
Plus as PlusIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
type Tag = { value: string; creatable?: boolean }
export function CreatableTagInput() {
const anchor = useComboboxAnchor()
const [tags, setTags] = React.useState<Tag[]>([
{ value: "urgent" },
{ value: "q4" },
{ value: "customer" },
])
const [selected, setSelected] = React.useState<Tag[]>([])
const [query, setQuery] = React.useState("")
const trimmed = query.trim()
const exists = tags.some(
(tag) => tag.value.toLowerCase() === trimmed.toLowerCase()
)
const items =
trimmed && !exists ? [...tags, { value: trimmed, creatable: true }] : tags
return (
<div className="w-full max-w-xs">
<Combobox
multiple
items={items}
value={selected}
inputValue={query}
onInputValueChange={setQuery}
itemToStringLabel={(tag: Tag) => tag.value}
isItemEqualToValue={(a, b) => a.value === b.value}
onValueChange={(next) => {
const created = next.find((tag) => tag.creatable)
if (created) {
const tag = { value: created.value }
setTags((prev) => [...prev, tag])
setSelected([...next.filter((t) => !t.creatable), tag])
} else {
setSelected(next)
}
setQuery("")
}}
>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values: Tag[]) => (
<React.Fragment>
{values.map((tag) => (
<ComboboxChip key={tag.value}>#{tag.value}</ComboboxChip>
))}
<ComboboxChipsInput placeholder="Add or create tags" />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxList>
{(tag: Tag) => (
<ComboboxItem
key={tag.value + (tag.creatable ? "-new" : "")}
value={tag}
>
{tag.creatable ? (
<>
<PlusIcon />
Create "{tag.value}"
</>
) : (
<>
<HashIcon className="text-muted-foreground" />
{tag.value}
</>
)}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-22
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { Field, FieldLabel } from "@/components/ui/field"
const colors = ["Template", "Block", "Icons", "Logos", "Vectors", "Pages"]
const sizes = ["SOLO", "TEAM", "PRO", "AGENCY", "LIFETIME"]
const skus = colors.flatMap((color) =>
sizes.map((size) => "DA-" + color.toUpperCase() + "-" + size)
)
export function LargeCatalogLimit() {
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="sku">SKU</FieldLabel>
<Combobox items={skus} limit={6}>
<ComboboxInput
id="sku"
placeholder="Search 30 SKUs"
className="w-full font-sans"
/>
<ComboboxContent>
<ComboboxEmpty>No SKUs match.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item} className="font-sans">
{item}
</ComboboxItem>
)}
</ComboboxList>
<div className="border-t px-2 py-1.5 text-[11px] text-muted-foreground">
Showing up to 6 results. Keep typing to narrow.
</div>
</ComboboxContent>
</Combobox>
</Field>
)
}
combobox-23
Loading...
"use client"
import * as React from "react"
import {
ScanBarcode as ScanBarcodeIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
type Product = { sku: string; name: string; price: number; stock: number }
const products: Product[] = [
{ sku: "A1", name: "Portfolio template", price: 49, stock: 40 },
{ sku: "A2", name: "Blocks bundle", price: 79, stock: 32 },
{ sku: "B1", name: "Icon pack", price: 19, stock: 6 },
{ sku: "B2", name: "Founding member license", price: 199, stock: 0 },
{ sku: "C1", name: "Logo pack", price: 29, stock: 18 },
]
export function ProductQuickAdd() {
const [cart, setCart] = React.useState<Product[]>([])
return (
<div className="w-full max-w-xs space-y-3 border p-3">
<Combobox
items={products}
value={null}
itemToStringLabel={(product: Product) => product.name}
onValueChange={(product) =>
product && setCart((prev) => [...prev, product])
}
>
<ComboboxInput
placeholder="Add item to order"
className="w-full"
showTrigger={false}
>
<InputGroupAddon>
<ScanBarcodeIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No products found.</ComboboxEmpty>
<ComboboxList>
{(product: Product) => (
<ComboboxItem
key={product.sku}
value={product}
disabled={product.stock === 0}
>
<span className="flex-1">{product.name}</span>
<span className="text-[11px] text-muted-foreground">
{product.stock === 0
? "Sold out"
: "$" + product.price.toFixed(2)}
</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<ul className="space-y-1 text-sm">
{cart.length === 0 && (
<li className="text-xs text-muted-foreground">No items yet.</li>
)}
{cart.map((item, index) => (
<li key={index} className="flex justify-between">
<span>{item.name}</span>
<span>${item.price.toFixed(2)}</span>
</li>
))}
</ul>
<div className="flex justify-between border-t pt-2 text-sm font-semibold">
<span>Total</span>
<span>
${cart.reduce((sum, item) => sum + item.price, 0).toFixed(2)}
</span>
</div>
</div>
)
}
combobox-24
Loading...
"use client"
import * as React from "react"
import {
Type as TypeIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
type Font = { name: string; stack: string; category: string }
const fonts: Font[] = [
{
name: "System Sans",
stack: "ui-sans-serif, system-ui, sans-serif",
category: "Sans",
},
{ name: "Georgia", stack: "Georgia, serif", category: "Serif" },
{
name: "Palatino",
stack: "Palatino, 'Book Antiqua', serif",
category: "Serif",
},
{ name: "Courier", stack: "'Courier New', monospace", category: "Mono" },
{ name: "Trebuchet", stack: "'Trebuchet MS', sans-serif", category: "Sans" },
]
export function FontFamilyPicker() {
const [font, setFont] = React.useState<Font | null>(fonts[1]!)
return (
<div className="w-full max-w-xs space-y-3">
<Combobox
items={fonts}
value={font}
onValueChange={setFont}
itemToStringLabel={(f: Font) => f.name}
>
<ComboboxInput placeholder="Font family" className="w-full">
<InputGroupAddon>
<TypeIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No fonts found.</ComboboxEmpty>
<ComboboxList>
{(f: Font) => (
<ComboboxItem key={f.name} value={f}>
<span
className="flex-1 text-sm"
style={{ fontFamily: f.stack }}
>
{f.name}
</span>
<span className="text-[11px] text-muted-foreground">
{f.category}
</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<p className="border p-3 text-lg" style={{ fontFamily: font?.stack }}>
The quick brown fox jumps over the lazy dog.
</p>
</div>
)
}
combobox-25
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { Field, FieldLabel } from "@/components/ui/field"
import { InputGroupAddon } from "@/components/ui/input-group"
import { cn } from "@/lib/utils"
type Token = { name: string; className: string }
const tokens: Token[] = [
{ name: "slate-900", className: "bg-foreground" },
{ name: "indigo-600", className: "bg-chart-2" },
{ name: "emerald-500", className: "bg-primary" },
{ name: "amber-400", className: "bg-primary" },
{ name: "rose-500", className: "bg-primary" },
{ name: "sky-400", className: "bg-primary" },
]
export function BrandColorToken() {
const [token, setToken] = React.useState<Token | null>(tokens[1]!)
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="accent">Accent colour</FieldLabel>
<Combobox
items={tokens}
value={token}
onValueChange={setToken}
itemToStringLabel={(t: Token) => t.name}
>
<ComboboxInput id="accent" className="w-full font-sans">
<InputGroupAddon>
<span
className={cn(
"size-4 border",
token?.className ?? "bg-transparent"
)}
/>
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No tokens found.</ComboboxEmpty>
<ComboboxList>
{(t: Token) => (
<ComboboxItem key={t.name} value={t} className="font-sans">
<span className={cn("size-4 border", t.className)} />
{t.name}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</Field>
)
}
combobox-26
Loading...
"use client"
import * as React from "react"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { Field, FieldLabel } from "@/components/ui/field"
const cities = [
"Amsterdam",
"Barcelona",
"Copenhagen",
"Lisbon",
"Prague",
"Vienna",
]
export function NativeFormSubmission() {
const [result, setResult] = React.useState<string | null>(null)
return (
<form
className="flex w-full max-w-xs flex-col gap-3"
onSubmit={(event) => {
event.preventDefault()
const data = new FormData(event.currentTarget)
setResult(String(data.get("city") || "(empty)"))
}}
>
<Field>
<FieldLabel htmlFor="city">Office location</FieldLabel>
<Combobox items={cities} name="city" defaultValue="Lisbon">
<ComboboxInput id="city" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No cities found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</Field>
<Button type="submit" variant="secondary">
Submit
</Button>
{result && (
<code className="bg-muted px-2 py-1.5 text-xs">city = {result}</code>
)}
</form>
)
}
combobox-27
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
const regions: Record<string, string[]> = {
"United States": ["California", "New York", "Texas", "Washington"],
Canada: ["British Columbia", "Ontario", "Quebec"],
Australia: ["New South Wales", "Queensland", "Victoria"],
}
const countries = Object.keys(regions)
export function CountryStateCascade() {
const [country, setCountry] = React.useState<string | null>(null)
const [state, setState] = React.useState<string | null>(null)
const states = country ? regions[country]! : []
return (
<FieldGroup className="w-full max-w-xs gap-3">
<Field>
<FieldLabel>Country</FieldLabel>
<Combobox
items={countries}
value={country}
onValueChange={(next) => {
setCountry(next)
setState(null)
}}
>
<ComboboxInput placeholder="Select country" className="w-full" />
<ComboboxContent>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</Field>
<Field>
<FieldLabel>State / province</FieldLabel>
<Combobox
key={country ?? "none"}
items={states}
value={state}
onValueChange={setState}
disabled={!country}
>
<ComboboxInput
placeholder={country ? "Select region" : "Choose a country first"}
disabled={!country}
className="w-full"
/>
<ComboboxContent>
<ComboboxEmpty>No regions found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</Field>
</FieldGroup>
)
}
combobox-28
Loading...
"use client"
import {
GitBranch as GitBranchIcon,
} from "@designali/icons"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
ComboboxValue,
} from "@/components/ui/combobox"
type Branch = { name: string; updated: string; isDefault?: boolean }
const branches: Branch[] = [
{ name: "main", updated: "2h ago", isDefault: true },
{ name: "feat/billing-portal", updated: "20m ago" },
{ name: "fix/date-picker-tz", updated: "1d ago" },
{ name: "chore/upgrade-deps", updated: "3d ago" },
]
export function GitBranchSwitcher() {
return (
<Combobox
items={branches}
defaultValue={branches[1]}
itemToStringLabel={(branch: Branch) => branch.name}
>
<ComboboxTrigger
render={
<Button
variant="outline"
size="sm"
className="w-56 justify-between font-sans"
/>
}
>
<span className="flex min-w-0 items-center gap-1.5">
<GitBranchIcon />
<span className="truncate">
<ComboboxValue />
</span>
</span>
</ComboboxTrigger>
<ComboboxContent className="w-64">
<ComboboxInput showTrigger={false} placeholder="Find a branch" />
<ComboboxEmpty>No branches found.</ComboboxEmpty>
<ComboboxList>
{(branch: Branch) => (
<ComboboxItem key={branch.name} value={branch}>
<span className="flex-1 truncate font-sans">{branch.name}</span>
{branch.isDefault ? (
<Badge variant="secondary" className="h-4 px-1 text-[10px]">
default
</Badge>
) : (
<span className="text-[11px] text-muted-foreground">
{branch.updated}
</span>
)}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
combobox-29
Loading...
"use client"
import * as React from "react"
import {
Plus as PlusIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
} from "@/components/ui/combobox"
import { cn } from "@/lib/utils"
type Workspace = { id: string; name: string; plan: string; gradient: string }
const workspaces: Workspace[] = [
{
id: "w1",
name: "Designali",
plan: "Business",
gradient: "from-primary to-chart-2",
},
{
id: "w2",
name: "Dalim Works",
plan: "Team",
gradient: "from-primary to-chart-2",
},
{
id: "w3",
name: "Side projects",
plan: "Free",
gradient: "from-primary to-primary",
},
]
function Monogram({ workspace }: { workspace: Workspace }) {
return (
<span
className={cn(
"flex size-5 shrink-0 items-center justify-center bg-gradient-to-br text-[10px] font-bold text-white",
workspace.gradient
)}
>
{workspace.name[0]}
</span>
)
}
export function WorkspaceSwitcher() {
const [current, setCurrent] = React.useState<Workspace | null>(workspaces[0]!)
return (
<Combobox
items={workspaces}
value={current}
onValueChange={setCurrent}
itemToStringLabel={(w: Workspace) => w.name}
>
<ComboboxTrigger
render={
<Button variant="ghost" className="w-56 justify-between px-2" />
}
>
<span className="flex items-center gap-2">
{current && <Monogram workspace={current} />}
<span className="truncate font-semibold">
{current?.name ?? "Select workspace"}
</span>
</span>
</ComboboxTrigger>
<ComboboxContent className="w-60">
<ComboboxInput showTrigger={false} placeholder="Switch workspace" />
<ComboboxEmpty>No workspaces found.</ComboboxEmpty>
<ComboboxList>
{(w: Workspace) => (
<ComboboxItem key={w.id} value={w}>
<Monogram workspace={w} />
<span className="flex-1">{w.name}</span>
<span className="text-[11px] text-muted-foreground">
{w.plan}
</span>
</ComboboxItem>
)}
</ComboboxList>
<div className="border-t p-1">
<Button variant="ghost" size="sm" className="w-full justify-start">
<PlusIcon />
Create workspace
</Button>
</div>
</ComboboxContent>
</Combobox>
)
}
combobox-30
Loading...
"use client"
import * as React from "react"
import {
CircleCheck as CircleCheckIcon,
CircleDashed as CircleDashedIcon,
CircleDot as CircleDotIcon,
Circle as CircleIcon,
CircleX as CircleXIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
} from "@/components/ui/combobox"
const statuses = [
{
value: "backlog",
label: "Backlog",
icon: CircleDashedIcon,
color: "text-muted-foreground",
},
{ value: "todo", label: "Todo", icon: CircleIcon, color: "text-foreground" },
{
value: "progress",
label: "In progress",
icon: CircleDotIcon,
color: "text-primary",
},
{
value: "done",
label: "Done",
icon: CircleCheckIcon,
color: "text-primary",
},
{
value: "canceled",
label: "Canceled",
icon: CircleXIcon,
color: "text-muted-foreground",
},
]
type Status = (typeof statuses)[number]
export function IssueStatusPicker() {
const [status, setStatus] = React.useState<Status | null>(statuses[2]!)
return (
<div className="flex w-full max-w-sm items-center gap-3 border p-3">
<span className="font-sans text-xs text-muted-foreground">ENG-412</span>
<span className="flex-1 truncate text-sm">
Retry failed webhook deliveries
</span>
<Combobox
items={statuses}
value={status}
onValueChange={setStatus}
itemToStringLabel={(s: Status) => s.label}
>
<ComboboxTrigger render={<Button variant="outline" size="xs" />}>
{status && <status.icon className={status.color} />}
{status?.label ?? "Status"}
</ComboboxTrigger>
<ComboboxContent className="w-44">
<ComboboxInput showTrigger={false} placeholder="Change status" />
<ComboboxList>
{(s: Status) => (
<ComboboxItem key={s.value} value={s}>
<s.icon className={s.color} />
{s.label}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-31
Loading...
"use client"
import * as React from "react"
import {
CircleAlert as CircleAlertIcon,
Minus as MinusIcon,
SignalHigh as SignalHighIcon,
SignalLow as SignalLowIcon,
SignalMedium as SignalMediumIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
} from "@/components/ui/combobox"
const priorities = [
{ value: "urgent", label: "Urgent", icon: CircleAlertIcon },
{ value: "high", label: "High", icon: SignalHighIcon },
{ value: "medium", label: "Medium", icon: SignalMediumIcon },
{ value: "low", label: "Low", icon: SignalLowIcon },
]
type Priority = (typeof priorities)[number]
const issues = [
{ id: "DES-88", title: "Empty state for search", priority: priorities[1]! },
{ id: "DES-91", title: "Dark mode chart colours", priority: priorities[2]! },
{
id: "DES-93",
title: "Broken focus ring on tabs",
priority: priorities[0]!,
},
]
function PriorityCell({ initial }: { initial: Priority }) {
const [value, setValue] = React.useState<Priority | null>(initial)
return (
<Combobox
items={priorities}
value={value}
onValueChange={setValue}
itemToStringLabel={(p: Priority) => p.label}
>
<ComboboxTrigger
render={
<Button
variant="ghost"
size="icon-sm"
aria-label={"Priority: " + (value?.label ?? "none")}
className="[&>svg:last-child]:hidden"
/>
}
>
{value ? <value.icon /> : <MinusIcon />}
</ComboboxTrigger>
<ComboboxContent className="w-40">
<ComboboxList>
{(p: Priority) => (
<ComboboxItem key={p.value} value={p}>
<p.icon />
{p.label}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
export function PriorityIconOnly() {
return (
<ul className="w-full max-w-sm divide-y border">
{issues.map((issue) => (
<li key={issue.id} className="flex items-center gap-2 px-2 py-1">
<PriorityCell initial={issue.priority} />
<span className="font-sans text-xs text-muted-foreground">
{issue.id}
</span>
<span className="truncate text-sm">{issue.title}</span>
</li>
))}
</ul>
)
}
combobox-32
Loading...
"use client"
import * as React from "react"
import {
ArrowUpDown as ArrowUpDownIcon,
PlaneLanding as PlaneLandingIcon,
PlaneTakeoff as PlaneTakeoffIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
type Airport = { code: string; city: string }
const airports: Airport[] = [
{ code: "LHR", city: "London Heathrow" },
{ code: "CDG", city: "Paris Charles de Gaulle" },
{ code: "JFK", city: "New York JFK" },
{ code: "LIS", city: "Lisbon" },
{ code: "HND", city: "Tokyo Haneda" },
{ code: "SIN", city: "Singapore Changi" },
]
function AirportField({
label,
icon,
value,
onChange,
}: {
label: string
icon: React.ReactNode
value: Airport | null
onChange: (a: Airport | null) => void
}) {
return (
<Combobox
items={airports}
value={value}
onValueChange={onChange}
itemToStringLabel={(a: Airport) => a.code + " · " + a.city}
>
<ComboboxInput
placeholder={label}
aria-label={label}
className="w-full"
showTrigger={false}
>
<InputGroupAddon>{icon}</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No airports found.</ComboboxEmpty>
<ComboboxList>
{(a: Airport) => (
<ComboboxItem key={a.code} value={a}>
<span className="w-9 font-sans font-semibold">{a.code}</span>
{a.city}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
export function FlightRouteSearch() {
const [from, setFrom] = React.useState<Airport | null>(airports[3]!)
const [to, setTo] = React.useState<Airport | null>(null)
return (
<div className="flex w-full max-w-sm flex-col gap-2">
<AirportField
label="From"
icon={<PlaneTakeoffIcon />}
value={from}
onChange={setFrom}
/>
<div className="flex justify-center">
<Button
variant="outline"
size="icon-sm"
aria-label="Swap airports"
onClick={() => {
setFrom(to)
setTo(from)
}}
>
<ArrowUpDownIcon />
</Button>
</div>
<AirportField
label="To"
icon={<PlaneLandingIcon />}
value={to}
onChange={setTo}
/>
<Button className="mt-1" disabled={!from || !to}>
Search flights
</Button>
</div>
)
}
combobox-33
Loading...
"use client"
import * as React from "react"
import {
Bell as BellIcon,
Camera as CameraIcon,
Gift as GiftIcon,
Heart as HeartIcon,
Leaf as LeafIcon,
Rocket as RocketIcon,
Shapes as ShapesIcon,
Star as StarIcon,
Zap as ZapIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const icons = [
{ name: "Heart", icon: HeartIcon },
{ name: "Star", icon: StarIcon },
{ name: "Bell", icon: BellIcon },
{ name: "Camera", icon: CameraIcon },
{ name: "Zap", icon: ZapIcon },
{ name: "Rocket", icon: RocketIcon },
{ name: "Leaf", icon: LeafIcon },
{ name: "Gift", icon: GiftIcon },
]
type IconOption = (typeof icons)[number]
export function IconPickerSearch() {
const [value, setValue] = React.useState<IconOption | null>(icons[5]!)
return (
<div className="flex w-full max-w-xs items-center gap-3">
<div className="flex size-10 shrink-0 items-center justify-center border bg-muted">
{value ? (
<value.icon className="size-5" />
) : (
<ShapesIcon className="size-5 text-muted-foreground" />
)}
</div>
<Combobox
items={icons}
value={value}
onValueChange={setValue}
itemToStringLabel={(o: IconOption) => o.name}
>
<ComboboxInput placeholder="Search icons" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No icons found.</ComboboxEmpty>
<ComboboxList>
{(o: IconOption) => (
<ComboboxItem key={o.name} value={o}>
<o.icon />
{o.name}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-34
Loading...
"use client"
import * as React from "react"
import {
Calendar as CalendarIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Card,
CardAction,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Combobox,
ComboboxContent,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
ComboboxValue,
} from "@/components/ui/combobox"
const presets = [
"Today",
"Yesterday",
"Last 7 days",
"Last 30 days",
"This quarter",
"Year to date",
]
const visitors: Record<string, string> = {
Today: "1,204",
Yesterday: "1,388",
"Last 7 days": "9,870",
"Last 30 days": "41,312",
"This quarter": "96,540",
"Year to date": "402,118",
}
export function DashboardDatePresets() {
const [range, setRange] = React.useState<string | null>("Last 7 days")
return (
<Card className="w-full max-w-xs" size="sm">
<CardHeader>
<CardDescription>Unique visitors</CardDescription>
<CardTitle className="text-2xl">
{range ? visitors[range] : "-"}
</CardTitle>
<CardAction>
<Combobox items={presets} value={range} onValueChange={setRange}>
<ComboboxTrigger render={<Button variant="outline" size="xs" />}>
<CalendarIcon />
<ComboboxValue />
</ComboboxTrigger>
<ComboboxContent className="w-40" align="end">
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</CardAction>
</CardHeader>
</Card>
)
}
combobox-35
Loading...
"use client"
import * as React from "react"
import {
Plus as PlusIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
import { Field, FieldLabel } from "@/components/ui/field"
const skills = [
"React",
"TypeScript",
"Figma",
"SQL",
"Python",
"Node.js",
"Copywriting",
"User research",
"GraphQL",
"Swift",
]
const suggested = ["TypeScript", "Figma", "SQL"]
export function SkillsWithSuggestions() {
const anchor = useComboboxAnchor()
const [value, setValue] = React.useState<string[]>(["React"])
return (
<Field className="w-full max-w-sm">
<FieldLabel>What are you good at?</FieldLabel>
<Combobox multiple items={skills} value={value} onValueChange={setValue}>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values: string[]) => (
<React.Fragment>
{values.map((skill) => (
<ComboboxChip key={skill}>{skill}</ComboboxChip>
))}
<ComboboxChipsInput placeholder="Search skills" />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No skills found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<div className="flex flex-wrap items-center gap-1.5">
<span className="text-xs text-muted-foreground">Suggested:</span>
{suggested
.filter((skill) => !value.includes(skill))
.map((skill) => (
<Button
key={skill}
variant="outline"
size="xs"
onClick={() => setValue((prev) => [...prev, skill])}
>
<PlusIcon />
{skill}
</Button>
))}
</div>
</Field>
)
}
combobox-36
Loading...
"use client"
import {
Lock as LockIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
import { InputGroupAddon } from "@/components/ui/input-group"
const owners = ["Ali Imam", "Sara", "Omar"]
export function ReadOnlyCombobox() {
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="owner">Account owner</FieldLabel>
<Combobox items={owners} defaultValue="Ali Imam" readOnly>
<ComboboxInput
id="owner"
readOnly
showTrigger={false}
className="w-full bg-muted/50"
>
<InputGroupAddon align="inline-end">
<LockIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription>
Set by your organisation's directory sync.
</FieldDescription>
</Field>
)
}
combobox-37
Loading...
"use client"
import * as React from "react"
import {
UserPlus as UserPlusIcon,
UserSearch as UserSearchIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const teammates = ["Ali Imam", "Bilal", "Chloe", "Diego"]
export function EmptyStateInvite() {
const [query, setQuery] = React.useState("")
return (
<div className="w-full max-w-xs">
<Combobox
items={teammates}
inputValue={query}
onInputValueChange={setQuery}
>
<ComboboxInput
placeholder="Add a reviewer (try 'zoe')"
className="w-full"
/>
<ComboboxContent>
<ComboboxEmpty className="flex-col items-center gap-2 py-4">
<UserSearchIcon className="size-5" />
<span>Nobody named "{query}" in this workspace.</span>
<Button size="xs" variant="outline">
<UserPlusIcon />
Invite by email
</Button>
</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-38
Loading...
"use client"
import * as React from "react"
import {
Send as SendIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
const people = [
"Ali Imam",
"Ben",
"Chen",
"Dara",
"Eva",
"Felix",
]
const roles = ["Can view", "Can comment", "Can edit"]
export function ShareDialogInvite() {
const anchor = useComboboxAnchor()
const [invitees, setInvitees] = React.useState<string[]>([])
return (
<Card className="w-full max-w-md" size="sm">
<CardHeader>
<CardTitle>Share "Designali brand guidelines"</CardTitle>
<CardDescription>
Invite people to collaborate on this doc.
</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-2 sm:flex-row">
<Combobox
multiple
items={people}
value={invitees}
onValueChange={setInvitees}
>
<ComboboxChips ref={anchor} className="flex-1">
<ComboboxValue>
{(values: string[]) => (
<React.Fragment>
{values.map((person) => (
<ComboboxChip key={person}>{person}</ComboboxChip>
))}
<ComboboxChipsInput
placeholder={values.length ? "" : "Add people"}
/>
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No people found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<Combobox items={roles} defaultValue="Can edit">
<ComboboxTrigger
render={
<Button
variant="outline"
className="justify-between font-normal sm:w-32"
/>
}
>
<ComboboxValue />
</ComboboxTrigger>
<ComboboxContent className="w-36" align="end">
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</CardContent>
<CardFooter className="justify-end">
<Button disabled={invitees.length === 0}>
<SendIcon data-icon="inline-start" />
Invite {invitees.length > 0 && invitees.length}
</Button>
</CardFooter>
</Card>
)
}
combobox-39
Loading...
"use client"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
import { Kbd } from "@/components/ui/kbd"
const pages = [
"Templates",
"Blocks",
"UI Designs",
"Icons",
"Logos",
"Pricing",
"Docs",
]
export function KeyboardHintFooter() {
return (
<div className="w-full max-w-xs">
<Combobox items={pages} autoHighlight>
<ComboboxInput
placeholder="Go to page..."
className="w-full"
showTrigger={false}
>
<InputGroupAddon align="inline-end">
<Kbd>⌘K</Kbd>
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No pages found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
<div className="flex items-center gap-3 border-t px-2 py-1.5 text-[11px] text-muted-foreground">
<span className="flex items-center gap-1">
<Kbd>↑</Kbd>
<Kbd>↓</Kbd>
navigate
</span>
<span className="flex items-center gap-1">
<Kbd>↵</Kbd>
open
</span>
<span className="flex items-center gap-1">
<Kbd>esc</Kbd>
close
</span>
</div>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-40
Loading...
"use client"
import * as React from "react"
import { Badge } from "@/components/ui/badge"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
const users = [
{ name: "Ali Imam", email: "ali@designali.com", role: "Owner" },
{ name: "Sara", email: "sara@designali.com", role: "Admin" },
{ name: "Omar", email: "omar@designali.com", role: "Member" },
{ name: "Nina", email: "nina@designali.com", role: "Member" },
{ name: "Client", email: "client@example.com", role: "Guest" },
]
const roles = ["Owner", "Admin", "Member", "Guest"]
export function AdminTableRoleFilter() {
const [role, setRole] = React.useState<string | null>(null)
const rows = role ? users.filter((user) => user.role === role) : users
return (
<div className="w-full max-w-md space-y-2">
<div className="flex items-center justify-between gap-2">
<span className="text-sm font-semibold">Members · {rows.length}</span>
<Combobox items={roles} value={role} onValueChange={setRole}>
<ComboboxInput placeholder="All roles" showClear className="w-36" />
<ComboboxContent>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
<div className="border">
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead className="text-right">Role</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((user) => (
<TableRow key={user.email}>
<TableCell>
<div className="font-medium">{user.name}</div>
<div className="text-xs text-muted-foreground">
{user.email}
</div>
</TableCell>
<TableCell className="text-right">
<Badge
variant={user.role === "Owner" ? "default" : "outline"}
>
{user.role}
</Badge>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
)
}
combobox-41
Loading...
"use client"
import {
BookOpen as BookOpenIcon,
CreditCard as CreditCardIcon,
Plug as PlugIcon,
Rocket as RocketIcon,
ShieldCheck as ShieldCheckIcon,
Wrench as WrenchIcon,
} from "@designali/icons"
import { Badge } from "@/components/ui/badge"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
type Category = { name: string; count: number; icon: typeof BookOpenIcon }
const categories: Category[] = [
{ name: "Getting started", count: 12, icon: RocketIcon },
{ name: "Billing & payments", count: 18, icon: CreditCardIcon },
{ name: "Integrations", count: 24, icon: PlugIcon },
{ name: "Security & privacy", count: 9, icon: ShieldCheckIcon },
{ name: "Troubleshooting", count: 31, icon: WrenchIcon },
]
export function HelpCenterCategoryCounts() {
return (
<div className="w-full max-w-xs space-y-2">
<p className="flex items-center gap-2 text-sm font-semibold">
<BookOpenIcon className="size-4" />
Browse articles
</p>
<Combobox items={categories} itemToStringLabel={(c: Category) => c.name}>
<ComboboxInput placeholder="Choose a category" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No categories found.</ComboboxEmpty>
<ComboboxList>
{(c: Category) => (
<ComboboxItem key={c.name} value={c}>
<c.icon className="text-muted-foreground" />
<span className="flex-1">{c.name}</span>
<Badge
variant="secondary"
className="h-4 px-1.5 text-[10px] tabular-nums"
>
{c.count}
</Badge>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-42
Loading...
"use client"
import * as React from "react"
import {
ListFilter as ListFilterIcon,
} from "@designali/icons"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
ComboboxTrigger,
} from "@/components/ui/combobox"
import { Separator } from "@/components/ui/separator"
const statuses = ["Draft", "Scheduled", "Published", "Archived", "Needs review"]
export function MultiSelectCountTrigger() {
const [value, setValue] = React.useState<string[]>(["Draft", "Needs review"])
return (
<div className="flex items-center gap-2">
<Combobox
multiple
items={statuses}
value={value}
onValueChange={setValue}
>
<ComboboxTrigger
render={
<Button variant="outline" size="sm" className="border-dashed" />
}
>
<ListFilterIcon />
Status
{value.length > 0 && (
<>
<Separator orientation="vertical" className="mx-1 h-4" />
<Badge variant="secondary" className="px-1">
{value.length} selected
</Badge>
</>
)}
</ComboboxTrigger>
<ComboboxContent className="w-48">
<ComboboxInput showTrigger={false} placeholder="Filter status" />
<ComboboxEmpty>No statuses.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
{value.length > 0 && (
<div className="border-t p-1">
<Button
variant="ghost"
size="xs"
className="w-full"
onClick={() => setValue([])}
>
Clear filters
</Button>
</div>
)}
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-43
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { cn } from "@/lib/utils"
type Theme = { name: string; bg: string; fg: string; accent: string }
const themes: Theme[] = [
{
name: "Paper",
bg: "bg-muted",
fg: "text-foreground",
accent: "bg-foreground",
},
{
name: "Midnight",
bg: "bg-foreground",
fg: "text-background",
accent: "bg-primary",
},
{
name: "Forest",
bg: "bg-chart-5",
fg: "text-chart-1",
accent: "bg-primary",
},
{
name: "Sunset",
bg: "bg-primary/10",
fg: "text-chart-5",
accent: "bg-primary",
},
]
export function HighlightedThemePreview() {
const [value, setValue] = React.useState<Theme | null>(themes[0]!)
const [preview, setPreview] = React.useState<Theme | undefined>(undefined)
const shown = preview ?? value ?? themes[0]!
return (
<div className="w-full max-w-xs space-y-3">
<div
className={cn(
"space-y-2 border p-4 transition-colors",
shown.bg,
shown.fg
)}
>
<p className="text-sm font-semibold">{shown.name}</p>
<p className="text-xs opacity-80">Your editor will look like this.</p>
<span className={cn("block h-1.5 w-16", shown.accent)} />
</div>
<Combobox
items={themes}
value={value}
onValueChange={setValue}
onItemHighlighted={(item) => setPreview(item)}
onOpenChange={(open) => !open && setPreview(undefined)}
itemToStringLabel={(t: Theme) => t.name}
>
<ComboboxInput placeholder="Choose theme" className="w-full" />
<ComboboxContent>
<ComboboxList>
{(t: Theme) => (
<ComboboxItem key={t.name} value={t}>
<span className={cn("size-4 border", t.bg)} />
{t.name}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
)
}
combobox-44
Loading...
"use client"
import * as React from "react"
import {
KeyRound as KeyRoundIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxChip,
ComboboxChips,
ComboboxChipsInput,
ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
ComboboxGroup,
ComboboxItem,
ComboboxLabel,
ComboboxList,
ComboboxValue,
useComboboxAnchor,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
const groups = [
{ label: "Invoices", items: ["invoices:read", "invoices:write"] },
{
label: "Customers",
items: ["customers:read", "customers:write", "customers:delete"],
},
{ label: "Webhooks", items: ["webhooks:read", "webhooks:manage"] },
]
export function GroupedScopesMulti() {
const anchor = useComboboxAnchor()
return (
<Field className="w-full max-w-sm">
<FieldLabel>Token scopes</FieldLabel>
<Combobox
multiple
items={groups}
defaultValue={["invoices:read", "customers:read"]}
>
<ComboboxChips ref={anchor}>
<ComboboxValue>
{(values: string[]) => (
<React.Fragment>
{values.map((scope) => (
<ComboboxChip key={scope} className="font-sans">
{scope}
</ComboboxChip>
))}
<ComboboxChipsInput placeholder="Add scope" />
</React.Fragment>
)}
</ComboboxValue>
</ComboboxChips>
<ComboboxContent anchor={anchor}>
<ComboboxEmpty>No scopes found.</ComboboxEmpty>
<ComboboxList>
{(group: (typeof groups)[number]) => (
<ComboboxGroup key={group.label} items={group.items}>
<ComboboxLabel>{group.label}</ComboboxLabel>
<ComboboxCollection>
{(scope: string) => (
<ComboboxItem
key={scope}
value={scope}
className="font-sans"
>
<KeyRoundIcon className="text-muted-foreground" />
{scope}
</ComboboxItem>
)}
</ComboboxCollection>
</ComboboxGroup>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription>
Grant only what this integration needs.
</FieldDescription>
</Field>
)
}
combobox-45
Loading...
"use client"
import * as React from "react"
import {
MapPin as MapPinIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
import { InputGroupAddon } from "@/components/ui/input-group"
type Address = { id: string; street: string; locality: string }
const addresses: Address[] = [
{ id: "1", street: "14 Harbour View Road", locality: "Brighton, BN2 1TL" },
{ id: "2", street: "14 Harrow Lane", locality: "Leeds, LS6 2QD" },
{ id: "3", street: "140 Harcourt Street", locality: "Dublin, D02 XY45" },
{ id: "4", street: "14A Hartfield Close", locality: "Bristol, BS7 9PE" },
]
export function AddressAutocomplete() {
const [address, setAddress] = React.useState<Address | null>(null)
return (
<Field className="w-full max-w-sm">
<FieldLabel htmlFor="address">Billing address for your Designali invoice</FieldLabel>
<Combobox
items={addresses}
value={address}
onValueChange={setAddress}
itemToStringLabel={(a: Address) => a.street + ", " + a.locality}
>
<ComboboxInput
id="address"
placeholder="Start typing your address"
showTrigger={false}
showClear
className="w-full"
>
<InputGroupAddon>
<MapPinIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No addresses found. Enter it manually.</ComboboxEmpty>
<ComboboxList>
{(a: Address) => (
<ComboboxItem key={a.id} value={a}>
<MapPinIcon className="text-muted-foreground" />
<div className="flex flex-col">
<span>{a.street}</span>
<span className="text-[11px] text-muted-foreground">
{a.locality}
</span>
</div>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
{address && (
<FieldDescription>
Estimated delivery: Tuesday, 18 November
</FieldDescription>
)}
</Field>
)
}
combobox-46
Loading...
"use client"
import {
Clock as ClockIcon,
Users as UsersIcon,
} from "@designali/icons"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxCollection,
ComboboxContent,
ComboboxEmpty,
ComboboxGroup,
ComboboxInput,
ComboboxItem,
ComboboxLabel,
ComboboxList,
ComboboxSeparator,
} from "@/components/ui/combobox"
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupText,
} from "@/components/ui/input-group"
const groups = [
{ label: "Recent", items: ["Ali Imam", "Julia"] },
{
label: "All contacts",
items: [
"Aiko",
"Bruno",
"Ali Imam",
"Julia",
"Marta",
"Sean",
],
},
]
export function RecentContactsGroup() {
return (
<div className="w-full max-w-xs space-y-3 border p-4">
<p className="text-sm font-semibold">Send money</p>
<Combobox items={groups}>
<ComboboxInput placeholder="Recipient name" className="w-full" />
<ComboboxContent>
<ComboboxEmpty>No contacts found.</ComboboxEmpty>
<ComboboxList>
{(group: (typeof groups)[number], index: number) => (
<ComboboxGroup key={group.label} items={group.items}>
<ComboboxLabel className="flex items-center gap-1.5">
{index === 0 ? (
<ClockIcon className="size-3" />
) : (
<UsersIcon className="size-3" />
)}
{group.label}
</ComboboxLabel>
<ComboboxCollection>
{(name: string) => (
<ComboboxItem key={group.label + name} value={name}>
<Avatar size="sm">
<AvatarFallback>
{name
.split(" ")
.map((p) => p[0])
.join("")}
</AvatarFallback>
</Avatar>
{name}
</ComboboxItem>
)}
</ComboboxCollection>
{index === 0 && <ComboboxSeparator className="my-1" />}
</ComboboxGroup>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<InputGroup>
<InputGroupAddon>
<InputGroupText>$</InputGroupText>
</InputGroupAddon>
<InputGroupInput
placeholder="0.00"
inputMode="decimal"
aria-label="Amount"
/>
</InputGroup>
<Button className="w-full">Continue</Button>
</div>
)
}
combobox-47
Loading...
"use client"
import * as React from "react"
import {
Hash as HashIcon,
MessageSquare as MessageSquareIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import { InputGroupAddon } from "@/components/ui/input-group"
const channels = [
"#general",
"#design-crit",
"#eng-platform",
"#launch-q4",
"#random",
"#support-escalations",
]
export function QuickJumpAutoHighlight() {
const [active, setActive] = React.useState("#general")
return (
<div className="w-full max-w-xs space-y-3">
<Combobox
items={channels}
autoHighlight
value={null}
onValueChange={(next) => next && setActive(next)}
>
<ComboboxInput
placeholder="Jump to channel"
className="w-full"
showTrigger={false}
>
<InputGroupAddon>
<HashIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No channels found.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<div className="flex items-center gap-2 border bg-muted/40 px-3 py-2 text-sm">
<MessageSquareIcon className="size-4 text-muted-foreground" />
Viewing <span className="font-medium">{active}</span>
</div>
</div>
)
}
combobox-48
Loading...
"use client"
import * as React from "react"
import {
Copy as CopyIcon,
} from "@designali/icons"
import { Button } from "@/components/ui/button"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const languages = [
"TypeScript",
"JavaScript",
"Python",
"Go",
"Rust",
"SQL",
"Bash",
"JSON",
]
export function CodeLanguageToolbar() {
const [lang, setLang] = React.useState<string | null>("TypeScript")
return (
<div className="w-full max-w-md border">
<div className="flex items-center gap-2 border-b bg-muted/40 px-2 py-1">
<span className="flex-1 font-sans text-xs text-muted-foreground">
snippet-01
</span>
<Combobox items={languages} value={lang} onValueChange={setLang}>
<ComboboxInput className="h-6 w-32 text-xs" aria-label="Language" />
<ComboboxContent>
<ComboboxEmpty>Unknown language.</ComboboxEmpty>
<ComboboxList>
{(item: string) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<Button variant="ghost" size="icon-xs" aria-label="Copy">
<CopyIcon />
</Button>
</div>
<pre className="overflow-x-auto p-3 font-mono text-xs leading-5">
{lang === "Python"
? "def greet(name):\n return f'Hello, {name}'"
: "export const greet = (name: string) =>\n 'Hello, ' + name"}
</pre>
</div>
)
}
combobox-49
Loading...
"use client"
import * as React from "react"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupText,
} from "@/components/ui/input-group"
type Currency = { code: string; symbol: string; name: string }
const currencies: Currency[] = [
{ code: "USD", symbol: "$", name: "US dollar" },
{ code: "EUR", symbol: "€", name: "Euro" },
{ code: "GBP", symbol: "£", name: "British pound" },
{ code: "JPY", symbol: "¥", name: "Japanese yen" },
{ code: "CHF", symbol: "Fr", name: "Swiss franc" },
]
export function CurrencyAmountInput() {
const [currency, setCurrency] = React.useState<Currency | null>(
currencies[1]!
)
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="amount">Amount</FieldLabel>
<div className="flex gap-2">
<InputGroup className="flex-1">
<InputGroupAddon>
<InputGroupText>{currency?.symbol ?? "?"}</InputGroupText>
</InputGroupAddon>
<InputGroupInput
id="amount"
defaultValue="250.00"
inputMode="decimal"
/>
</InputGroup>
<Combobox
items={currencies}
value={currency}
onValueChange={setCurrency}
itemToStringLabel={(c: Currency) => c.code}
>
<ComboboxInput className="w-24" aria-label="Currency" />
<ComboboxContent className="w-48" align="end">
<ComboboxEmpty>No currencies.</ComboboxEmpty>
<ComboboxList>
{(c: Currency) => (
<ComboboxItem key={c.code} value={c}>
<span className="w-5 text-center text-muted-foreground">
{c.symbol}
</span>
<span className="font-medium">{c.code}</span>
<span className="truncate text-muted-foreground">
{c.name}
</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
<FieldDescription>
Converted at today's mid-market rate.
</FieldDescription>
</Field>
)
}
combobox-50
Loading...
"use client"
import {
Languages as LanguagesIcon,
} from "@designali/icons"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/field"
import { InputGroupAddon } from "@/components/ui/input-group"
type Language = { code: string; english: string; native: string }
const languages: Language[] = [
{ code: "en", english: "English", native: "English" },
{ code: "es", english: "Spanish", native: "Español" },
{ code: "de", english: "German", native: "Deutsch" },
{ code: "ja", english: "Japanese", native: "日本語" },
{ code: "pt", english: "Portuguese", native: "Português" },
{ code: "ar", english: "Arabic", native: "العربية" },
]
export function LanguageNativeNames() {
return (
<Field className="w-full max-w-xs">
<FieldLabel htmlFor="language">Language</FieldLabel>
<Combobox
items={languages}
defaultValue={languages[0]}
itemToStringLabel={(l: Language) => l.native}
itemToStringValue={(l: Language) => l.code}
filter={(l: Language, query: string) =>
(l.english + " " + l.native)
.toLowerCase()
.includes(query.toLowerCase())
}
>
<ComboboxInput id="language" className="w-full">
<InputGroupAddon>
<LanguagesIcon />
</InputGroupAddon>
</ComboboxInput>
<ComboboxContent>
<ComboboxEmpty>No languages found.</ComboboxEmpty>
<ComboboxList>
{(l: Language) => (
<ComboboxItem key={l.code} value={l}>
<span className="flex-1">{l.native}</span>
<span className="text-[11px] text-muted-foreground">
{l.english}
</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
<FieldDescription>Search by English or native name.</FieldDescription>
</Field>
)
}
Categories
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Dialog
- Drawer
- Dropdown Menu
- Field
- Hover Card
- Input
- Input OTP
- Label
- Menubar
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip