-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7066 from gcko/feature/issue-7042
fix: #7042 Add Tailwind styling for IconField
- Loading branch information
Showing
8 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { DocSectionCode } from '@/components/doc/common/docsectioncode'; | ||
import { DocSectionText } from '@/components/doc/common/docsectiontext'; | ||
import Link from 'next/link'; | ||
|
||
export function TailwindDoc(props) { | ||
const code = { | ||
basic: ` | ||
const Tailwind = { | ||
iconfield: { | ||
root: { | ||
className: classNames('relative') | ||
} | ||
}, | ||
inputicon: { | ||
root: ({ context }) => ({ | ||
className: classNames('absolute top-1/2 -mt-2', { | ||
'left-2': context.iconPosition === 'left', | ||
'right-2': context.iconPosition === 'right' | ||
}) | ||
}) | ||
}, | ||
// For each input wrapped with IconField you will need to add styling. | ||
// The following is an example for InputText | ||
inputtext: { | ||
root: ({ props, context }) => ({ | ||
className: classNames( | ||
// Extend the root stylings with the following: | ||
{ | ||
'pl-8': context.iconPosition === 'left', | ||
'pr-8': props.iconPosition === 'right' | ||
} | ||
) | ||
}) | ||
}, | ||
} | ||
` | ||
}; | ||
|
||
const code2 = { | ||
javascript: ` | ||
import React from 'react'; | ||
import { IconField } from 'primereact/iconfield'; | ||
import { InputIcon } from 'primereact/inputicon'; | ||
import { InputText } from 'primereact/inputtext'; | ||
export default function BasicDemo() { | ||
return ( | ||
<div className="flex gap-3"> | ||
<IconField iconPosition="left"> | ||
<InputIcon className="pi pi-search"> </InputIcon> | ||
<InputText placeholder="Search" /> | ||
</IconField> | ||
<IconField> | ||
<InputIcon className="pi pi-spin pi-spinner"> </InputIcon> | ||
<InputText /> | ||
</IconField> | ||
</div> | ||
) | ||
} | ||
` | ||
}; | ||
|
||
return ( | ||
<> | ||
<DocSectionText {...props}> | ||
<p> | ||
PrimeReact offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the{' '} | ||
<Link href="/tailwind">Tailwind Customization</Link> section for an example. | ||
</p> | ||
<DocSectionCode code={code} hideToggleCode import hideStackBlitz /> | ||
<p>A playground sample with the pre-built Tailwind theme.</p> | ||
<DocSectionCode code={code2} embedded /> | ||
</DocSectionText> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters