choicebox
kibo-ui-registry/choiceboxFreeComponent
Choiceboxes are a great way to show radio or checkbox options with a card style.
Live preview
live · rendered by the registry
Rendered by Kibo UI Registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.kibo-ui.com/r/choicebox.jsonSource
1"use client";23import {4 RadioGroup,5 RadioGroupItem,6} from "@repo/shadcn-ui/components/ui/radio-group";7import { cn } from "@repo/shadcn-ui/lib/utils";8import {9 type ComponentProps,10 createContext,11 type HTMLAttributes,12 useContext,13} from "react";14import {15 Field,16 FieldContent,17 FieldDescription,18 FieldLabel,19 FieldTitle,20} from "@/components/ui/field";2122export type ChoiceboxProps = ComponentProps<typeof RadioGroup>;2324export const Choicebox = ({ className, ...props }: ChoiceboxProps) => (25 <RadioGroup className={cn("w-full", className)} {...props} />26);2728type ChoiceboxItemContextValue = {29 value: ChoiceboxItemProps["value"];30 id?: ChoiceboxItemProps["id"];31};3233const ChoiceboxItemContext = createContext<ChoiceboxItemContextValue | null>(34 null35);3637const useChoiceboxItemContext = () => {38 const context = useContext(ChoiceboxItemContext);3940 if (!context) {41 throw new Error(42 "useChoiceboxItemContext must be used within a ChoiceboxItem"43 );44 }4546 return context;47};4849export type ChoiceboxItemProps = ComponentProps<typeof RadioGroupItem>;5051export const ChoiceboxItem = ({52 className,53 children,54 value,55 id,56}: ChoiceboxItemProps) => (57 <ChoiceboxItemContext.Provider value={{ value, id }}>58 <FieldLabel htmlFor={id}>59 <Field className={className} orientation="horizontal">60 {children}61 </Field>62 </FieldLabel>63 </ChoiceboxItemContext.Provider>64);6566export type ChoiceboxItemHeaderProps = ComponentProps<typeof FieldContent>;6768export const ChoiceboxItemHeader = ({69 className,70 ...props71}: ChoiceboxItemHeaderProps) => (72 <FieldContent className={className} {...props} />73);7475export type ChoiceboxItemTitleProps = ComponentProps<typeof FieldTitle>;7677export const ChoiceboxItemTitle = ({78 className,79 ...props80}: ChoiceboxItemTitleProps) => <FieldTitle className={className} {...props} />;8182export type ChoiceboxItemSubtitleProps = HTMLAttributes<HTMLSpanElement>;8384export const ChoiceboxItemSubtitle = ({85 className,86 ...props87}: ChoiceboxItemSubtitleProps) => (88 <span89 className={cn("font-normal text-muted-foreground text-xs", className)}90 {...props}91 />92);9394export type ChoiceboxItemDescriptionProps = ComponentProps<95 typeof FieldDescription96>;9798export const ChoiceboxItemDescription = ({99 className,100 ...props101}: ChoiceboxItemDescriptionProps) => (102 <FieldDescription className={className} {...props} />103);104105export type ChoiceboxIndicatorProps = Partial<106 ComponentProps<typeof RadioGroupItem>107>;108109// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Kibo UI Registry
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| announcementannouncement | Kibo UI Registry | Components | Free | no deps | |
| avatar-stackavatar-stack | Kibo UI Registry | Components | Free | no deps | |
| bannerbanner | Kibo UI Registry | Components | Free | 2 deps | |
| calendarcalendar | Kibo UI Registry | Components | Free | 3 deps | |
| code-blockcode-block | Kibo UI Registry | Components | Free | 5 deps · 2 files | |
| color-pickercolor-picker | Kibo UI Registry | Components | Free | 3 deps | |
| comboboxcombobox | Kibo UI Registry | Components | Free | 2 deps | |
| comparisoncomparison | Kibo UI Registry | Components | Free | 2 deps |
