Skip to content

DateField docs does not merge className prop correctly #10013

@jeremy-code

Description

@jeremy-code

🙋 Documentation Request

Consider the following bit of code for the Tailwind CSS docs on DateField:

<AriaDateInput className={renderProps => fieldGroupStyles({...renderProps, class: 'inline min-w-[150px] px-3 h-9 text-sm leading-8.5 font-sans cursor-text disabled:cursor-default whitespace-nowrap overflow-x-auto [scrollbar-width:none]'})} {...props}>

export function DateInput(props: Omit<DateInputProps, 'children'>) {
  return (
    <AriaDateInput className={renderProps => fieldGroupStyles({...renderProps, class: 'inline min-w-[150px] px-3 h-9 text-sm leading-8.5 font-sans cursor-text disabled:cursor-default whitespace-nowrap overflow-x-auto [scrollbar-width:none]'})} {...props}>
...

Since className is used to set fieldGroupStyles and {...props} follows it, the className will be overwritten if set on DateInput. Setting the classname for Dateinput is shown in DatePicker: https://react-aria.adobe.com/DatePicker

I think the change to fix this would be something like:

export function DateInput(props: Omit<DateInputProps, 'children'>) {
  return (
    <AriaDateInput {...props} className={composeRenderProps(props.className, (className, renderProps) => fieldGroupStyles({...renderProps, class: cn('inline min-w-[150px] px-3 h-9 text-sm leading-8.5 font-sans cursor-text disabled:cursor-default whitespace-nowrap overflow-x-auto [scrollbar-width:none]', className) }) )}>
...

or just to make a new variant in tailwind-variants that extends fieldGroupStyles

🧢 Your Company/Team

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions