@@ -161,9 +161,9 @@ export function ComponentPreview() {
161161 switch ( name ) {
162162 case 'accordion' : {
163163 const type = ( validProps . type as string ) ?? 'single' ;
164- const collapsible = ( validProps . collapsible as boolean ) ?? true ;
164+ // Avoid passing ` collapsible` to DOM to prevent React warning; Radix handles it when type="single"
165165 return (
166- < Accordion type = { type as 'single' | 'multiple' } collapsible = { collapsible } className = " w-full max-w-md" >
166+ < Accordion type = { type as 'single' | 'multiple' } className = { ( validProps . className as string ) ?? ' w-full max-w-md' } >
167167 < AccordionItem value = "item-1" >
168168 < AccordionTrigger > Is it accessible?</ AccordionTrigger >
169169 < AccordionContent >
@@ -196,7 +196,7 @@ export function ComponentPreview() {
196196 }
197197 case 'table' : {
198198 return (
199- < Table className = " w-full max-w-2xl" >
199+ < Table className = { ( validProps . className as string ) ?? ' w-full max-w-2xl' } >
200200 < TableHeader >
201201 < TableRow >
202202 < TableHead > Invoice</ TableHead >
@@ -225,7 +225,7 @@ export function ComponentPreview() {
225225 case 'radio-group' : {
226226 const defaultValue = ( validProps . defaultValue as string ) ?? 'option-one' ;
227227 return (
228- < RadioGroup defaultValue = { defaultValue } className = " space-y-2" >
228+ < RadioGroup defaultValue = { defaultValue } className = { ( validProps . className as string ) ?? ' space-y-2' } >
229229 < div className = "flex items-center space-x-2" >
230230 < RadioGroupItem value = "option-one" id = "option-one" />
231231 < Label htmlFor = "option-one" > Option One</ Label >
@@ -242,7 +242,7 @@ export function ComponentPreview() {
242242 const disabled = ( validProps . disabled as boolean ) ?? false ;
243243 return (
244244 < Select disabled = { disabled } >
245- < SelectTrigger className = " w-[240px]" >
245+ < SelectTrigger className = { ( validProps . className as string ) ?? ' w-[240px]' } >
246246 < SelectValue placeholder = { placeholder } />
247247 </ SelectTrigger >
248248 < SelectContent >
@@ -256,7 +256,7 @@ export function ComponentPreview() {
256256 case 'tabs' : {
257257 const defaultValue = ( validProps . defaultValue as string ) ?? 'tab1' ;
258258 return (
259- < Tabs defaultValue = { defaultValue } className = " w-[400px]" >
259+ < Tabs defaultValue = { defaultValue } className = { ( validProps . className as string ) ?? ' w-[400px]' } >
260260 < TabsList >
261261 < TabsTrigger value = "tab1" > Tab 1</ TabsTrigger >
262262 < TabsTrigger value = "tab2" > Tab 2</ TabsTrigger >
@@ -279,7 +279,7 @@ export function ComponentPreview() {
279279 return (
280280 < div className = "w-full max-w-md" >
281281 < p className = "mb-2" > Section A</ p >
282- < Separator orientation = { orientation as 'horizontal' | 'vertical' } />
282+ < Separator orientation = { orientation as 'horizontal' | 'vertical' } className = { ( validProps . className as string ) ?? '' } />
283283 < p className = "mt-2" > Section B</ p >
284284 </ div >
285285 ) ;
@@ -295,7 +295,7 @@ export function ComponentPreview() {
295295 case 'resizable' : {
296296 const leftSize = ( validProps . defaultSize as number ) ?? 50 ;
297297 return (
298- < ResizablePanelGroup direction = "horizontal" className = " w-[500px]" >
298+ < ResizablePanelGroup direction = "horizontal" className = { ( validProps . className as string ) ?? ' w-[500px]' } >
299299 < ResizablePanel defaultSize = { leftSize } >
300300 < div className = "flex h-[200px] items-center justify-center p-6" >
301301 < span className = "font-semibold" > Panel 1</ span >
@@ -326,7 +326,7 @@ export function ComponentPreview() {
326326 case 'alert' : {
327327 const variant = ( validProps . variant as string ) ?? 'default' ;
328328 return (
329- < Alert variant = { variant as 'default' | 'destructive' } className = " w-full max-w-md" >
329+ < Alert variant = { variant as 'default' | 'destructive' } className = { ( validProps . className as string ) ?? ' w-full max-w-md' } >
330330 < AlertTitle > Heads up!</ AlertTitle >
331331 < AlertDescription >
332332 You can add components to your app using the cli.
@@ -337,29 +337,29 @@ export function ComponentPreview() {
337337 case 'checkbox' : {
338338 const checked = ( validProps . checked as boolean ) ?? false ;
339339 const disabled = ( validProps . disabled as boolean ) ?? false ;
340- return < Checkbox checked = { checked } disabled = { disabled } /> ;
340+ return < Checkbox checked = { checked } disabled = { disabled } className = { ( validProps . className as string ) ?? '' } /> ;
341341 }
342342 case 'switch' : {
343343 const checked = ( validProps . checked as boolean ) ?? false ;
344344 const disabled = ( validProps . disabled as boolean ) ?? false ;
345- return < Switch checked = { checked } disabled = { disabled } /> ;
345+ return < Switch checked = { checked } disabled = { disabled } className = { ( validProps . className as string ) ?? '' } /> ;
346346 }
347347 case 'textarea' : {
348348 const placeholder = ( validProps . placeholder as string ) ?? 'Enter your message...' ;
349349 const disabled = ( validProps . disabled as boolean ) ?? false ;
350350 const rows = ( validProps . rows as number ) ?? 4 ;
351- return < Textarea placeholder = { placeholder } disabled = { disabled } rows = { rows } className = " w-[350px]" /> ;
351+ return < Textarea placeholder = { placeholder } disabled = { disabled } rows = { rows } className = { ( validProps . className as string ) ?? ' w-[350px]' } /> ;
352352 }
353353 case 'input' : {
354354 const type = ( validProps . type as string ) ?? 'text' ;
355355 const placeholder = ( validProps . placeholder as string ) ?? 'Enter text...' ;
356356 const disabled = ( validProps . disabled as boolean ) ?? false ;
357- return < Input type = { type } placeholder = { placeholder } disabled = { disabled } className = " w-[280px]" /> ;
357+ return < Input type = { type } placeholder = { placeholder } disabled = { disabled } className = { ( validProps . className as string ) ?? ' w-[280px]' } /> ;
358358 }
359359 case 'badge' : {
360360 const variant = ( validProps . variant as string ) ?? 'default' ;
361361 const children = ( validProps . children as string ) ?? 'Badge' ;
362- return < BadgeComponent variant = { variant as 'default' | 'secondary' | 'destructive' | 'outline' } > { children } </ BadgeComponent > ;
362+ return < BadgeComponent variant = { variant as 'default' | 'secondary' | 'destructive' | 'outline' } className = { ( validProps . className as string ) ?? '' } > { children } </ BadgeComponent > ;
363363 }
364364 case 'button' : {
365365 const variant = ( validProps . variant as string ) ?? 'default' ;
@@ -371,6 +371,7 @@ export function ComponentPreview() {
371371 variant = { variant as import ( 'class-variance-authority' ) . VariantProps < typeof buttonVariants > [ 'variant' ] }
372372 size = { size as import ( 'class-variance-authority' ) . VariantProps < typeof buttonVariants > [ 'size' ] }
373373 disabled = { disabled }
374+ className = { ( validProps . className as string ) ?? '' }
374375 >
375376 { children }
376377 </ Button >
0 commit comments